CHAPTER 2 (2)
CHAPTER 2 (2)
CHAPTER 2 (2)
Chapter 2
(Non-Linear equations)
Introduction
Graphical method
Bisection method
Secant method
Regula Falsi method/method of false position
Newton-Raphson Method
Fixed point Iteration method
Examples:
3
1. x +2 x=0 Algebraic eqn.
2. tan( x )+cos x=0
x
3. e −4 x=0
1|Page
Computational /Numerical Methods lecture ________________
a+b
x 0=
Let 2
x
If f ( x 0 )=0 ⇒ 0 is the root of f ( x )=0
Otherwise: root lies either between
x 0 and a or between x 0 and b. (depending
NB: repeat this process until the latest interval (which contain the root) is as
small as desired, sayε
th
step, the new interval will be [an, bn] of length|b−a|
At the end of the n
2n
We then have
2|Page
Computational /Numerical Methods lecture ________________
|b −a|
≤ε
2n
|b−a| |b−a|
ln
log ε ε
n≥ e2 = −−−−−−(∗)
log e ln 2
1+1 .5 19
x 1= =1 . 25 f (1. 25 )=− <0
2 and 64
⇒ root lies between 1.25&1.5
1 .25+1. 5
x 2= =1 .375
2 and f (1. 375 )>0
⇒ root lies between 1.25&1.375
1 . 25+1. 375
x 3= =1 .3125
2 and f (1. 3125 )<0
⇒ root lies between 1.3125&1.375
1. 3125+1 .375
x 4= =1. 34375
2 and f (1. 34375 )>0
Example 2: determine approximately how many iterations are necessary to
3 2
solve to solve f ( x )=x + 4 x −10=0 with tolerance of ε =10 for a=1 and b=2.
−5
Solution
|b−a| |2−1|
n
≤ε n
≤10−5
2 ⇒ 2
3|Page
Computational /Numerical Methods lecture ________________
1
n
≤10−5
⇒2
−5
10
⇒ 2 ≤10 ⇒ −n log 2≤log 10 =−5
−n −5
5
n≥ ≈16 .6
log 210
⟹ At least 17 iterations are required (necessary) to achieve the desired
accuracy.
Exercise:
2
1. Find the root of ( x2 ) − sin x =0 on [1.5, 2] using Bisection method( compute
four iterations)
2. If a = 0.1 and b = 1.0, how many steps of the bisection method are needed to
–8
determine the root with an error of at most 0.5 10 .
⟹Continue computing the iterations until |x n+ 1−x n|≤ ε =0.5 x 10−n(which can be used
as a stoppage criteria).
Weak and strong sides of Bisection method
2. Always we form [an, bn] such that f (an )<0 ∧ f ( bn )>0 for n≥1
2. Secant Method
The method uses two points in the neighborhood of the solution to determine a
new estimate for the solution.
The two points (say x1& x2) are used to define a straight line (Secant line), and the
point where the line intersects the x-axis (say x 3) is the new estimate for the
solution.
( x 1 , f ( x 1)) .
4|Page
Computational /Numerical Methods lecture ________________
x2(
x3 , 0 )
x1
( x 2 , f ( x 2))
f ( x1 )−f ( x 2 ) f ( x 2 )−0
⇒ =
x 1−x 2 x 2 −x 3
Solving for X3 :
( x 2−x 1 ) x f ( x 2 )−x 2 f ( x1 )
x 3 =x 2− f ( x 2 )= 1
f (x 2 )−f ( x 1 ) f ( x 2 )−f ( x 1 )
In general
( x i−x i−1 )
x i+1 =x i− f ( xi )
f ( xi )−f ( x i−1 ) for i=1, 2,3,4,. . .
Example: Using Secant method perform the first four iterations to determine the
root of cosx −x e x =0 (Round your answers to four decimal places)
Solution:
Let f (x)=c osx−x e x
x 0=0 ⟹ f ( x 0 ) =f ( 0 )=1∧x 1=1 ⇒ f ( x 1 )=f ( 1 )=−2.1780
Using Secant method we have
( x 1−x 0 ) ( 1−0 )
x 2=x 1− f ( x 1 )=1− f ( 1)
f ( x 1 )−f ( x0 ) f ( 1 )−f ( 0 )
(1−0)
(−2.1780 ) =0.31466 ≈ 0.3147
¿ 1−
−2.1780−1
⟹ x 2=0.3147 and f ( x 2 ) =f ( 0.3147 )=0.5198
Hence
5|Page
Computational /Numerical Methods lecture ________________
( x 2−x 1 ) (0.3147−1)
x 3=x 2− f ( x 2 )=0.3147− f ( 0.3147 )
f ( x 2 )−f ( x 1) f ( 0.3147 )−f ( 1 )
(0.3147−1)
¿ 0.3147− ( 0.5198 ) =0.4467
0.5198−(−2.1780)
⟹ x 3=0.4467 , f ( x 3 ) =f ( 0.4467 )=0.2036
Using Secant method again, we have
( x 3−x 2 ) ( 0.4467−0.3147 )
x 4 =x3 − f ( x 3 )=0.4467− f ( 0.4467 )=0.5317
f ( x3 ) −f ( x 2 ) f ( 0.4467 )−f ( 0.3147 )
Similarly one can show that ⟹ x 5=0.5169
Exercise: Determine the root of f ( x )=x 3−e−0.5 x by using Secant method. Start with
x 1=0 and x 2=1, carry out the first five iterations by rounding to six decimal
places.
6|Page
Computational /Numerical Methods lecture ________________
(1−0)
¿ 1− (−2.1780 ) =0.31466 ≈ 0.3147(Similar to secant method)
−2.1780−1
⟹ x 2=0.3147 and f ( x 2 ) =f ( 0.3147 )=0.5198>0
Since f ( x 1 ) . f ( x 2 )=f ( 1 ) f ( 0.3147 )<0, root lies in [1, 0.3147]= [ x 1 , x 2]
Hence
( x 2−x 1 ) (0.3147−1)
x 3=x 2− f ( x 2 )=0.3147− f ( 0.3147 )
f ( x 2 )−f ( x 1) f ( 0.3147 )−f ( 1 )
(0.3147−1)
¿ 0.3147− ( 0.5198 ) =0.4467
0.5198−(−2.1780)
⟹ x 3=0.4467 , f ( x 3 ) =f ( 0.4467 )=0.2036 >0
Since f ( x 1 ) . f ( x 3 )=f ( 1 ) f ( 0.4467 ) <0, root lies in [1, 0.4467]= [ x 2 , x 3] (say)
Hence
( x 3−x 2 ) ( 0.4467−1 )
x 4 =x3 − f ( x 3 )=0.4467− f ( 0.4467 )
f ( x3 ) −f ( x 2 ) f ( 0.4467 )−f ( 1 )
( 0.4467−1 )
0.4467− 0.2036 = 0.4940(which is different from that of the secant)
0.2036−−2.1780
and f ( x 4 )=f ( 0.4940 )=cos ( 0.4940 )−0.4940 e 0.4940 =0.0708> 0
4. Newton-Raphson Method
Let x0 be the approximate root of f(x)=0 and x1=x0+h is exact root.
⟹ f ( x 1 )=f ( x 0+ h )=0
Expanding f ( x 0 +h ) by Taylor series, we obtain
2 3
' h '' h '' '
0=f ( x 0 ) +h f ( x 0 ) + f ( x 0 ) + f ( x 0 ) +. . .
2! 3!
Since h=x 1 −x 0 is small, neglecting the second and higher order derivatives
'
f ( x 0 ) + h f ( x0 ) =0
−f (x )
⟹ h= ' 0
f (x 0 )
⟹ a better approximation than x 0is therefore given by x 1,where
x 1=x 0 +h
f (x 0)
⟹ x 1=x 0− '
f (x 0)
7|Page
Computational /Numerical Methods lecture ________________
Similarly, a better approximation than x 1 is x 2is given by
f (x 1 )
⟹ x 2=x 1− '
f (x 1)
In general
f ( x2 ) f (x )
⟹ x 3=x 2− '
⟹ x 4 =x3 − ' 3 . ..
f (x 2) f (x 3)
f (x n )
⟹ x n+1=x n− ' for n=0, 1, 2, 3 , . . .
f (x n )
Example: use Newton-Raphson method to find the root of x 3−2 x−5=0 correct to
six decimal places (take x 0=2).
Hence
3
f (x 0) x 0−2 x 0−5
⟹ x 1=x 0− '
=x 0− 2
f (x 0) 3 x 0 −2
3
2 −2(2)−5 −1
¿ 2− 2
=2− =2.1000000
3(2 )−2 10
f ( x1 ) 3
x 1−2 x1 −5
x 2=x 1− '
=x 1− 2
f ( x1 ) 3 x 1−2
3
2.100000 −2(2.1000000)−5
¿ 2.1000000− =2.0945681211042 ≈ 2.0945681
3 x 2.1000002−2
3
f ( x2 ) x2 −2 x 2−5
⟹ x 3=x 2− '
=x 2− 2
=2.0945514816978≈ 2.0945515
f (x 2) 3 x 2−2
3
f (x 3) x 3−2 x 3−5
⟹ x 4=x 3− '
=x 3− 2
=2.0945514815423 ≈ 2.0945515
f (x 3 ) 3 x 3−2
8|Page
Computational /Numerical Methods lecture ________________
Since|x 4 −x 3|0.000000 ≤ 0.5 x 10 , the desired root is x=2.094552 correct to six
−6
decimal places.
Exercise:
Find the root of x=e− xusing Newton-Raphson method correct to 3 decimal places
(Take x 0=1 ¿.
f ( x )=0
To describe this method for finding the roots of
We rewrite this equation in the form of
x=φ ( x ) (*)
3 2
Example: x + x −1=0 can be expressed as
1
−
2
a. x=(1+ x ) =φ( x )
1
3 2
b. x=(1−x ) =φ( x )
1
2 3
c. x=(1−x ) =φ( x )
Let
x 0 be the approximate value of the desired root α
x 1=φ( x 0 )
x 2 =φ( x 1 )
x 3 =φ( x 2 )
x 4 =φ( x 3 )
…
x n =φ( x n−1 )
9|Page
Computational /Numerical Methods lecture ________________
x , x , x , x , . . . x n does not always converge
Note: the sequences of approximations 0 1 2 3
to some numberα .
x
Example: consider x=10 +1=φ( x )
If we take
x 0 =0 ,then
containing α andφ ( x ) is continuous in I .if |φ' ( x)|<1 for ∀ x ∈ I ,then the sequence
of approximations
x 0 , x 1 , x 2 , x 3 , . . . x n will converge to α provided that the initial
approximation
x 0 is chosen in I.
Proof:
α is a root of f ( x )=0
⇒ α is a root of x=φ ( x )
⇒ α=φ(α )
x x
And x n =φ( x n−1 ) where n and n−1 two successive approximations of α
⇒ x n −α = ( x n−1 −α )φ ( β )
'
10 | P a g e
Computational /Numerical Methods lecture ________________
⇒ |x n −α|→0 as n →∞
lim |x n −α|=0
⇒ n→∞
if k > 1
|x n −α|→∞ as n →∞
3 2
Example1: Find the root of the equation f ( x )=x + x −1=0 on the interval [0, 1]
correct to three decimal places.
f ( x )=x 3 + x 2 −1=0
Solution
x 3 + x 2 −1=0
x 2 ( x +1)=1
1
x=
√ x +1
1
let x= =φ ( x )
√ x +1
1 1 1
⇒ φ' ( x )=− =−
2 √(1+x )3 2 √(1+x )3
1 1
≤ <1 ∀ x ∈[ 0 , 1 ]
|φ ( x)|= 2 √(1+x ) 2
' 3
Let
x 0 =0 .75 be the initial approximation
1
x 1=φ( x 0 )= =0 . 7559
Hence √ 0. 75+1
11 | P a g e
Computational /Numerical Methods lecture ________________
1
x 2 =φ( x 1 )= =0 .7547
√0 . 7559+1
1
x 3 =φ( x 2 )= =0 . 7549
√ 0. 7547+1
Since|x 3−x 2|0.0002 ≤0.5 x 10 , the approximate root is 0.755correct to three
−3
decimal places.
Exercise:
1. Find the root of the equationcos x=3 x−1 correct to three decimal places on
π
[0, ]
2 using fixed point iteration method
2. Using fixed point iteration compute three iterations to find a real root of the
equation sin x +5 x+2=0 (take x 0=0 ).
12 | P a g e