Use this with 2 as starting point to find a fraction that is
Solution
Given that we an initial bound on the problem [a, b], then the maximum error of using either a or b as our approximation is h = b a. Because we halve the width of the interval with each iteration, the error is reduced by a factor of 2, and thus, the error after n iterations will be h/2n.
Therefore, thus, if step is fixed, then we may immediately know how many steps are required, after which we are assured that the absolute error is less than step. The inequality
may be solved for an integer value of n by finding:
For example, suppose that our initial interval is [0.7, 1.5]. If we have an step value of 1e-5, then we require a minimum of log2( 0.8/1e-5 ) = 17 steps.
Examples
Example 1
Consider finding the root of f(x) = x2 - 3. Let step = 0.01, abs = 0.01 and start with the interval [1, 2].
Table 1. Bisection method applied to f(x) = x2 - 3.
Thus, with the seventh iteration, we note that the final interval, [1.7266, 1.7344], has a width less than 0.01 and |f(1.7344)| < 0.01, and therefore we chose b = 1.7344 to be our approximation of the root.
Example 2
Consider finding the root of f(x) = e-x(3.2 sin(x) - 0.5 cos(x)) on the interval [3, 4], this time with step = 0.001, abs = 0.001.
Table 1. Bisection method applied to f(x) = e-x(3.2 sin(x) - 0.5 cos(x)).
Thus, after the 11th iteration, we note that the final interval,
| a | b | f(a) | f(b) | c = (a + b)/2 | f(c) | Update | new b a |
|---|---|---|---|---|---|---|---|
| 1.0 | 2.0 | -2.0 | 1.0 | 1.5 | -0.75 | a = c | 0.5 |
| 1.5 | 2.0 | -0.75 | 1.0 | 1.75 | 0.062 | b = c | 0.25 |
| 1.5 | 1.75 | -0.75 | 0.0625 | 1.625 | -0.359 | a = c | 0.125 |
| 1.625 | 1.75 | -0.3594 | 0.0625 | 1.6875 | -0.1523 | a = c | 0.0625 |
| 1.6875 | 1.75 | -0.1523 | 0.0625 | 1.7188 | -0.0457 | a = c | 0.0313 |
| 1.7188 | 1.75 | -0.0457 | 0.0625 | 1.7344 | 0.0081 | b = c | 0.0156 |
| 1.71988/td> | 1.7344 | -0.0457 | 0.0081 | 1.7266 | -0.0189 | a = c | 0.0078 |
