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

Roots 

of Equations/
Roots of Equations/
Open Methods
Open Methods
By
Dr Ali Ja arneh
Dr Ali Jawarneh

Dr Ali Jawarneh 1
(B) Open Methods

o Simple
p Fixed-Point iteration
o Newton-Raphson method
o Secant method
o Multiple Roots
o System of Nonlinear Equations

Require only a single value of x or two starting 
value that do not necessarily bracket the root

Dr Ali Jawarneh 2
Simple Fixed-Point Iteration
“ one-point
i t iteration”
it ti ”
“ successive substitution”
The method starts with the equation
f (x)
( )=0
The equation is rearranged so that one “x” is one the left hand side of the
equation
x = g(x) xi+1 = g(xi)
For example
f (x) = x2 − 2x + 3 = 0
can be rearrange
g as:
x= (x2+3)/2 xi+1= (xi2+3)/2 i=1, 2, 3, 4, …
In some cases, separating an “x” out of the equation f (x) = 0 is not possible.
In such cases, an “x” can be added to both sides of the equation.
For example
f (x) = sin(x) = 0
can be written as
x = sin(x) + x xi+1 = sin(xi) + xi i=1, 2, 3, 4, …
x i +1 − x i
Calculate the error and repeat until tolerance is met: ε a = 100%
Dr Ali Jawarneh
x i +1 3
Example: Using the fixed-point iteration, determine the non-
trivial root of the function sinx
sinx-x
x2=00 using xx=11 as an
initial guess, and 0.1% tolerance. Use 4 sig. fig.
Solution: x = sin x x i +1 = sin x i

i=1 x 2 = sin x1 = sin 1 = 0.9173 where x1 = 1


x i +1 − x i 0.9173 − 1
εa = 100% = 100% = 9.016%
x i +1 0.9173
i xi |εa | % 
_
1 1
i 2
i=2
2 0.9173 9.016
x 3 = sin x 2 = sin 0.9173 = 0.8911 3 0.8911 2.940
4 0.8819 1.043
where x 2 = 0.9173
5 0.8786 0.3756
x i +1 − x i 0.8911 − 0.9173 6 0.8774 0.1368
εa = 100% = 100% = 2.940%
x i +1 0.8911
7 0.8770 0.04561
Dr Ali Jawarneh 4
Example: Using simple fixed-point iteration, determine the
root of the function f(x)
f(x)=ee-x-x
x using initial guess of xx=00
and εa<40%. Use 6 sig. fig. True value of the root =0.567133
Solution:

i xi |εa | %  |εt | % 

_
1 0 100
2 1 100 76.3
3 0 367879
0.367879 171 8
171.8 35 1
35.1
4 0.692201 46.9 22.1
5 0.500473 38.3 11.8

Dr Ali Jawarneh 5
Newton‐Raphson Method
slope=f’(xi)
It is taken from Talyor series
[ Forward, 1st order approx.]
f(xi)

f(xi+1)=0 xr
xi xi+1

f (x i )
x i +1 = xi − i=1, 2, 3, 4, …

f ' (x i )
The major weakness of this method if it’s difficult to find the 
j
derivative or the derivative is zero or approach to zero
Dr Ali Jawarneh 6
Example: Use the Newton-Raphson method to determine the root
of the function f(x)
f(x)=e e-x-x
x using xx=00 as an initial guess, and
percent relative error less than 0.1%. Use 4 sig. fig.

Solution:
f ' ( x) = −e − x − 1 x i +1 = xi −
f (x i )
f ' (x i )
(e − x i − x i )
x i +1 = xi −
− e − xi − 1
− x1
i xi |εa | % 
(e − x 1 )
i=1 x 2 = x1 − − x1
= 0.5 _
−e −1 1 0
2 0.5 100
where x1 = 0
3 0.5663 11.7
4 0 5671
0.5671 0 14
0.14
(e − x 2 − x 2 )
i=2 x3 = x2 − − x2
= 0.5663 5 0.5671 Approx. 
−e −1 0.0

where x 2 = 0.5
Dr Ali Jawarneh 7
Secant Method
f( i)
f(x
Taken fromTalyor series [ Backward, 1st
order approx.] and Newton-Raphson
formula (Forward Talyor)

f ( x i )[x i −1 − x i ]
x i +1 = xi − f(xi-1)

f ( x i −1 ) − f ( x i ) xr
xi+1 xi-1 xi
i=1, 2, 3, 4, …
3 Notes:
3 Notes:
(1)Two initial guesses are required
( )
(2)The same formula as False‐Position Method
f ( x u )( x L − x u )
xr = xu −
f (x L ) − f (x u )
(3) Omitting the derivative 
Dr Ali Jawarneh 8
Example: Locate the first positive root of
f(x)=sinx+cos(1+x
f(x) sinx cos(1 x2))-1
1
Use 4 iterations of the secant method with initial guesses of [1 3]
Solution: x i +1 = x i − f ( x i )[x i −1 − x i ] i xi‐1 xi ||εa a | % 
i 1 ) − f (x i )
f ( x i−

_
[sin x i + cos(1 + x i2 ) − 1][x i −1 − x i ] 1 1 3
x i +1 = xi −
[sin x i −1 + cos(1 + x i2−1 ) − 1] − [sin x i + cos(1 + x i2 ) − 1] 2 3 ‐0.02321 13023
3 ‐0.02321 ‐1.22635 98

4 ‐1.22635 0.233951 624

5 0.233951 0.396366 40.9

i=1:
[sin x1 + cos(1 + x12 ) − 1][x 0 − x1 ]
x 2 = x1 − = −0.02321 Here, x0=1, x1=3
[sin x 0 + cos(1 + x 02 ) − 1] − [sin x1 + cos(1 + x12 ) − 1]

[ x 2 + cos((1 + x 22 ) − 1][x1 − x 2 ]
i=2: x 3 = x 2 − [sin
= −1.22635
[sin x1 + cos(1 + x12 ) − 1] − [sin x 2 + cos(1 + x 22 ) − 1]
Here, x1=3, x2=-0.02321
Dr Ali Jawarneh 9
Multiple Roots
9Multiple root: the function is tangent to the x-axis
‰Double root: the function is tangent to the x-axis
and does not cross it it.
f(x)=(x-3)(x-1)(x-1)
‰Triple root: the function is tangent to the x-axis
and the axis is crossed.
f(x)=(x-3)(x-1)(x-1)(x-1)

i=1, 2, 3, 4, …

f ( x i )f ' ( x i )
x i +1 = xi −
[f ' ( x i )] − f ( x i )f " ( x i )
2

Modified Newton-Raphson
Method for Multiple Roots
Dr Ali Jawarneh 10
Example: The function f(x)=x3-2x2-4x+8 has a double root at
x=2,
x 2, use the modified Newton-Raphson
Newton Raphson to solve for the root at
x=2. Using an initial guess of x=1.2. Do 3 iterations.

Solution: x i +1 = x i −
f ( x i )f ' ( x i ) i xi εa %
[f ' ( x i )]2 − f ( x i )f " ( x i )
1 1.2 ‐
( x − 2x − 4x i + 8)( 3x − 4x i − 4)
3 2 2
x i +1 = x i − i i i
2 1.878788 36
[( 3x i2 − 4x i − 4)] − [( x i3 − 2x i2 − 4x i + 8)(6x i − 4)]
2

3 1.998048 5.969
i=1:
4 2 0.089

( x13 − 2x12 − 4x1 + 8)( 3x12 − 4x1 − 4)


x 2 = x1 − = 1.878788
[( 3x12 − 4x1 − 4)]2 − [( x13 − 2x12 − 4x1 + 8)(6x1 − 4)]
Here, x1=1.2

i=2:
( x 32 − 2x 22 − 4x 2 + 8)( 3x 22 − 4x 2 − 4)
x3 = x2 − = 1.998048
[( 3x 22 − 4x 2 − 4)]2 − [( x 23 − 2x 22 − 4x 2 + 8)(6x 2 − 4)]
Here, x2=1.878788

Dr Ali Jawarneh 11
Example: Use modified Newton-Raphson to solve :
f(x) (x 3)(x 1)(x 1)
f(x)=(x-3)(x-1)(x-1)
For the root at x=1, use an initial guess x=0. True percent relative
error must be below 0.1% and use 7 sig. figs.
f ( x i )f ' ( x i )
Solution: x i +1 = xi −
[f ' ( x i )]2 − f ( x i )f " ( x i )

( x i3 − 5x i2 + 7 x i − 3)( 3x i2 − 10x i + 7 )
x i +1 = xi −
( 3x i2 − 10x i + 7 ) 2 − ( x i3 − 5x i2 + 7 x i − 3)(6x i − 10)
i xi εt %

εt= [true value-approx.)/true


value approx.)/true value]100%
1 0 100
2 1.105263 11

3 1.003082 0.31

4 1.000002 0.00024
Dr Ali Jawarneh 12
System of Nonlinear Equations
• An equation of the form ax+by=c is called a linear in x and y 
variables.
• ax+by+cz
ax+by+cz=d d is a linear equation in three variables, x, y, z.
is a linear equation in three variables, x, y, z.
• Thus, a linear equation in n variables is
a1x1+a2x2+ … +anxn = b
• A system of linear equations consists of n number of
A t f li ti it f b f
these equations and a solution of such system consists
n number of real numbers.
x+y+z=1 Equivalent to: x1+x2+x3=1
System of linear
equations: 2x+y-z=4 2x1+x2-x3=4
4x+y+4z=3 4x1+x2+4x3=3 3

System of Non-linear x2+y2=1


equations: y=x2
Dr Ali Jawarneh 13
y
( x − 4) 4 + ( y − 4) 2 = 5
y=x 2

x + y = 16
2 2

x2 + y 2 = 4
Linear Algebraic? x

Non-Linear Algebraic?
g

3x + 2y = 18 y

− x + 2y = 2

3x1 + 2x 2 = 18
− x1 + 2x 2 = 2
x
Dr Ali Jawarneh 14
Dr Ali Jawarneh 15
2 variables
⎡ ∂u i ∂u i ⎤ Newton-
N t
⎢ ∂x ∂y ⎥ ⎡ Δ x ⎤ ⎡ − u i ⎤
⎢ ⎥⎢ ⎥ = ⎢
∂v i ⎥ ⎣ Δy ⎦ ⎣ − v i ⎥⎦
Raphson
⎢ ∂v i
⎢⎣ ∂x ∂y ⎥⎦ Method
3 variables
⎡ ∂u i ∂u i ∂u i ⎤
⎢ ∂x ∂y ∂z ⎥⎥ ⎡ Δx ⎤ ⎡ − u ⎤ Δx = x i + 1 − x i

⎢ ∂v i ∂v i ∂v i ⎥ ⎢ ⎥ ⎢
i

Δy ⎥ = ⎢ − v i ⎥ Δy = y i + 1 − y i
⎢ ∂x ∂y ∂z ⎥ ⎢
⎢ ⎥ ⎢ ⎥ Δz = z i + 1 − z i
⎢ ∂w ∂w i ⎥ Δ
∂w i ⎣ ⎦ ⎣ z − w i⎦
⎢ i ⎥
⎣⎢ ∂x ∂y ∂z ⎥⎦ i=1, 2, 3, 4, …
Dr Ali Jawarneh 16
⎡ ∂u i ∂u i ⎤
⎢ ∂x For 2 variables
∂y ⎥ ⎡ Δ x ⎤ ⎡ − u i ⎤
⎢ ⎥⎢ ⎥ = ⎢ you have two
⎢ ∂v i ∂v i ⎥ ⎣ Δy ⎦ ⎣ − v i ⎥⎦
choices
⎢⎣ ∂x ∂y ⎥⎦

∂v i ∂u i
ui − vi i=1, 2, 3, 4, …
∂y ∂y
x i +1 = xi −
∂u i ∂v i ∂ u i ∂ v i

∂x ∂ y ∂ y ∂x
∂u i ∂v i
vi − ui
y i +1 = yi − ∂x ∂x
i=1, 2, 3, 4, …
∂u i ∂v i ∂ u i ∂ v i

∂x ∂ y ∂y ∂ x

Dr Ali Jawarneh 17
Example: Determine the roots of the simultaneous 
nonlinear equations: (x‐4)2+(y‐4)2=5, X2+y2=16
Use initial guesses [x  y]=[3  1]. The tolerances less than 0.1% 
in both variables
b h bl
∂v i ∂u ∂u i ∂v
Solution: ui
∂y
− vi i
∂y
vi
∂x
− ui i
∂x
x i +1 = xi − y i +1 = yi −
∂u i ∂v i ∂u i ∂v i ∂ u i ∂v i ∂ u i ∂ v i
− −
∂x ∂y ∂y ∂x ∂ x ∂y ∂ y ∂ x

u( x , y ) = ( x − 4 ) 2 + ( y − 4 ) 2 − 5 = 0
v( x, y ) = x 2 + y 2 − 16 = 0
∂u ∂u
= 2( x − 4) = 2( y − 4)
∂x ∂y
∂v ∂v
= 2x = 2y
∂x ∂y
Dr Ali Jawarneh 18
∂v 1 ∂u ∂u 1 ∂v
i=1: u1
∂y
− v1 1
∂y v1 − u1 1
x 2 = x1 − = 3.812 y 2 = y1 − ∂x ∂x = 1.562
∂ u 1 ∂v 1 ∂ u 1 ∂ v 1 ∂ u 1 ∂ v 1 ∂ u 1 ∂v 1
− −
∂x ∂ y ∂ y ∂ x ∂x ∂ y ∂y ∂ x

Here x 1 = 3, y 1 = 1

u1 = ( x1 − 4) 2 + ( y 1 − 4) 2 − 5 = ( 3 − 4) 2 + (1 − 4) 2 − 5 = 5

v 1 = x12 + y 12 − 16 = 3 2 + 12 − 16 = −6
∂u 1
= 2( x1 − 4) = 2( 3 − 4) = −2
∂x
∂u 1 x 2 − x1 3.812 − 3
= 2( y 1 − 4) = 2(1 − 4) = −6 ε ax = 100% = 100% = 21.3%
∂y x2 3.812
∂v 1
= 2x1 = 2( 3) = 6 y 2 − y1 1.562 − 1
∂x ε ay = 100% = 100% = 35.98%
y2 1.562
∂v 1
= 2y 1 = 2(1) = 2
∂y
Dr Ali Jawarneh 19
i=2:
∂v 2 ∂u ∂u 2 ∂v
u2 − v2 2 v2 − u2 2
∂y ∂y ∂x ∂x = 1.780
x3 = x2 − = 3.596 y3 = y2 −
∂u 2 ∂v 2 ∂u 2 ∂v 2 ∂u 2 ∂v 2 ∂u 2 ∂v 2
− −
∂x ∂ y ∂y ∂x ∂x ∂y ∂ y ∂x
Here
x 2 = 3.812, y 2 = 1.562
u 2 = ( x 2 − 4) 2 + ( y 2 − 4) 2 − 5 = ( 3.812 − 4) 2 + (1.562 − 4) 2 − 5 = 0.979

v 2 = x 22 + y 22 − 16 = 3.812 2 + 1.562 2 − 16 = 0.971


∂u 2 ∂u 2
= 2( x 2 − 4) = 2( 3.812 − 4) = −0.376 = 2( y 2 − 4) = 2(1.562 − 4) = −4.876
∂x ∂y
∂v 2 ∂v 2
= 2x 2 = 2( 3.812) = 7.624 = 2y 2 = 2(1.562) = 3.124
∂x ∂y
x3 − x2 3.596 − 3.812
ε ax = 100% = 100% = 6.007%
x3 3.596
y3 − y2 1.780 − 1.562
ε ay = 100% = 100% = 12.247%
y3 1.780
Dr Ali Jawarneh 20
i xi yi εax % εay %

1 3 1 ‐ ‐
2 3.812 1.562 21.3 35.98
3 3 596
3.596 1 780
1.780 6 007
6.007 12 247
12.247
4 3 570
3.570 1 805
1.805 0 7283
0.7283 1 385
1.385
5 3.570 1.806 0.0 0.05537
Dr Ali Jawarneh 21
Example: Determine the roots of the simultaneous 
nonlinear equations: (x‐4)2+(y‐4)2=5, X2+y2=16
Use initial guesses [x  y]=[3  1]. The tolerances less than 0.1% 
in both variables
b h bl
⎡ ∂u i ∂u i ⎤
Solution: ⎢ ∂x ∂y ⎥ ⎡ Δ x ⎤ ⎡ − u i ⎤ Δx = x i + 1 − x i
⎢ ⎥ =
⎢ ∂v i ∂v i ⎥ ⎢⎣ Δy ⎥⎦ ⎢⎣ − v i ⎥⎦
Δy = y i + 1 − y i
⎣⎢ ∂x ∂y ⎥⎦

u( x , y ) = ( x − 4 ) 2 + ( y − 4 ) 2 − 5 = 0
v( x, y ) = x 2 + y 2 − 16 = 0
∂u ∂u
= 2( x − 4) = 2( y − 4)
∂x ∂y
∂v ∂v
= 2x = 2y
∂x ∂y
Dr Ali Jawarneh 22
x 1 = 3, y 1 = 1
i=1:
u1 = ( x1 − 4) 2 + ( y 1 − 4) 2 − 5 = ( 3 − 4) 2 + (1 − 4) 2 − 5 = 5
v 1 = x12 + y 12 − 16 = 3 2 + 12 − 16 = −6
∂u 1
= 2( x1 − 4) = 2( 3 − 4) = −2
∂x
∂u 1
= 2( y 1 − 4) = 2(1 − 4) = −6
∂y
∂v 1
= 2x1 = 2( 3) = 6
∂x
∂v 1
= 2y 1 = 2(1) = 2
∂y

⎡ ∂u 1 ∂u 1 ⎤
⎢ ∂x ∂y ⎥ ⎡ Δ x ⎤ ⎡ − u 1 ⎤ ⎡− 2 − 6⎤ ⎡ Δx ⎤ ⎡− 5⎤
⎢ ⎥ = ⎢ 6 =
⎢ ∂v 1 ∂v 1 ⎥ ⎢⎣ Δy ⎥⎦ ⎢⎣ − v 1 ⎥⎦ ⎣ 2 ⎥⎦ ⎢⎣ Δ y ⎥⎦ ⎢⎣ 6 ⎥⎦
⎢⎣ ∂x ∂y ⎦⎥

Dr Ali Jawarneh 23
Cramer’s rule:
−2 −6 −5 −6 −2 −5
D= = 32 Dx = = 26 Dy = = 18
6 2 6 2 6 6

D x 26
Δx = = = 0.812 ⇒ Δx = x i +1 − x i = x 2 − x1 ⇒ x 2 = 0.812 + 3 = 3.812
D 32
Dy 18
Δy = = = 0.562 ⇒ Δy = y i +1 − y i = y 2 − y 1 ⇒ y 2 = 0.562 + 1 = 1.562
D 32

x 2 − x1 3.812 − 3
ε ax = 100% = 100% = 21.3%
x1 3.812

y 2 − y1 1.562 − 1
ε ay = 100% = 100% = 35.98%
y1 1.562

Dr Ali Jawarneh 24
i=2: x 2 = 3.812, y 2 = 1.562
u 2 = ( x 2 − 4) 2 + ( y 2 − 4) 2 − 5 = ( 3.812 − 4) 2 + (1.562 − 4) 2 − 5 = 0.979

v 2 = x 22 + y 22 − 16 = 3.812 2 + 1.562 2 − 16 = 0.971

∂u 2 ∂u 2
= 2( x 2 − 4) = 2( 3.812 − 4) = −0.376 = 2( y 2 − 4) = 2(1.562 − 4) = −4.876
∂x ∂y

∂v 2 ∂v 2
= 2x 2 = 2( 3.812) = 7.624 = 2y 2 = 2(1.562) = 3.124
∂x ∂y

⎡ ∂u 2 ∂u 2 ⎤
⎢ ∂x ∂y ⎥ ⎡ Δ x ⎤ ⎡ − u 2 ⎤ ⎡ − 0 .376 − 4 .876 ⎤ ⎡ Δ x ⎤ ⎡ − 0 .979 ⎤
⎢ ⎥ = ⎢ 7 .624 =⎢
⎢ ∂v 2 ∂v 2 ⎥ ⎢⎣ Δy ⎥⎦ ⎢⎣ − v 2 ⎥⎦ ⎣ 3 .124 ⎦ ⎣ Δ y ⎦ ⎣ − 0 .971 ⎥⎦
⎥ ⎢ ⎥

⎢⎣ ∂x ∂y ⎥⎦

Dr Ali Jawarneh 25
Cramer’s rule:
− 0.376 − 4.876 − 0.979 − 4.876
D= = 36 Dx = = −7.79299
7.624 3.124 − 0.971 3.124

− 0.376 − 0.979
Dy = = 7.828992
7.624 − 0.971

D x − 7.793
Δx = = = −0.2165 ⇒ Δx = x i +1 − x i = x 3 − x 2 ⇒ x 3 = −0.2165 + 3.812 = 3.596
D 36

Dy 7.8289
Δy = = = 0.2175 ⇒ Δy = y i +1 − y i = y 3 − y 2 ⇒ y 2 = 0.2175 + 1.562 = 1.780
D 36
x3 − x2 3.596 − 3.812
ε ax = 100% = 100% = 6.007%
x3 3.596

y3 − y2 1.780 − 1.562
ε ay = 100% = 100% = 12.247%
y3 1.780

Dr Ali Jawarneh 26
i xi yi εax % εay %

1 3 1 ‐ ‐
2 3.812 1.562 21.3 35.98
3 3 596
3.596 1 780
1.780 6 007
6.007 12 247
12.247
4 3 570
3.570 1 805
1.805 0 7283
0.7283 1 385
1.385
5 3.570 1.806 0.0 0.05537
Dr Ali Jawarneh 27

You might also like