Algorithm
Secant method Steps (Rule)
|
Step-1:
|
Find points `x_0` and `x_1` such that `x_0 < x_1` and `f(x_0) * f(x_1) < 0`.
|
Step-2:
|
find next value using
Formula-1 : `x_2=x_0-f(x_0)*(x_1-x_0)/(f(x_1)-f(x_0))`
or Formula-2 : `x_2=(x_0*f(x_1)-x_1*f(x_0))/(f(x_1)-f(x_0))`
or Formula-3 : `x_2=x_1-f(x_1)*(x_1-x_0)/(f(x_1)-f(x_0))`
(Using any of the formula, you will get same x2 value)
|
Step-3:
|
If `f(x_2) = 0` then `x_2` is an exact root,
else `x_0 = x_1` and `x_1 = x_2`
|
Step-4:
|
Repeat steps 2 & 3 until `f(x_i) = 0` or `|f(x_i)| <= "Accuracy"`
|
Example-1
1. Find a root of an equation `f(x)=x^3-x-1` using Secant method
Solution:
Here `x^3-x-1=0`
Let `f(x) = x^3-x-1`
Here
`1^(st)` iteration :
`x_0 = 1` and `x_1 = 2`
`f(x_0) = f(1) = -1` and `f(x_1) = f(2) = 5`
`:. x_2 = x_0 - f(x_0) * (x_1 - x_0) / (f(x_1) - f(x_0))`
`x_2 = 1 - (-1) xx (2 - 1)/(5 - (-1))`
`x_2 = 1.16667`
`:. f(x_2) = f(1.16667) = -0.5787`
`2^(nd)` iteration :
`x_1 = 2` and `x_2 = 1.16667`
`f(x_1) = f(2) = 5` and `f(x_2) = f(1.16667) = -0.5787`
`:. x_3 = x_1 - f(x_1) * (x_2 - x_1) / (f(x_2) - f(x_1))`
`x_3 = 2 - 5 xx (1.16667 - 2)/(-0.5787 - 5)`
`x_3 = 1.25311`
`:. f(x_3) = f(1.25311) = -0.28536`
`3^(rd)` iteration :
`x_2 = 1.16667` and `x_3 = 1.25311`
`f(x_2) = f(1.16667) = -0.5787` and `f(x_3) = f(1.25311) = -0.28536`
`:. x_4 = x_2 - f(x_2) * (x_3 - x_2) / (f(x_3) - f(x_2))`
`x_4 = 1.16667 - (-0.5787) xx (1.25311 - 1.16667)/(-0.28536 - (-0.5787))`
`x_4 = 1.33721`
`:. f(x_4) = f(1.33721) = 0.05388`
`4^(th)` iteration :
`x_3 = 1.25311` and `x_4 = 1.33721`
`f(x_3) = f(1.25311) = -0.28536` and `f(x_4) = f(1.33721) = 0.05388`
`:. x_5 = x_3 - f(x_3) * (x_4 - x_3) / (f(x_4) - f(x_3))`
`x_5 = 1.25311 - (-0.28536) xx (1.33721 - 1.25311)/(0.05388 - (-0.28536))`
`x_5 = 1.32385`
`:. f(x_5) = f(1.32385) = -0.0037`
`5^(th)` iteration :
`x_4 = 1.33721` and `x_5 = 1.32385`
`f(x_4) = f(1.33721) = 0.05388` and `f(x_5) = f(1.32385) = -0.0037`
`:. x_6 = x_4 - f(x_4) * (x_5 - x_4) / (f(x_5) - f(x_4))`
`x_6 = 1.33721 - 0.05388 xx (1.32385 - 1.33721)/(-0.0037 - 0.05388)`
`x_6 = 1.32471`
`:. f(x_6) = f(1.32471) = -0.00004`
Approximate root of the equation `x^3-x-1=0` using Secant method is `1.32471`
`n` | `x_0` | `f(x_0)` | `x_1` | `f(x_1)` | `x_2` | `f(x_2)` | Update |
1 | 1 | -1 | 2 | 5 | 1.16667 | -0.5787 | `x_0 = x_1` `x_1 = x_2` |
2 | 2 | 5 | 1.16667 | -0.5787 | 1.25311 | -0.28536 | `x_0 = x_1` `x_1 = x_2` |
3 | 1.16667 | -0.5787 | 1.25311 | -0.28536 | 1.33721 | 0.05388 | `x_0 = x_1` `x_1 = x_2` |
4 | 1.25311 | -0.28536 | 1.33721 | 0.05388 | 1.32385 | -0.0037 | `x_0 = x_1` `x_1 = x_2` |
5 | 1.33721 | 0.05388 | 1.32385 | -0.0037 | 1.32471 | -0.00004 | `x_0 = x_1` `x_1 = x_2` |
This material is intended as a summary. Use your textbook for detail explanation.
Any bug, improvement, feedback then