Skip to main content

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

PointSecant methodFalse Position method
Starting valuesAny two values x0, x1Two values a, b with f(a)·f(b) < 0
Root bracketingNot kept; root may leave the intervalAlways kept inside [a, b]
Choice of next pointsAlways the two latest pointsOne end is replaced so the sign change is kept
ConvergenceNot guaranteed, may divergeAlways converges
Order of convergence1.618 (superlinear)1 (linear, often slower)
Sign test on f(c)Not neededNeeded every iteration

✓ Answer checked by Claude Opus 5.5 (high effort)

All Numerical Method chapter 2 questions →