- 2075 Baisakh · 4+2 marks
Secant algorithm, versus false position
Short answer
Secant method: given x0,x1, compute x2 = x1 - f(x1)*(x1-x0)/(f(x1)-f(x0)), then shift. It does not need bracketing and uses the latest two points. False position requires f(a)f(b)<0, always brackes the root, guarantees convergence, but converges linearly; secant may diverge but has superlinear convergence (order ~1.618).
Write an algorithm of Secant method to calculate the roots of a nonlinear equation f(x) = 0. Write the differences between secant and false position methods.
Secant method finds a root of f(x) = 0 using x(n+1) = x(n) − f(x(n))·[x(n) − x(n−1)] / [f(x(n)) − f(x(n−1))].
Algorithm
Algorithm: Secant method
Input : f(x), initial guesses x0, x1,
tolerance e, maximum iterations N
Output: approximate root
1. Read x0, x1, e, N
2. Set i = 1
3. Repeat steps 4 to 9 while i <= N
4. f0 = f(x0), f1 = f(x1)
5. If |f1 - f0| is very small then
print "Division by zero; change guesses"
stop
6. x2 = x1 - f1 * (x1 - x0) / (f1 - f0)
7. If |x2 - x1| < e then
print "Root =", x2, "after", i, "iterations"
stop
8. x0 = x1
x1 = x2
9. i = i + 1
10. Print "Method does not converge in N iterations"
11. Stop
Differences between Secant and False Position methods
| Point | Secant method | False Position method |
|---|---|---|
| Starting values | Any two values x0, x1 | Two values a, b with f(a)·f(b) < 0 |
| Root bracketing | Not kept; root may leave the interval | Always kept inside [a, b] |
| Choice of next points | Always the two latest points | One end is replaced so the sign change is kept |
| Convergence | Not guaranteed, may diverge | Always converges |
| Order of convergence | 1.618 (superlinear) | 1 (linear, often slower) |
| Sign test on f(c) | Not needed | Needed every iteration |
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Secant method algorithm · Numerical Method, chapter 2 · asked 2×
- False position pseudo-code · Numerical Method, chapter 2 · asked 2×
- False position: e^cos x - sin x - 1 · Numerical Method, chapter 2
- False position: cos x = x e^x · Numerical Method, chapter 2 · asked 2×
- Secant method: explain and derive · Numerical Method, chapter 2 · asked 3×
- Secant: x e^x - cos x · Numerical Method, chapter 2 · asked 3×
- Algorithm and flowchart: quadratic roots · Computer Programming, chapter 2
- Quadratic equation roots in FORTRAN · Computer Programming, chapter 11 · asked 2×
- Roots of quadratic equation in C · Computer Programming, chapter 5
- Process versus thread differences · Embedded System, chapter 6 · asked 4×