Skip to main content
Mathematics LibreTexts

C.4 The secant method

  • Page ID
    89671
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    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{.}\)

    secant.svg

    The equation of the secant line is

    \[ y = F(x) = f(x_{n-1}) + \frac{f(x_n)-f(x_{n-1})}{x_n-x_{n-1}}(x-x_{n-1}) \nonumber \]

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

    \begin{align*} & 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})\\ & \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,

    Equation C.4.1 secant method.

    \[ x_{n+1}=\frac{x_{n-1} f(x_n) - x_n f(x_{n-1}) }{f(x_n)-f(x_{n-1})} \nonumber \]

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

    Example C.4.2 Approximating \(\sqrt{2}\text{,}\) again.

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

    \[ f(x)=x^2-2=0 \nonumber \]

    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

    \[ 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} \nonumber \]

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

    \begin{align*} x_{n+1}& =\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} \\ & =\frac{x_{n-1}x_n[x_n-x_{n-1}]+2[x_n-x_{n-1}]}{x_n^2-x_{n-1}^2} \\ & =\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} & & & \text{secant method}\qquad & & \text{Newton's method} \\ & x_0\quad & & 4 & & \\ & x_1 & & 3 & & 4 \\ & x_2 & & 2 & & 2.25 \\ & x_3 & & 1.6 & & 1.57 \\ & x_4 & & 1.444 & & 1.422 \\ & x_5 & & 1.4161 & & 1.414234 \\ & x_6 & & 1.414233 & & 1.414213562525 \\ & x_7 & & 1.414213575 & & 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.


    This page titled C.4 The secant method is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Joel Feldman, Andrew Rechnitzer and Elyse Yeager via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.