Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

Chapter 6

~Roots of Equations ~
Open Methods

“These notes are only to be used in class presentations”


1
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Open Methods

•Bracketing methods depend on knowing the interval in


which the root resides
•What if you don’t know the upper and lower bound
on the root?
• Open methods
– Use a single starting value or two starting values that do
not need to bracket the root.
– May not converge on root but when converge, they
converge faster than braketing methods.

2
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Bracketing methods
(a) In the bisection method the
root is constrained within
the interval [ xl, xu ]

Open methods

(b) and (c) A formula is used


to project from xi to xi+1 in
an iterative fashion
So the method may diverge
(b) or converge (c).

3
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Simple Fixed-Point Iteration
• Given an equation f(x)=0
• Convert f(x)=0 in to the form x=g(x)
f ( x)  0  x  g ( x)
If algebraic manipulation doesn’t work, just add x to both sides
f ( x)  0  x  f ( x)  x
• Let the initial guess be x0
• Then iterate
xi 1  g ( xi )
until the termination criteria is satisfied
Termination criteria
xi 1  xi
a   s OR Max.Iteration is reached
xi 1 4
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 6.1:
Use simple fixed point iteration to locate the root of f ( x)  e  x  x
with an initial guess of x0=0. Iterate until the estimated error εa falls
below a level of εs=0.01
Iter. no xi εa
0 0
1 1
2 0.36788 1.71828
3 0.69220 0.46854
4 0.50047 0.38309
5 0.60624 0.17447
6 0.54540 0.11157
7 0.57961 0.05903
8 0.56012 0.03481
9 0.57114 0.01931
10 0.56488 0.01109
11 0.56843 0.00624
5
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Convergence properties
– May not converge
– If it converges it converges linearly (the error is
roughly proportional to the error of the previous step)
– Convergence depends on the function characteristics
and starting point (initial guess).

6
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Fixed point theorem

Let g(x) and g’(x) are continuous on the interval [a,b].


If g ( x) [a, b] for each x [a, b] and if g ( x)  1 for all x in
the interval [a,b] then the fixed point iterative process
xi 1  g ( xi )
will converge to the root for any initial approximation x0
belonging to the given interval.

7
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
8
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 6.2:

Use fixed point iteration method to determine a solution accurate


to within 0.01 for f(x)=x3-x-1 on [1,2] with x0=1.

Iter. no xi εa
0 1
1 1.2599
2 1.3123 0.0399
3 1.3224 0.0076

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Newton-Raphson Method

• Most widely used method.


• Based on Taylor series expansion:

f ( xi 1 )  f ( xi )  f ( xi )( xi 1  xi )  R1
The root is the value of x i 1 when f(x i 1 )  0
Rearrangin g,
0  f(xi )  f (xi )( xi 1  xi )
f ( xi )
xi 1  xi  Newton-Raphson formula
f ( xi )
10
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Newton-Raphson Method

Geometric interpretation of the slope in the figure

f ( xi )  0
f (xi ) 
( xi  xi 1 )

f ( xi )
xi 1  xi 
f ( xi )

11
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Newton-Raphson Method

Step 1: Choose an initial guess xi for the root


Step 2: Calculate f(xi) and f '(xi)
Step 3: Estimate the root to be
f ( xi )
xi 1  xi 
f ( xi )

Step 4: Calculate
xi 1  xi
a 
xi 1

If εa ≤ εs OR Max.Iteration is reached, terminate the computation.


If not, return to Step 2.
12
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 6.3:

Determine the real root of f ( x)  x3  4 x 2  10


to 2 significant digits using Newton-Raphson Method with an
initial guess of x0=1.

iter. no xi f(xi) df(xi) εa


0 1 -5 11

1 1.45455 1.54020 17.98347


2 1.36890 0.06072 16.57287 0.06256
3 1.36524 0.00011 16.51351 0.00268

13
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 6.4:

Determine the real root of f ( x)  e  x  x


using Newton-Raphson Method with an initial guess of x0=0.
Iterate until the estimated error εa falls below a level of εs=0.01

iter. no xi f(xi) df(xi) εa


0 0 1 -2
1 0.50000 0.10653 -1.60653
2 0.56631 0.00130 -1.56762 0.11709
3 0.56714 0.0000002 -1.56714 0.00147

14
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 6.5:
x1
Determine the real root of sin( 2 x )  e
correct to 2 significant digits using Newton-Raphson Method
with an initial guess of x0=0.

iter.no xi f(xi) df(xi) εa


0 0.000000 -0.367879 1.632121
1 0.225400 -0.025203 1.339310
2 0.244217 -0.000399 1.296494 0.077053
3 0.244525 0.000000 1.295772 0.001257

15
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
• Newton-Raphson is an efficient method if f’(x) (the derivative)
can be evaluated analytically
• Rate of convergence is quadratic, i.e. the error is roughly
proportional to the square of the previous error
Ei+1=O(Ei2)
**Proof will be given in class
But:
• It does not always converge
• There is no convergence criterion. Convergence depends on
the nature of the function and on the accuracy of the initial
guess.

16
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Diverges because f''(x)=0 in
the vicinity of the root.

Oscillates around a local


minimum or maximum.

Diverges because of near


zero slopes.

Diverges because f '(x) =0.

17
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Secant Method
• Requires two initial
estimates xi and xi-1.
• However, it is not a
“bracketing method”
because f(x) is not required
to change signs between
estimates.
• The Secant Method has the
same properties as
Newton’s method.
• Convergence is not
guaranteed
18
18

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Secant Method

• If derivative f’(x) can not be computed analytically then we


need to compute it numerically (backward finite divided
difference method)

RESULT: NR becomes SECANT METHOD

df f ( xi )  f ( xi 1 )
f ( xi )   substitute this into NR equation
dx xi  xi 1

xi  xi 1
xi 1  xi  f ( xi ) i  1,2,3,
f ( xi )  f ( xi 1 )

19
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Secant Method

Step 1: Choose two initial guesses xi and xi-1 for the root
Step 2: Calculate f(xi) and f (xi-1)
Step 3: Estimate the root to be
xi  xi 1
xi 1  xi  f ( xi )
f ( xi )  f ( xi 1 )
Step 4: Calculate
xi 1  xi
a 
xi 1

If εa ≤ εs OR Max.Iteration is reached, terminate the computation.


If not, return to Step 2.
20
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 6.6:

Determine the real root of f ( x)  x3  4 x 2  10


using Secant Method with with initial estimates of x-1=1 and
x0=2. Iterate until the estimated error εa falls below a level of
εs=0.01 . Give your answers using 5 decimal digits with
rounding.

Iter. no xi-1 xi f(xi) εa


0 1 2 14
1 2 1.26316 -1.60227
2 1.26316 1.33883 -0.43036 0.05652
3 1.33883 1.36662 0.02291 0.02033
4 1.36662 1.36521 -0.00030 0.00103

21
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 6.7:
Determine the real root of f ( x)  e  x  x
using Secant Method with initial estimates of x-1=0 and x0=1.
Iterate until the estimated error εa falls below a level of εs=0.01.
Give your answers using 4 decimal digits with rounding.

Iter. no xi-1 xi f(xi) εa


0 0 1 -0.6321
1 1 0.6127 -0.0708
2 0.6127 0.5638 0.0052 0.0867
3 0.5638 0.5672 -4.242e-5 0.0059

22
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Secant Method vs. False-Position Method
• False-Position method always brackets the root
• False-Position will always converge
• Secant method may not converge
• Secant method usually converges much faster

The 1st iterations (a) and (b)


for two methods are identical

For the 2nd iterations (c) and


(d), the points used differ.

23
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Modified Secant Method
•Instead of using two arbitrary values to estimate the derivative,
we define a small δ (perturbation fraction)
f ( xi  xi )  f ( xi )
f ( xi ) 
xi
Substitute this derivative back into the equation:
xi
xi 1  xi  f ( xi )
f ( xi  xi )  f ( xi )

How to choose δ:
•If δ is too small, then the method will involve too much round-off error.
•If δ is too large, then the method is inefficient and may diverge
24
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 6.8:

Determine the real root of f ( x)  x 2  2 xe  x  e 2 x

using Modified Secant Method with an initial estimate of x0=0.06


and δ=0.01. Iterate until the estimated error εa falls below a level
of εs=0.1

iteration xi f(xi) εa
0 0.6 0.0026

1 0.5848 0.0008
2 0.5772 0.00025 0.0132

25
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
A computer program for the root-finding methods

1. A plotting routine should be included in the program.


2. At the end of the computation, the final root estimate
should always be substituted into the original function to
compute whether the result is close to zero.
3. The program should always include an upper limit on the
number of iterations to guard agains divergence.
4. The program should alert the user and take account of the
possibility that f' (x) might equal zero at any time during
the computation. (division by zero)

26
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Multiple Roots

Function is tangent to the x-axis at the


double root.

f ( x )  ( x  3)( x  1)2

Function is tangent to the x-axis at the


triple root bu that for this case the axis is
crossed.
f ( x)  ( x  3)( x  1)3

27
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1. Bracketing methods don’t work for the multiple roots.
2. Both f(x) & f´(x) goes to 0 at the root
3. Newton-Raphson and Secant Methods are linearly convergent for multiple
roots ( Ralston and Rabinowitz, 1978)

One way to ensure quadratic convergence is to define a function, which has


roots at all the same locations as the original function.
u( xi )
u( x ) 
f ( x) xi 1  xi 
f ( x ) u( xi )
Substitute this back into NR equation Alternative form for secant method;

f ( xi ) f ( xi ) u ( xi )( xi 1  xi )
xi 1  xi  xi 1  xi 
 f ( xi )2  f ( xi ) f ( xi ) u( xi 1 )  u ( xi )

 These equations are preferable for multiple roots but less efficient for single root

28
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 6.9: Use both the standard and modified Newton-Raphson
methods to evaluate the multiple root of

f ( x )  ( x  3)( x  1)( x  1)

with an initial guess of x0=0. Iterate until the estimated error εa


falls below a level of εs=0.01 .

29
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The results for multiple roots
Modified Newton-Raphson method

iteration xi f(xi) df(xi) εa


0 0 -3 7

1 1.10526 -0.02099 -0.38781


2 1.00308 -0.00002 -0.01230 0.10187
3 1.00000 -1.13e-11 -0.00001 0.00308

Standard Newton-Raphson method


iteration xi f(xi) df(xi) εa
1 0 -3 7

2 0.42857 -0.83965 3.26531


3 0.68571 -0.22859 1.55347 0.17668
4 0.83287 -0.06054 0.75234 0.08810
5 0.91333 -0.01567 0.36922 0.04442
6 0.95578 -0.00400 0.18273 0.02237
7 0.97766 -0.00101 0.09088 0.01124
8 0.98877 -0.00025 0.04531 0.00563
30
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Solve for the same function at x0=4 with both methods
The results for single root
Modified Newton-Raphson method
iteration xi f(xi) df(xi) εa
0 4 9 15

1 2.63636 -0.97370 1.48760


2 2.82022 -0.59563 2.65876 0.06519
3 2.96173 -0.14728 3.69822 0.04778
4 2.9985 -0.0061 3.98784 0.01226
5 3.00000 -0.00001 3.99998 0.00051

Standard Newton-Raphson method


iteration xi f(xi) df(xi) εa
1 4 9 15

2 3.40000 2.30400 7.68000


3 3.10000 0.44100 4.83000 0.03035
4 3.00870 0.03509 4.06979 0.00287
31
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

You might also like