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)

Outline

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:

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.

    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.

    Newton's Method

    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
    kxk
    12
    22.25
    32.2361111
    42.2360798
    infinity2.2360798
  4. A nice description of the Newton method with an animated graphic is given here .
  5. Comments:

    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:

    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:

    Hybrid Method

    Combine speed of secant method with safe convergence of bisection.
    1. Start with bracketing interval.
    2. Perform one secant step to get xk.
    3. If the secant step goes outside of the bracketing interval, do bisection instead.
    4. Refine the bracketing interval using the new xk.
    5. 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