Professional Documents
Culture Documents
2.2 Nonlinear Equs - Newton - Secant
2.2 Nonlinear Equs - Newton - Secant
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
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 )
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
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.
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 105
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
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 104 105
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 %
2m
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 %
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.
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
xi 1 x
x 3
i 1 0.512
3
0 5.0000
3xi 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
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
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
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
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
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.
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
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 104 0.05 0.02
2
0.05
0.053 0.165 0.05 3.993 104 0.023 0.165 0.02 3.993 104
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%
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)
0.06461
0.064613 0.165 0.06461 3.993 104 0.053 0.165 0.05 3.993 104
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%
Numerical Methods 40
Iteration 3
set xi-1 = x2 = 0.06471 (previous old estimate)
x i = x3 = 0.06241 (previous new estimate)
f x3 x3 x2
x 4 x3
f x3 f x2
0.0624143 0.165 0.062414 3.993 104 0.062414 0.064614
2
0.062414
0.0624143 0.165 0.062414 3.993 104 0.053 0.165 0.064614 3.993 104
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%
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
Numerical Methods 46