Skip to main content

Section C.4 The secant method

Let \(f(x)\) be a continuous function. The secant method is a variant of Newton's method that avoids the use of the derivative of \(f(x)\) — which can be very helpful when dealing with the derivative is not easy. It avoids the use of the derivative by approximating \(f'(x)\) by \(\frac{f(x+h)-f(x)}{h}\) for some \(h\text{.}\) That is, it approximates the tangent line to \(f\) at \(x\) by a secant line for \(f\) that passes through \(x\text{.}\) To limit the number of evaluations of \(f(x)\) required, it uses \(x=x_{n-1}\) and \(x+h=x_n\text{.}\) Here is how it works.

Suppose that we have already found \(x_n\text{.}\) Then we denote by \(y=F(x)\) the equation of the (secant) line that passes through \(\big(x_{n-1}, f(x_{n-1})\big)\) and \(\big(x_n,f(x_n)\big)\) and we choose \(x_{n+1}\) to be the value of \(x\) where \(F(x)=0\text{.}\)

The equation of the secant line is

\begin{equation*} y = F(x) = f(x_{n-1}) + \frac{f(x_n)-f(x_{n-1})}{x_n-x_{n-1}}(x-x_{n-1}) \end{equation*}

so that \(x_{n+1}\) is determined by

\begin{align*} \amp 0=F(x_{n+1}) = f(x_{n-1}) + \frac{f(x_n)-f(x_{n-1})}{x_n-x_{n-1}}(x_{n+1}-x_{n-1})\\ \amp \iff x_{n+1}= x_{n-1} - \frac{x_n-x_{n-1}}{f(x_n)-f(x_{n-1})} f(x_{n-1}) \end{align*}

or, simplifying,

Of course, to get started with \(n=1\text{,}\) we need two initial guesses, \(x_0\) and \(x_1\text{,}\) for the root.

In this example we compute, approximately, the square root of two by applying the secant method to the equation

\begin{equation*} f(x)=x^2-2=0 \end{equation*}

and we'll compare the secant method results with the corresponding Newton's method results. (See Example C.1.2.)

Since \(f'(x)=2x\text{,}\) (C.1.1) says that, under Newton's method, we should iteratively apply

\begin{equation*} x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}=x_n-\frac{x_n^2-2}{2x_n} =\frac{x_n}{2} +\frac{1}{x_n} \end{equation*}

while (C.4.1) says that, under the secant method, we should iteratively apply (after a little simplifying algebra)

\begin{align*} x_{n+1}\amp =\frac{x_{n-1} f(x_n) - x_n f(x_{n-1}) }{f(x_n)-f(x_{n-1})} =\frac{x_{n-1}[x_n^2-2] - x_n[x_{n-1}^2-2] }{x_n^2-x_{n-1}^2} \\ \amp =\frac{x_{n-1}x_n[x_n-x_{n-1}]+2[x_n-x_{n-1}]}{x_n^2-x_{n-1}^2} \\ \amp =\frac{x_{n-1}x_n+2}{x_{n-1}+x_n} \end{align*}

Here are the results, starting Newton's method with \(x_1=4\) and starting the secant method with \(x_0=4\text{,}\) \(x_1=3\text{.}\) (So we are giving the secant method a bit of a head start.)

\begin{alignat*}{3} \amp \amp \amp \text{secant method}\qquad \amp \amp \text{Newton's method} \\ \amp x_0\quad \amp \amp 4 \amp \amp \\ \amp x_1 \amp \amp 3 \amp \amp 4 \\ \amp x_2 \amp \amp 2 \amp \amp 2.25 \\ \amp x_3 \amp \amp 1.6 \amp \amp 1.57 \\ \amp x_4 \amp \amp 1.444 \amp \amp 1.422 \\ \amp x_5 \amp \amp 1.4161 \amp \amp 1.414234 \\ \amp x_6 \amp \amp 1.414233 \amp \amp 1.414213562525 \\ \amp x_7 \amp \amp 1.414213575 \amp \amp 1.414213562373095 \end{alignat*}

For comparison purposes, the square root of \(2\text{,}\) to 15 decimal places, is \(1.414213562373095\text{.}\) So the secant method \(x_7\) is accurate to 7 decimal places and the Newton's method \(x_7\) is accurate to at least 15 decimal places.

The advantage that the secant method has over Newton's method is that it does not use the derivative of \(f\text{.}\) This can be a substantial advantage, for example when evaluation of the derivative is computationally difficult or expensive. On the other hand, the above example suggests that the secant method is not as fast as Newton's method. The following subsection shows that this is indeed the case.