Secant method (source code)

= Secant method
{title2=$x_{k+1}=x_k-f(x_k)(x_k-x_{k-1})/(f(x_k)-f(x_{k-1}))$}
{wiki}

The <secant method> approximates a <zero of a function> by repeatedly taking the zero of a <secant line> through the two most recent sampled points. The formula follows by setting the line $f(x_k)+(x-x_k)(f(x_k)-f(x_{k-1}))/(x_k-x_{k-1})$ equal to zero. It requires distinct sampled positions and a nonzero difference of sampled values, unless a <root> has already been found. After initialization it needs one new <function> evaluation per step. Unlike <bisection>, it need not retain a bracket. For a sufficiently smooth <function> near a simple <root>, its usual local <order of convergence> is $(1+\sqrt5)/2$.<NIST Digital Library of Mathematical Functions/3.8 Nonlinear Equations>[§3.8(iii), Secant Method, following equation 3.8.6]{ref}