The secant method can be considered a variant of Newton's method in which the derivative is replaced by an approximation.
We can define the derivative of a function $f$ at a point $a$ as
If $x=a+h$ then $h=x-a$
also
If $a = x_{k-1}$ and $x = x_{k-2}$
Removing the limit we obtain
If the iteration formula for Newton's method is
and we substitute the derivative by its approximation
Graphically, the secant method can be explained as an iterative method where
That is, we start with
Next
And so on.
- Given two initial guesses $x_0$ and $x_1$
- For $k=2,3\ldots,\mathrm{MaxNumIter}$:
- Compute $x_k=x_{k-1}-f(x_{k-1})\dfrac{x_{k-1}-x_{k-2}}{f(x_{k-1})-f(x_{k-2})}$
- If $x_k$ meets the stopping condition, stop.
- Else, perform another iteration.
Our equation is
$$x=\sqrt{3} \quad \Rightarrow \quad x^2=3 \quad \Rightarrow \quad x^2-3=0$$Therefore $f(x)=x^2-3$
The iteration formula is
$$x_k=x_{k-1}-f(x_{k-1})\dfrac{x_{k-1}-x_{k-2}}{f(x_{k-1})-f(x_{k-2})}$$In this case
$$x_k=x_{k-1}-(x_{k-1}^2-3)\dfrac{x_{k-1}-x_{k-2}}{(x_{k-1}^2-3)-(x_{k-2}^2-3)}$$The value of the function at the root is zero. The value of the function in the approximation is called residual and, if it is a good approximation, it is a small
Also, the residual in step $k$ is known, while the error is unknown (we need the exact solution, which is what we are looking for).
As $\alpha= 1.732051$ the absolute error is