Numerical Analysis Lecture 6 Roots of Equations Newton

Numerical Analysis
Lecture 6
Roots of Equations
Newton-Raphson Method
١
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
Newton-Raphson Method
’Widely used
’Requires one single starting value of x
’Possibility of diverging (depend on the staring x and how close is it to the root)
If the initial guess at the root is xi, a
tangent can be extended from the
point [xi, f(xi)].
The point where this tangent crosses
the x axis usually represents an
improved estimate of the root.
f (x i )
x i +1 = x i −
f ′(x i )
٢
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
Newton-Raphson Method
“Example 1
’Using the Newton-Raphson method to estimate the root of f(x)= e-x-x
employing an initial guess of x0 = 0. and εs = 0.01%
f (x ) = −e
'
Lecture 6
−x
−1
f (x i )
x i +1 = x i − /
f (x i )
xi+1
εA
1.00000 -2.00000
0.500000
-
0.500000
0.10653 -1.60653
0.566311
11.70929%
2
0.566311
0.00130 -1.56762
0.567143
0.14673%
3
0.567143
0.00000 -1.56714
0.567143
0.00002%
i
xi
0
0.000000
1
f(xi)
f'(xi)
Numerical Analysis
٣
Eng. Malek Abuwarda
Newton-Raphson Method
“ Failure of Newton-Raphson method
’Inflection point in vicinity of root
’Oscillate around local maximum or minimum
’Jump away for several roots
’Disaster from zero slope
٤
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
The Secant Method
“ The Secant Method
’A slight variation of Newton’s method for functions whose
derivatives are difficult to evaluate. For these cases the
derivative can be approximated by a backward finite divided
difference
f ′(x i ) ≅
x i − x i −1
f (x i ) − f (x i −1 )
x i +1 = x i − f (x i )
x i − x i −1
f (x i ) − f (x i −1 )
٥
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
The Secant Method
Requires two initial estimates of x , e.g, xo, x1. However, because f(x) is not
required to change signs between estimates, it is not classified as a
“bracketing” method.
The scant method has the same
properties as Newton’s method.
Convergence is not guaranteed
for all xo, f(x).
٦
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
The Secant Method
“Example 2
’Using the Newton-Raphson method to estimate the root of f(x)= e-x-x
employing an initial guesses of x0 = 0., x1 = 1 and εs = 0.01%
x i − x i −1
x i +1 = x i − f (x i )
f (x i ) − f (x i −1 )
iter
xi-1
f(xi-1)
xi
f(xi)
xi+1
εA
0
0.000000 1.00000 1.00000 -0.63212
0.612700
-
1
1.000000 -0.63212 0.61270 -0.07081
0.563838
8.66586%
2
0.612700 -0.07081 0.56384 0.00518
0.567170
0.58747%
3
0.563838 0.00518 0.56717 -0.00004
0.567143
0.00477%
٧
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
Multiple Roots
“ Multiple root
’corresponds to a point where a function is tangent to the x axis
f(x)= ( x-3)( x-1)( x-1)
f(x)= ( x-3)( x-1)( x-1)( x-1)
= x 3 - 5x 2 +7x -3
= x 4 - 6x 3 + 125x 2 - 10x+3
٨
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
Multiple Roots
“ Difficulties of multiple roots
’None of the methods deal with multiple roots efficiently
’Function does not change sign at the multiple root, therefore, cannot use
bracketing methods
’Both f(x) and f′(x)=0, division by zero with Newton’s and Secant
methods
“ Modified Newton Raphson Method
x i +1 = x i −
f ( x i )f ' ( x i )
2
⎡⎣f (x i ) ⎤⎦ − f (x i )f '' (x i )
'
٩
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
Modified Newton Raphson Method
“Example 3
’Use Modified Newton-Raphson method to evaluate the multiple roots of
f(x)= x3-5x2+7x-3 with an initial guess of x0=0.
The true root value is 1.0 and εs = 0.01%
First let us find f ’(x) and f ”(x)
x i +1 = x i −
f (x ) = 3x − 10x + 7
'
2
f ( x i )f ' ( x i )
2
⎡⎣f (x i ) ⎤⎦ − f (x i )f '' (x i )
'
f '' (x ) = 6x − 10
i
xi
f(xi)
f'(xi)
f''(xi)
xi+1
εt
1
0.000000
-3.00000
7.00000
-10.00000
1.105263
10.5263%
2
1.105263
-0.02099 -0.38781
-3.36842
1.003082
0.3082%
3
1.003082
-0.00002 -0.01230
-3.98151
1.000002
0.0002%
١٠
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
Modified Newton Raphson Method
The modified formula was convergent and we found the double root which
was 1. Now let us try to evaluate the third root. Take the third root as 3.
now we have to start with the initial guess of x0=4 near the third root.
i
xi
f(xi)
f'(xi)
f''(xi)
xi+1
εt
1
4.000000
9.00000
15.00000
14.00000
2.636364
12.1212%
2
2.636364
-0.97370
1.48760
5.81818
2.820225
5.9925%
3
2.820225
-0.59563
2.65876
6.92135
2.961728
1.2757%
4
2.961728
-0.14728
3.69822
7.77037
2.998479
0.0507%
5
2.998479
-0.00608
3.98784
7.99087
2.999998
0.0001%
١١
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
Systems of Nonlinear Equations
“ Roots of a set of simultaneous equations:
f1(x1,x2,…….,xn)=0
f2 (x1,x2,…….,xn)=0
fn (x1,x2,…….,xn)=0
The solution is a set of x values that simultaneously get the equations
to zero
x2+xy=10
&
y+3xy2=57
u(x,y)= x2+xy-10 =0
v(x,y)=y+3xy2-57=0
The solution will be the value of x and y which makes u(x,y)=0 and
v(x,y)=0 - These are x=2 and y=3
١٢
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
Systems of Nonlinear Equations
Fixed-Point Iteration
“ Example 4
’Use Fixed-Point Iteration to estimate the root of x2+xy=10 & y+3xy2=57.
The correct pair of roots are x = 2 and y = 3 and εs = 1%
Initial guesses x = 1.5 and y = 3.5
We have two simultaneous nonlinear equations with two unknowns, x and y
u (x , y ) = x 2 + xy − 10 = 0
v (x , y ) = y + 3xy 2 − 57 = 0
Using fixed-point iteration
10 − x 2
x =
y
for u(x,y)
y = 57 − 3xy 2 For v(x,y)
١٣
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
Systems of Nonlinear Equations
xi
yi
u(xi,yi)
v(xi+1,yi)
εtx
εty
1.500000
3.50000
2.21429
-24.37500
10.71%
912.50%
-24.37500 -0.20911 429.71365
110.46%
14223.79%
2.214286
First iteration,
10 − 1.52
= 2.21429
u (x i , y i ) = x i +1 =
3.5
v (x i +1 , y i ) = y i +1 = 57 − 3 ( 2.21429 )( 3.5) = −24.375
2
Second iteration:
10 − ( 2.21429 )
=
= −0.20911
−24.375
2
u (x i +1 , y i +1 ) = x i + 2
v (x i + 2 , y i +1 ) = y i + 2 = 57 − 3 ( -0.20911)( −24.375 ) = 429.714
2
Solution is diverging so try another iteration formula
Lecture 6
Numerical Analysis
١٤
Eng. Malek Abuwarda
Systems of Nonlinear Equations
Try different format of x and y
x = 10 − xy for u(x,y)
57 − y
y =
3x
for u(x,y)
xi
yi
u(xi,yi)
v(xi+1,yi)
εtx
εty
1.500000
3.50000
2.17945
2.86051
8.97%
4.65%
2.179449
2.86051
1.94053
3.04955
2.97%
1.65%
1.940534
3.04955
2.02046
2.98340
1.02%
0.55%
2.020456
2.98340
1.99303
3.00570
0.35%
0.19%
The sufficient conditions for convergence for the two-equation case are
∂u
∂v
∂u
∂v
+
<1
+
< 1 and
∂y
∂y
∂x
∂x
Lecture 6
Numerical Analysis
١٥
Eng. Malek Abuwarda
Systems of Nonlinear Equations
Newton-Raphson Method
The standard Newton Raphson formula:
f ( xi )
xi +1 = xi −
f '( xi )
In order to deal with two variable in an equation the formula below
derived from the standard Newton Raphson
∂v i
∂u i
ui ⋅
−v i
∂y
∂y
x i +1 = x i −
∂u i ∂v i ∂u i ∂v i
⋅
−
∂x ∂y
∂y ∂x
∂u i
∂v i
vi
−ui
∂x
∂x
y i +1 = y i −
∂u i ∂v i ∂u i ∂v i
⋅
−
∂x ∂y
∂y ∂x
Lecture 6
Numerical Analysis
١٦
Eng. Malek Abuwarda
Systems of Nonlinear Equations
Example 5
’Use Newton-Raphson to estimate the root of x2+xy=10 & y+3xy2=57.
The correct pair of roots are x = 2 and y = 3 and εs = 1%
Initial guesses x = 1.5 and y = 3.5
We have two simultaneous nonlinear equations with two unknowns, x and y
u (x , y ) = x 2 + xy − 10 = 0
∂u
= 2x + y
∂x
∂u
=x
∂y
∂v i
∂u
−v i i
∂y
∂y
x i +1 = x i −
∂u i ∂v i ∂u i ∂v i
⋅
−
∂x ∂y
∂y ∂x
ui ⋅
Lecture 6
v (x , y ) = y + 3xy 2 − 57 = 0
∂v
= 3y 2
∂x
∂v
= 1 + 6xy
∂y
∂u i
∂v i
−ui
∂x
∂x
y i +1 = y i −
∂u i ∂v i ∂u i ∂v i
⋅
−
∂x ∂y
∂y ∂x
vi
Numerical Analysis
١٧
Eng. Malek Abuwarda
Systems of Nonlinear Equations
xi
yi
u(xi,yi) du/dx
du/dy v(xi,yi) dv/dx
dv/dy
xi+1
yi+1
εtx
εty
1.50 3.50 -2.500
6.500
1.500
1.625 36.750 32.500 2.036
2.844
1.8%
5.2%
2.04 2.84 -0.064
6.916
2.036
-4.756 24.263 35.741 1.999
3.002
0.1%
0.1%
2.00 3.00 -0.005
7.000
1.999
0.050 27.041 37.004 2.000
3.000
0.0%
0.0%
The results are converging to the true value of x = 2 and y = 3
١٨
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
Roots of Polynomials
The roots of polynomials such as
fn (x) = ao + a1x + a2 x2 +…+ an xn
Follow these rules:
For an nth order equation, there are n real or complex roots.
If n is odd, there is at least one real root
The efficacy of bracketing and open methods depends on whether the problem
being solved involves complex roots. If only real roots exist, these methods
could be used. However,
Finding good initial guesses complicates both the open and bracketing
methods, also the open methods could be receptive to divergence
Special methods have been developed to find the real and complex roots of
polynomials
Müller method
Bairstow methods
١٩
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda
Müller’s method
“ Müller’s method obtains a root estimate by projecting a parabola to the x
axis through three function values
“ The method consists of deriving the coefficients of parabola that goes
through the three points:
’Write the equation in a convenient form:
f 2 ( x ) = a ( x − x2 ) 2 + b ( x − x2 ) + c
Secant method
Lecture 6
Numerical Analysis
Müller’s method
٢٠
Eng. Malek Abuwarda
Müller’s method
. You need THREE point to start with
. Find out x3 (estimated root) by the following equations
x3 = x2 +
a=
− 2c
b ± b 2 − 4ac
δ1 − δ o
h1 + ho
b = ah1 + δ1
c = f ( x2 )
f (x 1 ) − f (x o )
δo =
ho
f (x 2 ) − f (x 1 )
δ1 =
h1
h o = x1 − x o
h1 = x 2 − x1
The ± sign in the main equation above is chosen to agree with the sign of b.
That’s mean if b is positive the sign would be (+) and if b is negative the sign would be (-)
Lecture 6
Numerical Analysis
٢١
Eng. Malek Abuwarda
Müller’s method
Example 6
’Use Muller’s method to find the root of f(x)= x3 - 13x – 12
Initial guesses of x0, x1, and x2 of 4.5, 5.5 and 5.0 respectively
and εs = 0.01%
δ0
δ1
x3(xr)
εA
1.00
-0.50 62.25 69.75 15.00 62.25 48.00 3.9765
-
82.88 48.00 -0.82
-0.50
-1.02 69.75 47.69 14.48 32.88 -0.82 4.0011 0.614%
4.00
48.00 -0.82
0.04
-1.02
0.02
47.69 34.73 12.98 35.05
0.04 4.0000 0.026%
4.00
-0.82
0.00
0.02
0.00
34.73 35.01 11.98 35.00
0.00 4.0000 0.000%
f(x0)
f(x1)
f(x2)
x0
x1
x2
4.50
5.50
5.00
20.63 82.88 48.00
5.50
5.00
3.98
5.00
3.98
3.98
4.00
0.04
h0
h1
a
b
c
٢٢
Lecture 6
Numerical Analysis
Eng. Malek Abuwarda