W9_Finding the Roots

download W9_Finding the Roots

of 21

Transcript of W9_Finding the Roots

  • 8/2/2019 W9_Finding the Roots

    1/21

    Centre for Computer Technology

    ICT114Mathematics for

    Computing

    Week 9

    Finding the Roots of f(x)

  • 8/2/2019 W9_Finding the Roots

    2/21

    March 20, 2012 Copyright Box Hill Institute

    Objectives

    Review week 8

    Errors in Computing

    Differential Newtons Method

    Secant Method

    Summary

  • 8/2/2019 W9_Finding the Roots

    3/21

    March 20, 2012 Copyright Box Hill Institute

    Fixed Point Iteration

    It involves evaluating a formula that takesa guess at a root as input and returns an

    updated guess at the root as output. Thesuccess of this method depends on thechoice of the formula that is iterated

  • 8/2/2019 W9_Finding the Roots

    4/21

    March 20, 2012 Copyright Box Hill Institute

    Algorithm : Fixed Point Iteration

    To solvef(x) = 0

    rewrite as

    xnew = g(xold)

    initialize: x0 = . . .for k= 1, 2, . . .

    xk= g(xk-1)if converged, stop

    end

  • 8/2/2019 W9_Finding the Roots

    5/21

    March 20, 2012 Copyright Box Hill Institute

    Bisection Method

    Given an initial bracket for a root, thesystematic halving of the of the bracketaround the root is called the bisectionmethod. Though it does it slowly, it alwaysconverges.

    note: when a root is suspected to lie in therange xleft x xright, the pair (xleft,xright ) isreferred to as a bracket.

  • 8/2/2019 W9_Finding the Roots

    6/21

    March 20, 2012 Copyright Box Hill Institute

    Algorithm : Bisection Method

    initialize: a= . . ., b= . . .for k= 1, 2, . . .

    xm= (a+ b)/2

    if f(xm)

  • 8/2/2019 W9_Finding the Roots

    7/21

    Centre for Computer Technology

    Newtons Method

  • 8/2/2019 W9_Finding the Roots

    8/21

    March 20, 2012 Copyright Box Hill Institute

    Newton's Method

    Using an initial guess at the root and the

    slope of f(x), Newton's method usesextrapolation to estimate where f(x)crosses the x axis. This method converges

    very quickly, but it can diverge if f(x) = 0 isencountered during iterations.

    (f(x) is the differential of f(x))

  • 8/2/2019 W9_Finding the Roots

    9/21

    March 20, 2012 Copyright Box Hill Institute

    Newtons Method

  • 8/2/2019 W9_Finding the Roots

    10/21

    March 20, 2012 Copyright Box Hill Institute

    Newtons Method

    f(x) is the differential for f(x)

  • 8/2/2019 W9_Finding the Roots

    11/21

    March 20, 2012 Copyright Box Hill Institute

    Algorithm

    initialize: x1 = . . .

    for k= 2, 3, . . .xk= xk-1- f(xk-1)/f(xk-1)

    if converged, stop

    end

  • 8/2/2019 W9_Finding the Roots

    12/21

    March 20, 2012 Copyright Box Hill Institute

    Example

  • 8/2/2019 W9_Finding the Roots

    13/21

    March 20, 2012 Copyright Box Hill Institute

  • 8/2/2019 W9_Finding the Roots

    14/21

    Centre for Computer Technology

    Secant Method

  • 8/2/2019 W9_Finding the Roots

    15/21

    March 20, 2012Copyright Box Hill Institute

    Secant Method

    The secant method approximates f(x)from the value of f(x) at two previous

    guesses at the root. It is as fast as theNewton's method but can also fail atf(x)=0.

  • 8/2/2019 W9_Finding the Roots

    16/21

    March 20, 2012Copyright Box Hill Institute

    Secant Method

  • 8/2/2019 W9_Finding the Roots

    17/21

    March 20, 2012Copyright Box Hill Institute

    Secant Method

  • 8/2/2019 W9_Finding the Roots

    18/21

    March 20, 2012Copyright Box Hill Institute

    Algorithm

    initialize: x1 = . . ., x2 = . . .

    for k= 2, 3 .. .

    xk+1 = xk- f(xk)(xk- xk-1)/(f(xk) - f(xk-1))If f(xk+1)

  • 8/2/2019 W9_Finding the Roots

    19/21

    March 20, 2012Copyright Box Hill Institute

    Example

  • 8/2/2019 W9_Finding the Roots

    20/21

    March 20, 2012Copyright Box Hill Institute

    Summary

    Newtons Method - Using an initial guessat the root and the slope of f(x), Newton'smethod uses extrapolation to estimate

    where f(x) crosses the x axis. Secant Method - The secant method

    approximates f(x) from the value of f(x) at

    two previous guesses at the root. It is asfast as the Newton's method but can alsofail at f(x)=0.

  • 8/2/2019 W9_Finding the Roots

    21/21

    March 20, 2012Copyright Box Hill Institute

    References

    Gerald W. Recktenwald, Numerical Methodswith MATLAB, Implementation and Application,Prentice Hall

    H L Verma and C W Gross : Introduction toQuantitative Methods,John Wiley

    JB Scarborough : Numerical MathematicalAnalysis, Jon Hopkins Hall, New Jersey

    Finding the Roots of f(x) = 0, Gerald W.Recktenwald, Department of MechanicalEngineering, Portland State University