What the secant method is for
The secant method solves f(x) = 0 using nothing but values of f. No derivative, no algebra, no rearranging - which is exactly what you need when f is a lookup table, the output of a simulation, or an expression whose derivative is unpleasant to write down.
The idea is one line long. Take your two most recent points, draw the straight line through (xₙ₋₁, f(xₙ₋₁)) and (xₙ, f(xₙ)), and take the point where that line crosses the axis as your next estimate. Repeat. Because a straight line through two nearby points on a smooth curve is a good local model of it, the estimates close in on the root quickly.
The variant this calculator also offers, false position (regula falsi), uses the identical formula but keeps the two points on opposite sides of the root. It gives up some speed and gains a guarantee: the root stays trapped between the endpoints, so the method cannot run away. Which you want depends on whether you value speed or safety more for the function in front of you.
The iteration, term by term
The update is
xₙ₊₁ = xₙ − f(xₙ) · (xₙ − xₙ₋₁) / (f(xₙ) − f(xₙ₋₁))
Read it as Newton's method with the derivative replaced by a difference quotient. Newton takes x − f(x)/f′(x); here the slope f′(xₙ) is estimated by (f(xₙ) − f(xₙ₋₁)) / (xₙ − xₙ₋₁), the slope of the chord through the last two points. Everything else is identical.
That substitution costs accuracy per step and saves a function evaluation. Newton needs both f and f′ at every iteration and converges quadratically, meaning the number of correct digits roughly doubles each step. The secant method needs only one new value of f per iteration - the previous one is reused - and converges with order φ = (1 + √5)/2 ≈ 1.618, the golden ratio. Measured per function evaluation rather than per iteration, that makes the secant method the faster of the two whenever a derivative evaluation costs about as much as a function evaluation, because 1.618 exceeds √2 ≈ 1.414, the effective per-evaluation order of Newton.
The denominator is the only thing that can fail. If the two function values are equal, the chord is horizontal and never meets the axis; the calculator stops and says so rather than dividing by zero. If they are merely close, the chord is nearly horizontal and the next iterate is thrown a long way off - the classic secant failure, and the reason a bad starting pair can diverge.
False position uses the same expression but chooses which old point to discard by sign rather than by age: it replaces whichever endpoint has the same sign as the new value, so the bracket survives every step. The cost is that on a convex stretch of curve one endpoint can sit still forever, and the interval then shrinks from one side only. That reduces the order of convergence to 1 - linear - which is why a stubborn regula falsi run can need many more iterations than the secant method on the same function.
Worked example: the root of x³ − 2x − 5
This is the cubic Newton used to illustrate his own method, published by Wallis in 1685. Its real root is 2.0945514815. Start from x0 = 2 and x1 = 3.
- Evaluate the ends. f(2) = 8 − 4 − 5 = −1. f(3) = 27 − 6 − 5 = 16. The signs differ, so a root lies between them.
- First step. x2 = 3 − 16(3 − 2)/(16 − (−1)) = 3 − 16/17 = 3 − 0.9411765 = 2.0588235.
- Evaluate there. 2.05882353 = 8.7268472, so f(2.0588235) = 8.7268472 − 4.1176470 − 5 = −0.3907998. The sign has flipped, so the estimate has crossed the root.
- Second step. Using the pair (3, 2.0588235): the numerator is (−0.3907998)(2.0588235 − 3) = (−0.3907998)(−0.9411765) = 0.3677645, and the denominator is −0.3907998 − 16 = −16.3907998. The correction is 0.3677645 ÷ (−16.3907998) = −0.0224373, so x3 = 2.0588235 − (−0.0224373) = 2.0812608.
- Keep going. Three more steps bring successive iterates into agreement at ten decimal places, at 2.0945514815.
Six iterations, six new function evaluations, ten correct digits. Bisection on the same starting interval would need about 34 evaluations to reach the same accuracy - log₂(1/10−10) = 33.2 halvings of a unit interval - because each step buys you a fixed factor of two rather than an accelerating one.
Watch the errors shrink. After the first step the estimate is off by 2.0945515 − 2.0588235 = 0.0357280; after the second, by 2.0945515 − 2.0812608 = 0.0132907. Each new error is roughly proportional to the product of the two before it, which is the relation eₙ₊₁ ≈ C eₙ eₙ₋₁ that produces the golden-ratio order.
Reading the iteration table
Start with the residual. A converged root has f(root) at or near the limits of floating-point precision - typically 10−12 or smaller for a well-scaled function. If the iterates have stopped moving but the residual is large, you have not found a root: you have found a place where the iteration is stuck, usually a pole where f blows up and changes sign. The calculator flags exactly that combination.
Next look at the |Δx| column. Healthy secant convergence shows this column collapsing faster than geometrically - each entry roughly the product of the two before it, scaled. A column falling by a constant factor each row means you are getting linear convergence, which happens at a multiple root (where f and f′ vanish together) or when running false position against a one-sided curve.
The observed order is estimated from the last four iterates as ln(eₙ/eₙ₋₁) / ln(eₙ₋₁/eₙ₋₂). Expect roughly 1.6 for the secant method on a simple root and roughly 1 for false position or for a repeated root. It is blank when there are too few iterations or when the errors are not decreasing monotonically, because the estimate is meaningless then.
A stopping test on |Δx| alone can lie in both directions. On a very flat function, small steps do not mean a small residual; on a very steep one, a large step can still leave you at a tiny residual. If your problem is scaled awkwardly, check both columns before accepting the answer.
Root-finders compared
| Method | Order | New f evaluations per step | Needs f′? | Guaranteed to converge? |
|---|---|---|---|---|
| Bisection | 1 (factor 0.5 per step) | 1 | No | Yes, given a sign change |
| False position | 1 | 1 | No | Yes, given a sign change |
| Secant | 1.618 | 1 | No | No |
| Newton-Raphson | 2 | 1 plus one f′ | Yes | No |
| Muller | 1.839 | 1 | No | No |
| Brent | 1.618 typical, 0.5 worst case | 1 | No | Yes, given a sign change |
Order p means the error obeys e_{n+1} ≈ C·eₙᵖ near the root. At a repeated root every method in this table drops to linear convergence.
What goes wrong, and what to do about it
- The two starting values give nearly equal f. The chord is almost horizontal and the next iterate is flung far away. Separate the starting points, or pick them on opposite sides of the root.
- The iteration leaves the domain. A step into negative territory under a square root or logarithm returns an undefined value and the run stops. False position cannot do this, because it never leaves the original bracket - a good reason to prefer it for functions with a restricted domain.
- The root is repeated. If f touches the axis without crossing, both f and f′ vanish there, and every method in the table above degrades to linear convergence. Apply the secant method to
f(x)/f′(x)instead, which turns a repeated root back into a simple one. - You converged to a pole, not a root. Functions like
1/(x−2)change sign across the pole and fool any sign-based test. Always check the residual, and plot the function across the interval before trusting a bracket. - False position stagnates. One endpoint never moves and the interval shrinks by an ever-smaller amount. The Illinois modification - halving the retained endpoint's function value each time it is kept - fixes this; so does switching to the plain secant variant once you are close.
- The tolerance is tighter than the arithmetic. Below about 10−15 relative, double precision cannot distinguish successive iterates and the loop simply runs out of iterations. Set the tolerance to what the problem needs, not to the smallest number you can type.
Where the secant method fits
Every general-purpose root-finding routine in a numerical library is a hybrid, and the secant method is usually the fast half of it. Brent's method - the algorithm behind scipy.optimize.brentq and MATLAB's fzero - keeps a bracket like bisection but attempts an inverse quadratic interpolation step first, falling back to the secant step, and falling back again to bisection when the fast steps misbehave. You get secant speed on well-behaved functions and bisection's guarantee on badly behaved ones.
Seen from another angle, the secant method is inverse linear interpolation applied repeatedly: it fits a straight line to x as a function of f and reads off where f = 0. Fit a parabola through three points instead and you get Muller's method, with order 1.839. The connection to polynomial interpolation is exact, not analogical.
If you can differentiate your function cheaply and in closed form, Newton-Raphson is the better tool and its quadratic convergence is hard to beat near the root. If you are solving a differential equation and need a root inside each implicit time step - the situation in stiff solvers - a secant or Newton step is what sits inside the loop of an implicit Runge-Kutta or backward Euler scheme. And for a system of nonlinear equations rather than a single one, Broyden's method is the secant idea generalised: it maintains an approximate Jacobian updated from successive function differences instead of computing derivatives.
Historically the method is older than calculus. A rule equivalent to false position appears in the Egyptian Rhind papyrus and in Chinese and medieval Islamic arithmetic texts as a way to solve linear problems by guessing twice and correcting. The modern reading - as Newton's method with the derivative approximated - only makes sense after Newton, but the arithmetic long predates it.
