3. Roots of Equations Contd

download 3. Roots of Equations Contd

of 58

Transcript of 3. Roots of Equations Contd

  • 8/12/2019 3. Roots of Equations Contd

    1/58

    Roots of Equations: Open

    methods Newton-Raphson

    Secant Method Muller methods

  • 8/12/2019 3. Roots of Equations Contd

    2/58

    Newton-Raphson Method

  • 8/12/2019 3. Roots of Equations Contd

    3/58

    Newton-Raphson Method

    )(x f ) f(x

    -= x xi

    iii 1

    f(x)

    f(x i)

    f(x i-1)

    xi+2 x i+1 x i X

    ii x f x ,

    Figure 1 Geometrical illustration of the Newton-Raphson method. http://numericalmethods.eng.usf.edu3

  • 8/12/2019 3. Roots of Equations Contd

    4/58

    Derivation

    f(x)

    f(xi)

    xi+1 x i X

    B

    C A

    )()(

    1i

    iii x f

    x f x x

    1

    )()('

    ii

    ii

    x x x f

    x f

    AC AB

    tan(

    Figure 2 Derivation of the Newton-Raphson method. 4http://numericalmethods.eng.usf.edu

  • 8/12/2019 3. Roots of Equations Contd

    5/58

    Algorithm for Newton-RaphsonMethod

    5http://numericalmethods.eng.usf.edu

  • 8/12/2019 3. Roots of Equations Contd

    6/58

    Step 1

    )( x f Evaluate symbolically.

    http://numericalmethods.eng.usf.edu6

  • 8/12/2019 3. Roots of Equations Contd

    7/58

    Step 2

    i

    iii x f

    x f -= x x 1

    Use an initial guess of the root, , to estimate the new value of the root, , asi x 1i x

    http://numericalmethods.eng.usf.edu7

  • 8/12/2019 3. Roots of Equations Contd

    8/58

    Step 3

    0101

    1 x

    - x x =

    i

    iia

    Find the absolute relative approximate error as a

    http://numericalmethods.eng.usf.edu8

  • 8/12/2019 3. Roots of Equations Contd

    9/58

    Step 4

    Compare the absolute relative approximate error withthe pre-specified relative error tolerance .

    Also, check if the number of iterations has exceeded themaximum number of iterations allowed. If so, one needsto terminate the algorithm and notify the user.

    s

    Is ?

    Yes

    No

    Go to Step 2 using newestimate of the root.

    Stop the algorithm

    sa

    http://numericalmethods.eng.usf.edu9

  • 8/12/2019 3. Roots of Equations Contd

    10/58

    Example 1

    A polynomial is expressed as

    423 1099331650 -.+ x.- x x f Use the Newtons method of finding roots of equations to finda) The root x. Conduct three iterations to estimate the root of the above

    equation.

    b) The absolute relative approximate error at the end of each iteration, andc) The number of significant digits at least correct at the end of each iteration.

    http://numericalmethods.eng.usf.edu10

  • 8/12/2019 3. Roots of Equations Contd

    11/58

    Example 1 Cont.

    423 1099331650 -.+ x.- x x f

    11http://numericalmethods.eng.usf.edu

    To aid in the understanding of how thismethod works to find the root of an

    equation, the graph of f(x) is shown to theright, where

    Solution

    Figure 4 Graph of the function f(x)

  • 8/12/2019 3. Roots of Equations Contd

    12/58

    Example 1 Cont.

    12http://numericalmethods.eng.usf.edu

    x- x x f

    .+ x.- x x f -

    33.03'

    10993316502

    423

    Let us assume the initial guess of the root of is . 0 x f m05.00 x

    Solve for x f '

  • 8/12/2019 3. Roots of Equations Contd

    13/58

    Example 1 Cont.

    06242.0

    01242.00.05

    109

    10118.1

    0.05

    05.033.005.03

    10.993305.0165.005.005.0

    '

    3

    4

    2

    423

    0

    001

    x f x f

    x x

    13http://numericalmethods.eng.usf.edu

    Iteration 1The estimate of the root is

  • 8/12/2019 3. Roots of Equations Contd

    14/58

    Example 1 Cont.

    14http://numericalmethods.eng.usf.eduFigure 5 Estimate of the root for the first iteration.

  • 8/12/2019 3. Roots of Equations Contd

    15/58

    Example 1 Cont.

    %90.19

    10006242.0

    05.006242.0

    1001

    01

    x x x

    a

    15http://numericalmethods.eng.usf.edu

    The absolute relative approximate error at the end of Iteration 1 isa

    The number of significant digits at least correct is 0, as you need an absoluterelative approximate error of 5% or less for at least one significant digits to becorrect in your result.

  • 8/12/2019 3. Roots of Equations Contd

    16/58

    Example 1 Cont.

    06238.0

    104646.406242.0

    1090973.8

    1097781.306242.0

    06242.033.006242.03

    10.993306242.0165.006242.006242.0

    '

    5

    3

    7

    2

    423

    1

    1

    12 x f

    x f x x

    16http://numericalmethods.eng.usf.edu

    Iteration 2The estimate of the root is

  • 8/12/2019 3. Roots of Equations Contd

    17/58

    Example 1 Cont.

    17http://numericalmethods.eng.usf.eduFigure 6 Estimate of the root for the Iteration 2.

  • 8/12/2019 3. Roots of Equations Contd

    18/58

    Example 1 Cont.

    %0716.0

    10006238.0

    06242.006238.0

    100

    2

    12

    x

    x xa

    18http://numericalmethods.eng.usf.edu

    The absolute relative approximate error at the end of Iteration 2 isa

    The maximum value of m for which is 2.844. Hence,the number of significant digits at least correct in the answer is 2.

    m

    a

    2105.0

  • 8/12/2019 3. Roots of Equations Contd

    19/58

    Example 1 Cont.

    06238.0

    109822.406238.0

    1091171.81044.406238.0

    06238.033.006238.03

    10.993306238.0165.006238.006238.0

    '

    9

    3

    11

    2

    423

    2

    223

    x f x f

    x x

    19http://numericalmethods.eng.usf.edu

    Iteration 3The estimate of the root is

  • 8/12/2019 3. Roots of Equations Contd

    20/58

    Example 1 Cont.

    20http://numericalmethods.eng.usf.eduFigure 7 Estimate of the root for the Iteration 3.

  • 8/12/2019 3. Roots of Equations Contd

    21/58

    Example 1 Cont.

    %0

    10006238.0

    06238.006238.0

    100

    2

    12

    x

    x xa

    21http://numericalmethods.eng.usf.edu

    The absolute relative approximate error at the end of Iteration 3 isa

    The number of significant digits at least correct is 4, as only 4 significantdigits are carried through all the calculations.

  • 8/12/2019 3. Roots of Equations Contd

    22/58

    Advantages and Drawbacks ofNewton Raphson Method

    22http://numericalmethods.eng.usf.edu

  • 8/12/2019 3. Roots of Equations Contd

    23/58

    Advantages

    Converges fast (quadratic convergence), if itconverges.

    Requires only one guess

    23http://numericalmethods.eng.usf.edu

  • 8/12/2019 3. Roots of Equations Contd

    24/58

    Drawbacks

    24http://numericalmethods.eng.usf.edu

    1. Divergence at inflection pointsSelection of the initial guess or an iteration value of the root that is closeto the inflection point of the function may start diverging away fromthe root in the Newton-Raphson method.

    For example, to find the root of the equation .

    The Newton-Raphson method reduces to .

    Table 1 shows the iterated values of the root of the equation.

    The root starts to diverge at Iteration 6 because the previous estimate of0.92589 is close to the inflection point of .

    Eventually after 12 more iterations the root converges to the exact value of

    x f

    0512.01 3 x x f

    2

    33

    113

    512.01

    i

    iii

    x x

    x x

    1 x

    .2.0 x

  • 8/12/2019 3. Roots of Equations Contd

    25/58

    Drawbacks Inflection Points

    IterationNumber

    x i

    0 5.0000

    1 3.6560

    2 2.7465

    3 2.1084

    4 1.60005 0.92589

    6 30.119

    7 19.746

    18 0.2000 0512.01 3 x x f 25http://numericalmethods.eng.usf.edu

    Figure 8 Divergence at inflection point for

    Table 1 Divergence near inflection point.

  • 8/12/2019 3. Roots of Equations Contd

    26/58

    2. Division by zeroFor the equation

    the Newton-Raphson methodreduces to

    For , thedenominator will equal zero.

    Drawbacks Division by Zero

    0104.203.0 623 x x x f

    26http://numericalmethods.eng.usf.edu

    ii

    iiii

    x x

    x x x x

    06.03

    104.203.02

    623

    1

    02.0or0 00 x x Figure 9 Pitfall of division by zeroor near a zero number

  • 8/12/2019 3. Roots of Equations Contd

    27/58

    Results obtained from the Newton-Raphson method may oscillateabout the local maximum or minimum without converging on a rootbut converging on the local maximum or minimum.

    Eventually, it may lead to division by a number close to zero and maydiverge.

    For example for the equation has no real roots.

    Drawbacks Oscillations near localmaximum and minimum

    022 x x f

    27http://numericalmethods.eng.usf.edu

    3. Oscillations near local maximum and minimum

  • 8/12/2019 3. Roots of Equations Contd

    28/58

    Drawbacks Oscillations near localmaximum and minimum

    28http://numericalmethods.eng.usf.edu

    -1

    0

    1

    2

    3

    4

    5

    6

    -2 -1 0 1 2 3

    x

    f(x)

    3

    4

    2

    1

    - - 3.142

    Figure 10 Oscillations around localminima for . 22 x x f

    Iteration Number

    0123

    456789

    1.00000.5

    1.75 0.30357

    3.14231.2529

    0.171665.73952.69550.97678

    3.002.255.0632.092

    11.8743.5702.02934.9429.2662.954

    300.00128.571476.47

    109.66150.80829.88102.99112.93175.96

    Table 3 Oscillations near local maxima andmimima in Newton-Raphson method.

    i x i x f %a

  • 8/12/2019 3. Roots of Equations Contd

    29/58

    4. Root JumpingIn some cases where the function is oscillating and has a number of roots,one may choose an initial guess close to a root. However, the guesses may jumpand converge to some other root.

    For example

    Choose

    It will converge to

    instead of-1.5

    -1

    -0.5

    0

    0.5

    1

    1.5

    -2 0 2 4 6 8 10

    x

    f(x)

    -0.06307 0.5499 4.461 7.539822

    Drawbacks Root Jumping

    0sin x x f

    29http://numericalmethods.eng.usf.edu

    x f

    539822.74.20 x0 x

    2831853.62 x Figure 11 Root jumping from intendedlocation of root for

    . 0sin x x f

  • 8/12/2019 3. Roots of Equations Contd

    30/58

    Secant Method

  • 8/12/2019 3. Roots of Equations Contd

    31/58

    31

    Secant Method Derivation

    )(x f ) f(x

    -= x xi

    iii 1

    f(x)

    f(x i)

    f(x i-1)

    x i+2 x i+1 x i X

    ii x f x ,

    1

    1 )()()(ii

    iii x x

    x f x f x f

    )()())((

    1

    11

    ii

    iiiii x f x f

    x x x f x x

    Newtons Method

    Approximate the derivative

    Substituting Equation (2) intoEquation (1) gives the Secantmethod

    (1)

    (2)

    Figure 1 Geometrical illustration of theNewton-Raphson method.

  • 8/12/2019 3. Roots of Equations Contd

    32/58

    32

    Secant Method Derivation

    )()())((

    1

    11

    ii

    iiiii x f x f

    x x x f x x

    The Geometric Similar Trianglesf(x)

    f(x i)

    f(x i-1)

    xi+1 xi-1 xi X

    B

    C

    E D A

    11

    1

    1

    )()( ii

    i

    ii

    i

    x x x f

    x x x f

    DE

    DC

    AE

    AB

    Figure 2 Geometrical representation ofthe Secant method.

    The secant method can also be derived from geometry:

    can be written as

    On rearranging, the secant methodis given as

  • 8/12/2019 3. Roots of Equations Contd

    33/58

    http://numericalmethods.eng.usf.edu

    33

    Algorithm for Secant Method

  • 8/12/2019 3. Roots of Equations Contd

    34/58

    34

    Step 1

    0101

    1 x - x x = iiia

    Calculate the next estimate of the root from two initial guesses

    Find the absolute relative approximate error

    )()())((

    1

    1

    1ii

    iii

    ii x f x f x x x f

    x x

  • 8/12/2019 3. Roots of Equations Contd

    35/58

    35

    Step 2

    Find if the absolute relative approximate error is greater thanthe prespecified relative error tolerance.

    If so, go back to step 1, else stop the algorithm.

    Also check if the number of iterations has exceeded themaximum number of iterations.

  • 8/12/2019 3. Roots of Equations Contd

    36/58

    36

    Example 1 Cont.

    Use the Secant method of finding roots of equations to find the x Conduct three iterations to estimate the root of the above equation. Find the absolute relative approximate error and the number of significantdigits at least correct at the end of each iteration.

    A polynomial is given as

    423

    1099331650-

    .+ x.- x x f

  • 8/12/2019 3. Roots of Equations Contd

    37/58

    http://numericalmethods.eng.usf.edu 37

    Example 1 Cont.

    423 1099331650 -.+ x.- x x f

    To aid in the understanding of how thismethod works to find the root of an

    equation, the graph of f(x) is shown to theright,

    where

    Solution

    Figure 4 Graph of the function f(x).

  • 8/12/2019 3. Roots of Equations Contd

    38/58

    http://numericalmethods.eng.usf.edu 38

    Example 1 Cont.

    Let us assume the initial guesses of the root ofas and

    0 x f 02.01 x

    Iteration 1The estimate of the root is

    06461.0

    10993.302.0165.002.010993.305.0165.005.0

    02.005.010993.305.0165.005.005.0

    423423

    423

    10

    10001 x f x f

    x x x f x x

    .05.00 x

  • 8/12/2019 3. Roots of Equations Contd

    39/58

    http://numericalmethods.eng.usf.edu 39

    Example 1 Cont.

    The absolute relative approximate error at the end of Iteration1 is

    %62.22

    10006461.0

    05.006461.0

    1001

    01

    x x x

    a

    a

    The number of significant digits at least correct is 0, as you needan absolute relative approximate error of 5% or less for onesignificant digits to be correct in your result.

  • 8/12/2019 3. Roots of Equations Contd

    40/58

    http://numericalmethods.eng.usf.edu 40

    Example 1 Cont.

    Figure 5 Graph of results of Iteration 1.

  • 8/12/2019 3. Roots of Equations Contd

    41/58

    http://numericalmethods.eng.usf.edu 41

    Example 1 Cont.

    Iteration 2The estimate of the root is

    06241.0

    10993.305.0165.005.010993.306461.0165.006461.0

    05.006461.010993.306461.0165.006461.006461.0

    423423

    423

    01

    01112 x f x f

    x x x f x x

  • 8/12/2019 3. Roots of Equations Contd

    42/58

    http://numericalmethods.eng.usf.edu 42

    Example 1 Cont.

    The absolute relative approximate error at the end ofIteration 2 is

    %525.3

    10006241.0

    06461.006241.0

    1002

    12

    x x x

    a

    a

    The number of significant digits at least correct is 1, as you needan absolute relative approximate error of 5% or less.

  • 8/12/2019 3. Roots of Equations Contd

    43/58

    http://numericalmethods.eng.usf.edu 43

    Example 1 Cont.

    Figure 6 Graph of results of Iteration 2.

  • 8/12/2019 3. Roots of Equations Contd

    44/58

    http://numericalmethods.eng.usf.edu 44

    Example 1 Cont.

    Iteration 3The estimate of the root is

    06238.0

    10993.306461.0165.005.010993.306241.0165.006241.0

    06461.006241.010993.306241.0165.006241.006241.0

    423423

    423

    12

    12223 x f x f

    x x x f x x

  • 8/12/2019 3. Roots of Equations Contd

    45/58

    http://numericalmethods.eng.usf.edu 45

    Example 1 Cont.

    The absolute relative approximate error at the end ofIteration 3 is

    %0595.0

    10006238.0

    06241.006238.0

    1003

    23

    x x x

    a

    a

    The number of significant digits at least correct is 5, as you needan absolute relative approximate error of 0.5% or less.

  • 8/12/2019 3. Roots of Equations Contd

    46/58

    http://numericalmethods.eng.usf.edu 46

    Iteration #3

    Figure 7 Graph of results of Iteration 3.

  • 8/12/2019 3. Roots of Equations Contd

    47/58

    http://numericalmethods.eng.usf.edu 47

    Advantages

    Converges fast, if it converges Requires two guesses that do not need to bracket

    the root

  • 8/12/2019 3. Roots of Equations Contd

    48/58

    http://numericalmethods.eng.usf.edu 48

    Drawbacks

    Division by zero

    10 5 0 5 102

    1

    0

    1

    2

    f(x) prev . guessnew guess

    2

    2

    0

    f x( )

    f x( )

    f x( )

    1010 x x guess1 x guess2

    0 xSin x f

  • 8/12/2019 3. Roots of Equations Contd

    49/58

    http://numericalmethods.eng.usf.edu 49

    Drawbacks (continued)

    Root Jumping

    10 5 0 5 102

    1

    0

    1

    2

    f(x)x'1, (first guess)x0, (previous guess)Secant linex1, (new guess)

    2

    2

    0

    f x( )

    f x( )

    f x( )

    secant x( )

    f x( )

    1010 x x 0 x 1' x x 1

    0Sinx x f

  • 8/12/2019 3. Roots of Equations Contd

    50/58

    50

    Mller Method

    M llers method obtains a root estimate by projecting a parabola to the x axis through threefunction values.

  • 8/12/2019 3. Roots of Equations Contd

    51/58

    51

    Mller Method

    c x xb x xa x f )()()( 22

    22

    The method consists of deriving thecoefficients of parabola that goes through thethree points:

    1. Write the equation in a convenient form:

  • 8/12/2019 3. Roots of Equations Contd

    52/58

    52

    2. The parabola should intersect the three points [x o , f(x o )],[x 1 , f(x 1 )], [x 2 , f(x 2 )]. The coefficients of the polynomial

    can be estimated by substituting three points to give

    3. Three equations can be solved for three unknowns, a, b,c. Since two of the terms in the 3 rd equation are zero, itcan be immediately solved for c=f(x 2 ).

    c x xb x xa x f

    c x xb x xa x f

    c x xb x xa x f ooo

    )()()(

    )()()(

    )()()(

    222222

    212

    211

    22

    2

    )()()()(

    )()()()(

    212

    2121

    22

    22

    x xb x xa x f x f

    x xb x xa x f x f ooo

  • 8/12/2019 3. Roots of Equations Contd

    53/58

    53

    )(

    )()(

    )()()()(

    x-xhx-xh

    If

    2111

    1

    112

    11

    11

    2

    11

    12

    121

    1

    1

    121o1o

    x f cahbhh

    a

    hahbhhhahhbhh

    x x x f x f

    x x x f x f

    o

    o

    oooo

    o

    oo

    Solved for aand b

  • 8/12/2019 3. Roots of Equations Contd

    54/58

    54

    Roots can be found by applying an alternative form ofquadratic formula:

    The error can be calculated as

    term yields two roots, the sign is chosen to agree with b . Thiswill result in a largest denominator, and will give root estimatethat is closest to x 2.

    acbbc x x

    42223

    %1003

    23

    x x x

    a

  • 8/12/2019 3. Roots of Equations Contd

    55/58

    55

    Once x3 is determined, the process is

    repeated using the following guidelines:1. If only real roots are being located, choose the

    two original points that are nearest the new rootestimate, x3.

    2. If both real and complex roots are estimated,employ a sequential approach just like in secantmethod, x1 , x 2, and x3 to replace xo , x 1, and x2.

  • 8/12/2019 3. Roots of Equations Contd

    56/58

    Example

  • 8/12/2019 3. Roots of Equations Contd

    57/58

  • 8/12/2019 3. Roots of Equations Contd

    58/58