Calculator · Engineering Mathematics

Secant Method Calculator

Root of a single-variable function from two starting guesses, approximating the derivative with the secant through the last two iterates instead of requiring one analytically.

Problem definition

Operators + − * / ^, parentheses, pi and e, and sin, cos, tan, asin, acos, atan, exp, sqrt, abs, ln, log, log10. Write 2*x, not 2x.

Results

Root estimate x*1.521
Residual f(x*)-1.843e-14
Iterations7
Function evaluations9
Final step |Δx|1.180e-9
StatusConverged
Last secant slope [f(xₙ) − f(xₙ₋₁)] / (xₙ − xₙ₋₁)5.944

Function plot

f(x) = x^3 - x - 2, with x₀, x₁ and the root estimate marked.

Iteration history

Secant iteration history
nxₙ₋₁xₙf(xₙ₋₁)f(xₙ)Step Δxxₙ₊₁
112-24-0.66671.333
221.3334-0.9630.12941.463
31.3331.463-0.963-0.33330.068481.531
41.4631.531-0.33330.05863-0.010241.521
51.5311.5210.05863-0.0026934.499e-41.521
61.5211.521-0.002693-2.015e-53.391e-61.521
71.5211.521-2.015e-57.015e-9-1.180e-91.521

Continue

Open in Root Finding Lab

f(x), both starting values, the tolerance and the iteration limit continue into the Lab, with the secant method enabled.

Assumptions & validity

  • · f is continuous near the root.
  • · x₀ and x₁ are distinct starting values.
  • · The root is simple, which is what gives the stated order of convergence.
  • · No bracket is required or maintained: x₀ and x₁ need not straddle the root, and the iterates may leave the starting interval.

Technical reference

xₙ₊₁ = xₙ − f(xₙ)·(xₙ − xₙ₋₁) / [f(xₙ) − f(xₙ₋₁)]

Secant slope: sₙ = [f(xₙ) − f(xₙ₋₁)] / (xₙ − xₙ₋₁)

Local order of convergence: p = (1 + √5)/2 ≈ 1.618

xₙ₋₁, xₙ
the last two iterates
f
the function whose root is sought
sₙ
the secant slope used in place of f′(xₙ)
x*
the root estimate returned by the method

This is Newton with the tangent replaced by the secant through the last two points, so no derivative is needed and one new function evaluation is spent per iteration.

Convergence is superlinear (order ≈ 1.618) locally, for a simple root.

x₀ and x₁ need NOT bracket the root, and the iterates may leave the starting interval — this is not a bracketing method and offers no guarantee of convergence.

A vanishing denominator — two equal function values — stops the method instead of producing an infinite step.

The stopping rule is the normalised residual test |f(x)|/fScale ≤ atol + rtol; a negligible step alongside a large residual is reported as stalled rather than converged.

The secant step is algebraically unchanged by f → c·f, and normalising the residual makes the stopping decision unchanged too.

Related tools