Back to 498CQM Home
Calendar / Outine
Previous Lecture
Next Lecture

# Phys 498CQM Lecture 2

Author: Erik Koch, Modified by R. Martin
HW 1 (due 1/31)

## Root Finding

Root finding involves finding a real solution x0 to the equation f(x) = 0 for some function f(x).

There are two kinds of roots to consider:

• Odd roots - sign changes across x0. These are the roots that will be considered in this section.
• Even roots - no sign change. Numerically, these pose problems. If you add some numerical uncertainty to the function (f = f + constant), there root can split into two roots or disappear (become complex). Thus, if you are looking for an even root, it is best to solve for a local extremum instead.

### Bisection Method

Start with an interval [ a, b ] that brackets the root. The interval should only bracket one root, so that f(a) × f(b) < 0. The bisection algorithm divides this interval each iteration, succesively refining the approximation for the root:
1. xn+1 = ( a + b ) / 2
2. If f( xn+1 × f(a) > 1 then let a = xn+1
3. 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.

• 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.

### Newton's Method

Make a linear approximation to the function each iteration to get a better guess at the root.

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
4. A nice description of the Newton method with an animated graphic is given here .

• 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.

### Secant Method

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) ]

• 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.

### Hybrid Method

Combine speed of secant method with safe convergence of bisection.