The secant method is defined by the recurrence relation As can be seen from the recurrence relation, the secant method requires two initial values, x0 and x1, which should ideally be chosen to lie close to the root.
Derivation of the method
Starting with initial values and, we construct a line through the points and, as shown in the picture above. In slope–intercept form, the equation of this line is
The root of this linear function, that is the value of such that is We then use this new value of as and repeat the process, using and instead of and. We continue this process, solving for,, etc., until we reach a sufficiently high level of precision :
Convergence
The iterates of the secant method converge to a root of, if the initial values and are sufficiently close to the root. The order of convergence is φ, where is the golden ratio. In particular, the convergence is superlinear, but not quite quadratic. This result only holds under some technical conditions, namely that be twice continuously differentiable and the root in question be simple. If the initial values are not close enough to the root, then there is no guarantee that the secant method converges. There is no general definition of "close enough", but the criterion has to do with how "wiggly" the function is on the interval. For example, if is differentiable on that interval and there is a point where on the interval, then the algorithm may not converge.
The secant method does not require that the root remain bracketed, like the bisection method does, and hence it does not always converge. The false position method uses the same formula as the secant method. However, it does not apply the formula on and, like the secant method, but on and on the last iterate such that and have a different sign. This means that the false position method always converges. The recurrence formula of the secant method can be derived from the formula for Newton's method by using the finite-difference approximation The secant method can be interpreted as a method in which the derivative is replaced by an approximation and is thus a quasi-Newton method. If we compare Newton's method with the secant method, we see that Newton's method converges faster. However, Newton's method requires the evaluation of both and its derivative at every step, while the secant method only requires the evaluation of. Therefore, the secant method may occasionally be faster in practice. For instance, if we assume that evaluating takes as much time as evaluating its derivative and we neglect all other costs, we can do two steps of the secant method for the same cost as one step of Newton's method, so the secant method is faster. If, however, we consider parallel processing for the evaluation of the derivative, Newton's method proves its worth, being faster in time, though still spending more steps.
Generalizations
is a generalization of the secant method to more than one dimension. The following graph shows the function f in red and the last secant line in bold blue. In the graph, the x intercept of the secant line seems to be a good approximation of the root of f.
Computational example
Below, the secant method is implemented in the Python programming language. It is then applied to find a root of the function with initial points and def secant_method: """Return the root calculated using the secant method.""" for i in range: x2 = x1 - f * / float - f) x0, x1 = x1, x2 return x2 def f_example: return x ** 2 - 612 root = secant_method print # Root: 24.738633748750722