# Secant method

The secant method uses secant lines of the graph of a locally linear function to approximate its real or complex roots. For a function $f(x)$, the approximations are defined recursively by $$x_{i+1} = \frac{x_{i-1}f(x_i) - x_if(x_{i-1})}{f(x_i) - f(x_{i-1})}.$$ The values $x_0$ and $x_1$ used initially in the recursion are guesses.

## Derivation

Since the secant line between points $(x_{i-1}, f(x_{i-1}))$ and $(x_i, f(x_i))$ is a linear function, it has exactly one root (unless $f(x_{i-1}) = f(x_i)$, in which case the method fails). The root of the secant line serves as $x_{i+1}$, an improved approximation to the root of $f(x)$.

The slope of the secant line is $$\frac{f(x_i) - f(x_{i-1})}{x_i - x_{i-1}}.$$ The point $(x_{i+1}, 0)$ is on the secant line, so $$\frac{f(x_i) - f(x_{i-1})}{x_i - x_{i-1}} = \frac{0 - f(x_i)}{x_{i+1} - x_i}.$$ Rearranging, $$x_{i+1} = x_i - \frac{f(x_i)(x_i - x_{i-1})}{f(x_i) - f(x_{i-1})}.$$ The reformulation $$x_{i+1} = \frac{x_{i-1}f(x_i) - x_if(x_{i-1})}{f(x_i) - f(x_{i-1})}$$ more clearly shows the symmetry between $x_{i}$ and $x_{i-1}$ in the calculation of $x_{i+1}$.

## Failure cases

The secant method fails when there are two adjacent estimates $x_i$ and $x_{i-1}$ for which $f(x_i) = f(x_{i-1})$ (analogous to reaching a zero derivative in Newton's method), and like Newton's method may converge to an unexpected root, cycle periodically, or diverge.