2 The bisection method
Suppose that, by trial and error for example, we know that a single zero of some function lies between and . The root is said to be bracketed by and . This must mean that and are of opposite signs, that is that .
Example 23
The single positive zero of the function models the wave number of water waves at a certain frequency in water of depth (measured in some units we need not worry about here). Find two points which bracket the zero of .
Solution
We simply evaluate at a selection of -values.
From this we can see that changes sign between and . Thus we can take and as the bracketing points. That is, the zero of is in the bracketing interval .
Task!
The function has a single positive zero. Find bracketing points and for the zero of . Arrange for the difference between and to be equal to .
(NB - be careful to use radians on your calculator!)
We evaluate for a range of values:
Clearly
changes sign between the bracketing values
and
.
(Other answers are valid of course, it depends which values of
you tried.)
The aim with the bisection method is to repeatedly reduce the width of the bracketing interval so that it “pinches" the required zero of to some desired accuracy. We begin by describing one iteration of the bisection method in detail.
Let , the mid-point of the interval . All we need to do now is to see in which half (the left or the right) of the interval the zero is in. We evaluate . There is a (very slight) chance that , in which case our job is done and we have found the zero of . Much more likely is that we will be in one of the two situations shown in Figure 13 below. If then we are in the situation shown in (a) and we replace with the smaller bracketing interval . If, on the other hand, then we are in the situation shown in (b) and we replace with the smaller bracketing interval .
Figure 13
Either way, we now have a bracketing interval that is half the size of the one we started with. We have carried out one iteration of the bisection method. By successively reapplying this approach we can make the bracketing interval as small as we wish.
Example 24
Carry out one iteration of the bisection method so as to halve the width of the bracketing interval for
Solution
The mid-point of the bracketing interval is . We evaluate
to 4 decimal places. We found earlier (Example 20, page 63) that and , the fact that is of the opposite sign to means that the zero of lies in the bracketing interval .
Task!
Carry out one iteration of the bisection method so as to halve the width of the bracketing interval for
Here . The mid-point of the bracketing interval is . We evaluate
We found earlier (Task, pages 58-59) that and , the fact that is of the opposite sign to means that the zero of lies in the bracketing interval .
So we have a way of halving the size of the bracketing interval. By repeatedly applying this approach we can make the interval smaller and smaller.
The general procedure, involving (possibly) many iterations, is best described as an algorithm:
- Choose an error tolerance.
- Let , the mid-point of the bracketing interval.
-
There are three possibilities:
- , this is very unlikely in general, but if it does happen then we have found the zero of and we can go to step 7 ,
- the zero is between and ,
- the zero is between and .
- If the zero is between and , that is if (as in Figure 13(a)) then let .
- Otherwise the zero must be between and (as in Figure 13(b)) so let .
- If is greater than the required tolerance then go to step 2 .
- End.
One feature of this method is that we can predict in advance how much effort is required to achieve a certain level of accuracy.
Example 25
A given problem using the bisection method starts with the bracketing points and . How many iterations will be required so that the error in the approximation is less that ?
Solution
Before we carry out any iterations we can write that the zero to be approximated is
so that the maximum magnitude of the error in 1.75 may be taken to be equal to 0.25.
Each successive iteration will halve the size of the error, so that after
iterations the error is equal to
We require that this quantity be less than . Now,
The smallest value of which satisfies this inequality can be found by trial and error, or by using logarithms to see that . Either way, the smallest integer which will do the trick is
It takes 19 iterations of the bisection method to ensure the required accuracy.
Task!
A function is known to have a single zero between the points and . If these values were used as the initial bracketing points in an implementation of the bisection method, how many iterations would be required to ensure an error less than ?
We require that
or, after a little rearranging,
The smallest value of which satisfies this is . (This can be found by trial-and-error or by using logarithms.)
2.1 Pros and cons of the bisection method
Pros
- the method is easy to understand and remember
- the method always works (once you find values and which bracket a single zero)
- the method allows us to work out how many iterations it will take to achieve a given error tolerance because we know that the interval will exactly halve at each step
Cons
- the method is very slow
- the method cannot find roots where the curve just touches the -axis but does not cross it (e.g. double roots)
The slowness of the bisection method will not be a surprise now that you have worked through an example or two! Significant effort is involved in evaluating and then all we do is look at this -value and see whether it is positive or negative! We are throwing away hard won information.
Let us be realistic here, the slowness of the bisection method hardly matters if all we are saying is that it takes a few more fractions of a second of computing time to finish, when compared with a competing approach. But there are applications in which may be very expensive (that is, slow) to calculate and there are applications where engineers need to find zeros of a function many thousands of times. (Coastal engineers, for example, may employ mathematical wave models that involve finding the wave number we saw in Example 20 at many different water depths.) It is quite possible that you will encounter applications where the bisection method is just not good enough.