- xn+1 = ( a + b ) / 2
- If f( xn+1 × f(a) > 1 then let a = xn+1
- If f( xn+1 × f(b) > 1 then let a = xn+1
Thus the new [ a, b ] is a smaller interval that brackets the root.
Comments:
- Each step halves the interval size.
- Convergence is guaranteed (you can't lose the root).
- This method has "linear" convergence, that is, the log of the error
decreases linearly with the number of iterations.
When do you stop? This choice can can some difficulties:
- Absolute error: | a - b | < delta. This will not work if x0
is very large, since round off error in | a - b | may be larger than
delta.
- Relative error: | a - b | < delta × | a |. This runs into
problems near x = 0.
- Ill-conditioned root. If the slope of f(x) is very small near the
root, then there may be a range of x values for which f(x) is nearly
zero. Machine round-off error can prohibit determination of the
correct value of x0 in this case.
Make a linear approximation to the function each iteration to get
a better guess at the root.
Start with an x1 near the root. Iterate using the
formula:
xn+1 = xn - f ( xn ) / f' ( xn )
(This formula can be easily derived from a taylor expansion about
xn.)
Example - Caluclate the Square Root of 5
- f(x) = x2 - 5
- f'(x) = 2 x
- so xk+1 = xk - ( x2 - 5 ) / 2 x
k | xk |
1 | 2 |
2 | 2.25 |
3 | 2.2361111 |
4 | 2.2360798 |
infinity | 2.2360798 |
-
A nice description of the Newton method with an animated graphic is given
here .
Comments:
- Much faster convergence than bisection (superlinear).
- But - this method can head to other roots, go to infinity, or
get trapped in cycles. NOT GUARENTEED TO CONVERGE.
This is an example of a quasi-Newton method.
If you don't know f'(x), you can approximate using a numerical
derivative.
The obvious choice (but not a good choice) is
f'(x) - [ f(x+h) - f(x) ] / h
There are a couple of problems with this:
- Extra evaluations of f are neccesary.
- The proper choice for h is not obvious.
The secant method uses the previous point in the sequence for
the approximation of the derivative.
Start by choosing
[ x1, x2 ] that is near the root. (This
interval does not have to bracket the root.)
Iterate according to
xn+1 = xn - f(xn) ×
( xn - xn-1 ) / [ f(xn) -
f(xn-1) ]
Comments:
- Much faster convergence than bisection (superlinear), but can
be slower than Newton's method.
- You don't need to calculate f'.
- Just like Newton's method,
this method can head to other roots, go to infinity, or
get trapped in cycles. NOT GUARENTEED TO CONVERGE.
Combine speed of secant method with safe convergence of bisection.
- Start with bracketing interval.
- Perform one secant step to get xk.
- If the secant step goes outside of the bracketing interval,
do bisection instead.
- Refine the bracketing interval using the new xk.
- Repeat loop until converged.
The 'standard' (Brent's method) for calculating roots of a nonlinear
equation without using derivatives is a hybrid method, combining
root bracketing, bisection, and inverse quaderature interpolation
(instead of the linear interpolation used in our example).
For an example, see the function
zeroin.f from
netlib.
Last Modified Jan. 1
Email question/comments/corrections to
rmartin@uiuc.edu