Lecture 5
Lecture 5
Numerical Methods
[MA-200]
Newton’s Method [Recall]
Assumptions: 𝑓(𝑥), 𝑓 ′ 𝑥 and 𝑥0 are available
𝑓′ 𝑥 ≠ 0
𝑓(𝑥𝑖 )
𝑥𝑖+1 = 𝑥𝑖 − ′
𝑓 𝑥𝑖
′
𝑓 𝑥𝑖 − 𝑓(𝑥𝑖−1 )
𝑓 𝑥 =
𝑥𝑖 − 𝑥𝑖−1
𝑓(𝑥𝑖 ) 𝑓(𝑥𝑖 )
𝑥𝑖+1 = 𝑥𝑖 − ′ = 𝑥𝑖 −
𝑓 𝑥𝑖 𝑓 𝑥𝑖 − 𝑓(𝑥𝑖−1 )
𝑥𝑖 − 𝑥𝑖−1
𝑥𝑖 − 𝑥𝑖−1
𝑥𝑖+1 = 𝑥𝑖 − 𝑓 𝑥𝑖 .
𝑓 𝑥𝑖 − 𝑓(𝑥𝑖−1 )
Secant Method
Assumptions:
𝑥𝑖 − 𝑥𝑖−1
𝑥𝑖+1 = 𝑥𝑖 − 𝑓 𝑥𝑖 .
𝑓 𝑥𝑖 − 𝑓(𝑥𝑖−1 )
Secant Method - Flowchart
Working Procedure
Step 1: Let a function 𝑓 𝑥 = 0
Step 2: Find 𝑥0 and 𝑥1 such that 𝑓 𝑥0 . 𝑓 𝑥1 < 0
Step 3: Estimate the new value of the root, 𝑥𝑖+1
𝑥𝑖 − 𝑥𝑖−1
𝑥𝑖+1 = 𝑥𝑖 − 𝑓 𝑥𝑖 .
𝑓 𝑥𝑖 − 𝑓(𝑥𝑖−1 )
Step 4: Specify the stopping criteria.
For example: Calculate the “Relative or Absolute Approximate Error”
𝑥𝑖+1 − 𝑥𝑖
𝑅. 𝐸 = , 𝐴. 𝐸 = 𝑥𝑖+1 − 𝑥𝑖
𝑥𝑖
Example:
Find a root of the equation f(x)= 𝒙𝟐 -2 by using Secant Method in the interval [1, 2].
Solution:
Let
𝑓 𝑥 = 𝑥2 − 2
Assume initial guesses 𝑥0 = 1, 𝑥1 = 2
𝑥𝑖 − 𝑥𝑖−1
𝑥𝑖+1 = 𝑥𝑖 − 𝑓 𝑥𝑖 .
𝑓 𝑥𝑖 − 𝑓(𝑥𝑖−1 )
1st Iteration:
At i=1
𝑥1 − 𝑥0
𝑥2 = 𝑥1 − 𝑓 𝑥1 .
𝑓 𝑥1 − 𝑓(𝑥0 )
2
𝑓 𝑥0 = 𝑥0 − 2 = 12 − 2 = −1
𝑓 𝑥1 = 𝑥12 − 2 = 22 − 2 = 2
Cont.
2−1 2
𝑥2 = 2 − 2. = 2 − = 1.3333
2 − −1 3
𝑥2 = 1.3333
2nd Iteration:
At i=2
𝑥2 − 𝑥1
𝑥3 = 𝑥2 − 𝑓 𝑥2 .
𝑓 𝑥2 − 𝑓(𝑥1 )
𝑓 𝑥1 = 𝑥12 − 2 = 22 − 2 = 2
𝑓 𝑥2 = 𝑥22 − 2 = 1.33332 − 2 = −0.2223
Cont.
1.3333 − 2
𝑥3 = 1.3333 − (−0.2223). = 1.4
−0.2223 − 2
𝑥2 = 1.4
3rd Iteration:
At i=3
𝑥3 − 𝑥2
𝑥4 = 𝑥3 − 𝑓 𝑥3 .
𝑓 𝑥3 − 𝑓(𝑥2 )
𝑓 𝑥2 = 𝑥22 − 2 = 1.33332 − 2 = −0.2223
𝑓 𝑥3 = 𝑥32 − 2 = 1.42 − 2 = −0.04
Cont.
1.4 − 1.3333
𝑥4 = 1.4 − (−0.04). = 1.4102
−0.04 + 0.2223
𝑥4 = 1.4102
4th Iteration:
At i= 4
𝑥4 − 𝑥3
𝑥5 = 𝑥4 − 𝑓 𝑥4 .
𝑓 𝑥4 − 𝑓(𝑥3 )
𝑓 𝑥3 = 𝑥32 − 2 = 1.42 − 2 = −0.04
𝑓 𝑥4 = 𝑥42 − 2 = 1.41022 − 2 = −0.0114
Cont.
1.4102 − 1.4
𝑥5 = 1.4102 − (−0.0114). = 1.4143
−0.0114 + 0.04
𝑥5 = 1.4143
5th Iteration:
At i= 5
𝑥5 − 𝑥4
𝑥6 = 𝑥5 − 𝑓 𝑥5 .
𝑓 𝑥5 − 𝑓(𝑥4 )
𝑓 𝑥4 = 𝑥42 − 2 = 1.41022 − 2 = −0.0114
𝑓 𝑥5 = 𝑥52 − 2 = 1.41432 − 2 = 0.0001
Cont.
1.4143 − 1.4102
𝑥6 = 1.4143 − (0.0001). = 1.4143
0.0001 + 0.0114
𝑥6 = 1.4143
Absolute Error:
n=1, 𝑥1+1 − 𝑥1 = 𝑥2 − 𝑥1 = 1.3333 − 2 = 0.6667
n=2, 𝑥2+1 − 𝑥2 = 𝑥3 − 𝑥2 = 1.4 − 1.3333 = 0.0667
n=3, 𝑥1+1 − 𝑥1 = 𝑥4 − 𝑥3 = 1.4102 − 1.4 = 0.0102
n=4, 𝑥2+1 − 𝑥2 = 𝑥5 − 𝑥4 = 1.4143 − 1.4102 = 0.0041
n=5, 𝑥3+1 − 𝑥3 = 𝑥6 − 𝑥5 = 1.4143 − 1.4143 = 0 < 0.0001 = 10−4
Advantages of Secant Method
Exercise 2.3
Q3(a), Q4(a), Q7, Q8, Q11, Q12, Q13(b), Q14(c)
END OF SECTION