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

 The bracketed methods are convergent

because they move closer progressively to the


root. They need two initial estimates that
bracket the solution.
 In the open methods, one starting value is
needed or two values that do not necessarily
bracket the root. However, they may diverge
from the true root.
 When successful, they are much faster than
the bracketing methods.

Numerical Methods 2
Using the Taylor series expansion, the NR iterative formula
can be expressed as:
f ( xi  h)  f ( xi )  f ( xi )( xi 1  xi )  0
f ( xi ) f(x)
xi 1 = xi 
f ( xi )
Graphically, this is equivalent
f(xi)
x f x 
i, i

to drawing a tangent to the


function at [xi,f(xi)] and the point
where the tangent crosses the f(xi-1)

x-axis represents an improved 


X
estimate of the root. xi+2 xi+1 xi

Numerical Methods 3
f(x)

AB
f(xi) B f '(x i )  tan(i  
AC

f (x i )
f '(x i ) 
x i  x i 1
C  A X f ( xi )
xi+1 xi xi 1  xi 
f ( xi )

Derivation of the Newton-Raphson method.

Numerical Methods 4
Numerical Methods 5
Step (1): Evaluate f (x) analytically.
Step (2): Use an initial guess of the root, xi , to
estimate the new value of the root, xi 1 , as:
f  xi 
xi 1 = xi -
f xi 
Step (3): Find the absolute relative approximate
error a as

xi 1- xi
a =  100
xi 1

Numerical Methods 6
No
Given the solution step a step
tolerance (|ϵstep|) and the
function tolerance (|ϵf|), Yes
step (4) decides about the No
continuation of the Go to Step 2 using new
f (x i 1 )  f (x i ) 
| f|
calculations or not. estimate of the root

No No. of iterations Yes


exceeded a maximum

Solution reached
Terminate
No solution
Terminate

Numerical Methods 7
You are asked to find the depth to which the
floating ball is submerged when floating in water.
The floating ball has a specific gravity of 0.6 and
has a radius of 5.5 cm.

Floating ball problem.


Numerical Methods 8
R
The equation that gives the depth
x in meters to which the ball is
submerged under water is given
by
f  x   x -0.165 x +3.993 10
3 2 -4

Use the Newton’s method of finding roots of equations to find

a) the depth ‘x’ to which the ball is submerged under water. Conduct
three iterations to estimate the root of the above equation.
b) The absolute relative approximate error at the end of each iteration,
and
c) The number of significant digits at least correct at the end of each
iteration.  %  0.01%
step

f  105
Numerical Methods 9
Solution
To aid in the understanding
of how this method works to
find the root of an equation,
the graph of f(x) is shown to
the right,
where
f  x   x 3-0.165 x 2+3.993 10- 4
Graph of the function f(x)

Numerical Methods 10
Solve for f '  x 

f  x   x 3-0.165 x 2+3.993 10- 4


f '  x   3x 2 -0.33x
Let us assume the initial guess of the root of f  x   0
is x 0  0.05m . This is a reasonable guess (discuss why
x  0 and x  0.11 m are not good choices) as the
extreme values of the depth x would be 0 and the
diameter (0.11 m) of the ball.

Numerical Methods 11
Iteration 1
The estimate of the root is
f x 0 
x1  x 0 
f ' x 0 

 0 . 05 
0 . 05 3  0 . 165 0 . 05 2  3 .993  10  4
3 0 . 05   0 . 33 0 . 05 
2

1 . 118  10  4
 0.05 
 9  10  3
 0.05   0 . 01242 
 0 . 06242

Numerical Methods 12
The absolute relative approximate error  a at the end of Iteration 1
is
x1  x0
a %   100
x1
0 .0 6 2 4 2  0 .0 5
  100
0 .0 6 2 4 2
 1 9 .9 0 %  0 .0 1 %
The number of significant digits at least correct is 0, as you need an
absolute relative approximate error of 5% or less for at least one
significant digits to be correct in your result.

Also the functional error is greater than the required absolute error:
f (x 1 )  f (x 0 )  1.4839  104  105

Numerical Methods 13
Iteration 2
The estimate of the root is

f  x1 
x 2  x1 
f ' x1 

 0 . 06242 
0 . 06242 3  0 . 165 0 . 06242 2  3 .993  10  4
3 0 . 06242   0 . 33 0 . 06242 
2

 3 . 97781  10  7
 0 . 06242 
 8 . 90973  10  3
 0 . 06242  4 . 4646  10  5 
 0 . 06238

Numerical Methods 14
The absolute relative approximate error  a at the end of Iteration 2
is
x2  x1
a   100
x2
0 .0 6 2 3 8  0 .0 6 2 4 2
  100
0 .0 6 2 3 8
 0 .0 6 4 1 2 %  0 .0 1 %

f (x 2 )  f (x1 )  3.978  107  105

2m
The maximum value of m for which  a  0 . 5  10 is 2.844.
Hence, the number of significant digits at least correct in the
answer is 2.

Numerical Methods 15
Iteration 3
The estimate of the root is

f x 2 
x3  x2 
f ' x 2 

 0 . 06238 
0 . 06238 3  0 . 165 0 . 06238 2  3 .993  10  4
3 0 . 06238   0 . 33 0 . 06238 
2

4 . 44  10  11
 0 . 06238 
 8 . 91171  10  3
 0 . 06238   4 . 9822  10  9 
 0 . 06238

Numerical Methods 16
The absolute relative approximate error  a at the end of Iteration 3
is
x2  x1
a %   100
x2
0 .0 6 2 3 8  0 .0 6 2 3 8
  100
0 .0 6 2 3 8
 0 %  0 .0 1 %

The number of significant digits at least correct is 4, as only 4


significant digits are carried through all the calculations.
i xi f(xi) f’(xi) xi+1 |Ɛa|% m
1 0.05 0.000112 -0.009 0.062422 19.90 -
2 0.062422 -4E-07 -0.00891 0.062378 0.071573 2
3 0.062378 4.43E-11 -0.00891 0.062378 7.97E-06 6

Numerical Methods 17
 For f(x) = x3 − 4, apply the Newton’s method
with starting point x0 = 2. Tabulate your
calculations and find the a % . Terminate
your calculation for at least 3 significant
digits in the calculated root.

Numerical Methods 18
 Converges fast (quadratic convergence), if it
converges.

 Requires only one guess

Numerical Methods 19
1. Divergence at inflection points
2. Division by zero
3. Oscillations near local max and min
4. Root Jumping

Numerical Methods 20
Plot of f(x) = sin(2x) from −π/4 to 5π/4; note f ’s second
derivative is f″(x) = –4sin(2x). Tangent is blue where curve is
concave up (above its own tangent), green where concave down
(below its tangent), and red at inflection points: 0, π/2 and π

Numerical Methods 21
Selection of the initial guess or an iteration value
of the root that is close to the inflection point of
the function may start diverging away from the
root in the Newton-Raphson method. For
example, to find the root of the equation:
f x    x  1  0.512  0
3

The Newton-Raphson method reduces to # xi

xi 1 x 
x 3
i  1  0.512
3
0 5.0000

3xi  1
i 2 1 3.6560
2 2.7465
The root starts to diverge at Iteration 6 3 2.1084
because the previous estimate of 0.92589 is 4 1.6000
close to the inflection point of x  1. 5 0.92589
6 −30.119
Eventually after 12 more iterations the root 7 −19.746
converges to the exact value of x  0.2.  
18 0.2000

Numerical Methods 22
For the equation
f  x   x 3  0.03 x 2  2.4  10 6  0
the Newton-Raphson method
reduces to
xi3  0.03 xi2  2.4  10 6
xi 1  xi 
3xi2  0.06 xi

For x 0  0 or x 0  0.1414 , the


denominator will equal zero. Pitfall of division by zero or
near a zero number

Numerical Methods 23
Results obtained from the Newton-Raphson
method may oscillate about the local
maximum or minimum without converging
on a root but converging on the local
maximum or minimum.
Eventually, it may lead to division by a
number close to zero and may diverge.
For example for f  x   x  2  0 the
2

equation has no real roots.

Numerical Methods 24
Table 2 Oscillations near local maxima
and mimima in Newton-Raphson method.

f xi  a %
Iteration 6 f(x)
Number xi 5

0 –1.0000 3.00
4
1 0.5 2.25 300.00
2 –1.75 5.063 128.571 33
3

3 –0.30357 2.092 476.47 2

4 3.1423 11.874 109.66 1


1 2
2
5 1.2529 3.570 150.80 4
1

x
6 –0.17166 2.029 829.88 0
-2 -1 0 1 2 3
7 5.7395 34.942 102.99 - -0.3040
-1
0.5 4 3.142

8 2.6955 9.266 112.93


9 0.97678 2.954 175.96 Oscillations around local minima for
f x   x 2  2

Numerical Methods 25
 
In some cases where the function f x is oscillating and has a number
of roots, one may choose an initial guess close to a root. However, the
guesses may jump and converge to some other root.

For example
f  x   sin x  0
Choose
x0  2.4  7.539822
x0 =
It will converge to x  0

instead of x  2  6.2831853
Root jumping from intended
location of root for f  x   sin x  0

Numerical Methods 26
 The main problem in applying the NR is the
need for evaluating the derivative.
 The derivative can be approximated using the
backward divided difference formula as:
f(x)

fi f (x i )  f (x i 1 )
f ' x i    f(xi)
x i x i  x i 1
fi
xr
f(xi-1)

xi-1 xi x

x i
Numerical Methods 28
f(x) Newton’s Method
f(xi )
xi 1 = xi - (1)
f (xi )
f(xi)
x f x 
i, i

Approximate the derivative


f ( xi )  f ( xi 1 )
f ( xi )  (2)
f(xi-1)
xi  xi 1

X
Substituting Equation (2)
xi+2 xi+1 xi
into Equation (1) gives the
Secant method
Geometrical illustration of the
f ( xi )( xi  xi 1 )
Newton-Raphson method. xi 1  xi 
f ( xi )  f ( xi 1 )
Numerical Methods 29
The secant method can also be derived from geometry:
f(x)
The Geometric Similar Triangles
AB DC

f(xi) B AE DE
can be written as
f ( xi ) f ( xi 1 )

C
xi  xi 1 xi 1  xi 1
f(xi-1)

E D A
On rearranging, the secant
X
xi+1 xi-1 xi method is given as

f ( xi )( xi  xi 1 )
Geometrical representation of the xi 1  xi 
Secant method. f ( xi )  f ( xi 1 )

Numerical Methods 30
Numerical Methods 31
Calculate the next estimate of the root from two initial guesses

f ( xi )( xi  xi 1 )
xi 1  xi 
f ( xi )  f ( xi 1 )
Find the absolute relative approximate error

xi 1- xi
a =  100
xi 1

Numerical Methods 32
Find if the absolute relative
approximate error is greater than
the pre-specified relative error
tolerance.

If so, xi-1 xi xi+1


set: xi-1 = xi (previous old estimate)
xi = xi+1 (previous new estimate)

and go back to step 1, else stop the


algorithm.

Also check if the number of


iterations has exceeded the
maximum number of iterations.

Numerical Methods 33
You are asked to find the depth to which the ball is
submerged when floating in water. The floating
ball has a specific gravity of 0.6 and has a radius of
5.5 cm.

Numerical Methods 34
The equation that gives the depth x to which the
ball is submerged under water is given by
f x   x 3-0.165 x 2+3.993 10- 4
Use the Secant method of finding roots of equations to
find the depth x to which the ball is submerged under
water.
• Conduct three iterations to estimate the root of
the above equation.
• Find the absolute relative approximate error and the
number of significant digits at least correct at the
end of each iteration.

Numerical Methods 35
Solution
To aid in the understanding
of how this method works to
find the root of an equation,
the graph of f(x) is shown to
the right,
where
f  x   x 3-0.165 x 2+3.993  10- 4

Graph of the function f(x).


Numerical Methods 36
Let us assume the initial guesses of the root of f  x  0
as x0  0.02 and x 1  0.05.

Iteration 1 x0 x1 x2
The estimate of the root is

f x1 x1  x 0 
x 2  x1 
f x1   f x 0 
 
0.053  0.165 0.05  3.993  104  0.05  0.02
2

 
 0.05 
   
0.053  0.165 0.05  3.993  104   0.023  0.165 0.02  3.993  104 
2 2

   
 0.064614

Numerical Methods 37
The absolute relative approximate error a at the end of
Iteration 1 is

x2  x1
a   100
x2
0.06461  0.05
  100
0.06461
 22.62%

The number of significant digits at least correct is 0, as you


need an absolute relative approximate error of 5% or less
for one significant digits to be correct in your result.

Numerical Methods 38
Iteration 2
x3
set xi-1 = xi (previous old estimate)
xi = xi+1 (previous new estimate) x0 x1 x2
set xi-1 = x1 =0.05 (previous old estimate)
xi = x2 =0.064614 (previous new estimate)

The estimate of the root is


f x2 x2  x1 
x3  x2 
f x2   f x1 
 
0.064613  0.165 0.06461  3.993 104 0.06461  0.05
2

 
 0.06461 
   
0.064613  0.165 0.06461  3.993 104   0.053  0.165 0.05  3.993 104 
2 2

   
 0.062414

Numerical Methods 39
The absolute relative approximate error a at the end of
Iteration 2 is
x 3  x2
a  100
x3
0.062414  0.064614
 100
0.062414
 3.525%

The number of significant digits at least correct is 1, as you


need an absolute relative approximate error of 5% or less.

Numerical Methods 40
Iteration 3
set xi-1 = x2 = 0.06471 (previous old estimate)
x i = x3 = 0.06241 (previous new estimate)

The estimate of the root is

f x3 x3  x2 
x 4  x3 
f x3   f x2 
 
0.0624143  0.165 0.062414  3.993 104 0.062414  0.064614
2

 
 0.062414 
   
0.0624143  0.165 0.062414  3.993 104   0.053  0.165 0.064614  3.993 104 
2 2

   
 0.062378

Numerical Methods 41
The absolute relative approximate error a at the end of
Iteration 3 is a  x 4  x 3  100
x4
0.062378  0.062414
  100
0.062378
 0.0595%

The number of significant digits at least correct is 2, as you


need an absolute relative approximate error of 0.5% or
less.
i xi-1 xi f(xi-1) f(xi) xi+1 |Ɛa|% m
1 0.02 0.05 0.000341 0.000112 0.064614

2 0.05 0.064614 0.000112 -2E-05 0.062414 3.524714 1

3 0.064614 0.062414 -2E-05 -3.3E-07 0.062377 0.059468 2

4 0.062414 0.062377 -3.3E-07 2.03E-09 0.062378 0.000364 5

Numerical Methods 42
 Converges fast, if it converges
 Requires two guesses that do not need to
bracket the root

Numerical Methods 43
2
2

f ( x)
0
f ( x) 0
f ( x)

2 2
10 5 0 5 10
 10 x x guess1  x guess2 10
f(x)
prev. guess
new guess f  x   Sin x   0

Division by zero
Numerical Methods 44
2
2

f ( x)

f ( x)
0
f ( x) 0
secant( x)

f ( x)

2 2
10 5 0 5 10
 10 x x 0  x 1'  x x 1 10
f(x)
f  x   Sinx  0
x'1, (first guess)
x0, (previous guess)
Secant line
x1, (new guess)

Root Jumping
Numerical Methods 45
f(x) = x3 − 4
X0=2 , X1=3

i xi-1 xi f(xi-1) f(xi) xi+1 |Ɛaa|%
 Solve f(x) for an error tolerance of 1% 1 2 3 4 23 1.789474
,using the secant method with two 2 3 1.789474 23 1.730281 1.690998 5.823528
sets of initial guesses : 3 1.789474 1.690998 1.730281 0.835365 1.599075 5.748492
4 1.690998 1.599075 0.835365 0.088902 1.588127 0.689351
(a) x0=2 , x1=3 5 1.599075 1.588127 0.088902 0.005494 1.587406 0.045426
(b) x0=0 , x1=1 6 1.588127 1.587406 0.005494 4.02E-05 1.587401 0.000335
7 1.587406 1.587401 4.02E-05 1.84E-08 1.587401 1.53E-07
Comment of the achieved solution? 8 1.587401 1.587401 1.84E-08 6.13E-14 1.587401 5.18E-13
9 1.587401 1.587401 6.13E-14 -8.9E-16 1.587401 1.4E-14
10 1.587401 1.587401 -8.9E-16 8.88E-16 1.587401 1.4E-14

X0=0 , X1=1 ∈a

i xi-1 xi f(xi-1) f(xi) xi+1 |Ɛa|%


1 0 1 -4 -3 4
2 1 4 -3 60 1.142857 250
3 4 1.142857 60 -2.50729 1.257463 9.114031
4 1.142857 1.257463 -2.50729 -2.01168 1.722653 27.00429
5 1.257463 1.722653 -2.01168 1.112028 1.557047 10.63588
6 1.722653 1.557047 1.112028 -0.2251 1.584926 1.759022
7 1.557047 1.584926 -0.2251 -0.01868 1.587449 0.158917
8 1.584926 1.587449 -0.01868 0.000363 1.587401 0.003027
9 1.587449 1.587401 0.000363 -5.7E-07 1.587401 4.72E-06
10 1.587401 1.587401 -5.7E-07 -1.7E-11 1.587401 1.43E-10

Numerical Methods 46

You might also like