Numerical Methods Lecture #5

You might also like

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

Numerical

Methods
Lecture-5
[MA-200]
ARISHA ALI
Secant Method

If 𝑥𝑛−1 and 𝑥𝑛 are the two approximations to roots 𝛼 of nonlinear equation


𝑓 𝑥 = 0 then 𝑥𝑛+1 approximation is given by
𝑥𝑛−1 𝑓 𝑥𝑛 −𝑥𝑛 𝑓(𝑥𝑛−1 )
𝑥𝑛+1 =
𝑓(𝑥𝑛) −𝑓(𝑥𝑛−1 )

𝑛 = 1, 2, 3, …

ARISHA ALI 2
Graphical
Representation

ARISHA ALI 3
Working Rule
▪Let 𝑓 𝑥 = 0 be the given equation
▪Find 𝑥0 𝑎𝑛𝑑 𝑥1 such that 𝑓 𝑥0 < 0 𝑎𝑛𝑑 𝑓 𝑥1 > 0 (𝑜𝑟 𝑓(𝑥0 )𝑓(𝑥1 ) < 0)
▪Find first approximate by
𝑥0 𝑓 𝑥1 − 𝑥1 𝑓(𝑥0 )
𝑥2 =
𝑓(𝑥1) − 𝑓(𝑥0 )
Find 𝑓(𝑥2 )
▪Find second approximate by
𝑥1 𝑓 𝑥2 − 𝑥2 𝑓(𝑥1 )
𝑥3 =
𝑓(𝑥2 ) − 𝑓(𝑥1 )
ARISHA ALI 4
Cont…
Calculate 𝑓 𝑥3
▪Find third approximate root by
𝑥2 𝑓 𝑥3 − 𝑥3 𝑓(𝑥2 )
𝑥4 =
𝑓(𝑥3 ) − 𝑓(𝑥2 )
Calculate 𝑓 𝑥4
▪ Repeat above process up to required approximate root

ARISHA ALI 5
Example#1
Find the real root of equation 𝑥 3 − 𝑥 − 1 = 0 by secant method correct up to 3
decimal places.
Solution
Let 𝑓 𝑥 = 𝑥 3 − 𝑥 − 1 = 0
To find 𝒙𝟎 𝒂𝒏𝒅 𝒙𝟏
𝑓 0 = −1 < 0
𝑓 1 = −1 < 0
𝑓 2 =8−2−1=5>0
ARISHA ALI 6
Cont…

𝑓 1.5 = 0.875 > 0


𝑓 1.4 = 0.343 > 0
𝑓 1.3 = −0.103 < 0
Choosing 𝑥0 = 1.3 𝑎𝑛𝑑 𝑥1 = 1.4
𝑓 𝑥0 = −0.103 𝑎𝑛𝑑 𝑓 𝑥1 = 0.343

ARISHA ALI 7
Cont…
1st Iteration:
𝑥0 𝑓 𝑥1 −𝑥1 𝑓(𝑥0 ) 1.3 0.343 −1.4(−0.103)
𝑥2 = = = 1.32304
𝑓(𝑥1 )−𝑓(𝑥0 ) 0.343−(−0.103)

𝑓 𝑥2 = −0.007136 < 0
2nd Iteration:
𝑥1 𝑓 𝑥2 −𝑥2 𝑓(𝑥1 ) 1.4 −0.007136 −1.32304(0.343)
𝑥3 = = = 1.324605
𝑓(𝑥2 )−𝑓(𝑥1 ) −0.007136−0.343

𝑓 𝑥3 = −0.000481 < 0

ARISHA ALI 8
Cont…
3rd Iteration:
𝑥2 𝑓 𝑥3 −𝑥3 𝑓(𝑥2 ) 1.32304 −0.000481 −1.324605(−0.007136)
𝑥4 = =
𝑓(𝑥3 )−𝑓(𝑥2 ) −0.000481−(−0.007136)

𝑥4 = 1.324717
Hence the correct root up to 3 decimal places is 𝑥 = 1.324

ARISHA ALI 9
Example # 2
Find the solution of 𝑥 = 𝑐𝑜𝑠𝑥 by secant method correct up to 4 decimal places
𝜋
for the initial approximation 𝑝0 = 0.5 𝑎𝑛𝑑 𝑝1 =
4

Solution:
𝑓 𝑥 = 𝑥 − 𝑐𝑜𝑠𝑥 = 0
𝑓 𝑝0 = 𝑓 0.5 = 0.5 − cos 0.5 = −0.37758 < 0
𝜋 𝜋 𝜋
𝑓 𝑝1 = 𝑓 = − cos = 0.078291 > 0
4 4 4

ARISHA ALI 10
Cont…
1st Iteration:
𝑝0 𝑓 𝑝1 −𝑝1 𝑓(𝑝0 ) 0.5 0.078298 −0.78539(−0.37758)
𝑝2 = = = 0.7363843
𝑓(𝑝1) −𝑓(𝑝0 ) 0.078291−(−0.37758)

𝑓 𝑝2 = −4.519622 ∗ 10−3
2nd Iteration:
𝑝1 𝑓 𝑝2 −𝑝2 𝑓(𝑝1 ) 0.785398 −4.519622∗10−3 −0.736383(0.078291)
𝑝3 = = = 0.739062
𝑓(𝑝2) −𝑓(𝑝1 ) 4.519622∗10−3 −0.078291

𝑓 𝑝3 = −3.871582 ∗ 10−5

ARISHA ALI 11
Cont…

3rd Iteration:
𝑝3 𝑓 𝑝2 −𝑝2 𝑓(𝑝3 ) 0.739062 −4.519622∗10−3 −0.736383(−3.871582∗10−5 )
𝑝4 = =
𝑓(𝑝3 )−𝑓(𝑝2 ) −3.871582∗10−5 −(−4.519622∗10−3 )

𝑝4 = 0.739085
Hence the correct root up to 4 decimal places is 𝑝 = 0.7390

ARISHA ALI 12
Error in Secant Method

∈𝑛+1 = 𝑘 ∈𝑛 ∈𝑛−1
∈𝑛+1 ∝ ∈𝑛 ∈𝑛−1
The error in secant method is proportional to the product of previous two terms

ARISHA ALI 13
Order/Rate of Convergence
Since
∈𝑛+1 = 𝑘 ∈𝑛 ∈𝑛−1 ---------- 1
𝑝
∈𝑛+1 = 𝑘 ∈𝑛 ------------2
We will find the number 𝑝, replace 𝑛 by 𝑛 − 1 in eq 2
𝑝
∈𝑛−1+1 = 𝑘 ∈𝑛−1
𝑝
∈𝑛 = 𝑘 ∈𝑛−1
1ൗ
1ൗ 𝑝 𝑝
∈𝑛 𝑝 = 𝑘 ∈𝑛−1

ARISHA ALI 14
Cont…
1ൗ 1ൗ
∈𝑛 𝑝 =𝑘 𝑝 ∈𝑛−1
1ൗ
∈𝑛 𝑝 = 𝐶 ∈𝑛−1
1 1ൗ
∈𝑛−1 = ∈𝑛 𝑝 ----------- 3
𝐶

Putting Eq 2 and eq 3 in eq 1
𝑝 1 1ൗ
𝑘 ∈𝑛 = 𝑘 ∈𝑛 ∗ ∈𝑛 𝑝
𝐶
𝑝+1
𝑝 𝑘 ൗ𝑝
𝑘 ∈𝑛 = ∈𝑛
𝐶

ARISHA ALI 15
Cont…
Equating powers
𝑝+1
𝑝=
𝑝

𝑝2 − 𝑝 − 1 = 0
Applying quadratic formula
−𝑏± 𝑏2 −4𝑎𝑐
𝑥=
2𝑎

𝑥 = 𝑝, 𝑎 = 1, 𝑏 = −1, 𝑐 = −1

ARISHA ALI 16
Cont…
1± (−1)2 −4(1)(−1)
𝑝=
2(1)

1± 1+4
𝑝=
2

1± 5
𝑝=
2

Therefore p is order and order is always positive


1+ 5
𝑝= = 1.618
2

Therefore the order of convergence of Secant Method is 1.618


ARISHA ALI 17
Argument: NR Method superior to
Secant Method

▪ In NR Method the error is proportional to the square of the previous errors i.e.,
∈𝑛+1 ∝ ∈2𝑛 , whereas in secant method the error is proportional to the product of
the previous two Errors i.e., ∈𝑛+1 ∝ ∈𝑛 ∈𝑛−1
▪The order of convergence of NR Method is 2 and the Order of Convergence of
Secant Method is 1.618.
Therefore we conclude that NR method is Superior to Secant Method

ARISHA ALI 18
Advantages

▪It converges faster


▪It doesn’t require use of derivative of a given function.
▪It requires only one function evaluation per iteration as compare to NR Method.

ARISHA ALI 19
Disadvantages

▪It requires two guesses


▪It is not guaranteed to converge
▪If 𝑓 𝑥𝑛 = 𝑓 𝑥𝑛−1 , then this method fails

ARISHA ALI 20
Homework

Exercise: 2.3
Q3(a), Q4(a), Q5, Q6, Q11, Q12, Q13(b), Q14(a , c)

ARISHA ALI 21
Quiz #1 Announcement

Monday 29th March 2021


Lecture #1 to Lecture #5
Timings 30 to 40 mins

ARISHA ALI 22

You might also like