Skip to main content

Exploring Calculus with Maple Introductory Calculus

Section 12.6 Newton’s Method

Suppose we start with the function \(f(x) = { e}^x - 2\text{.}\) The root of this function is \(x = \ln 2\text{,}\) which is found by setting \(f(x)=0\) and solving for \(x\text{.}\) To get decimal approximations for roots of functions, we can simply use the fsolve() command.
> f(x) := exp(x) - 2;
\begin{equation*} \displaystyle f\, := \,x\mapsto {{ e}^{x}}-2 \end{equation*}
> fsolve(f(x) = 0);
\begin{equation*} \displaystyle 0.6931471806 \end{equation*}
Solvers such as the fsolve() command can find decimal approximations for roots such as this very quickly by employing efficient algorithms behind the scenes. In this section, we will use Newton’s method, which is very efficient technique for finding roots. We need to load the Student[Calculus1] package before we use the NewtonsMethod() command.
The NewtonsMethod() command must be given a function as well as an initial value for the variable. This initial value should usually be chosen to be close to where we “guess” that a root should be found. The method relies on calculating the root (or x-intercept) of the tangent line at the specified value, and iterates several times for each new root found. In most cases, the roots of these tangent lines quickly converge to a true root of the function.
Optional parameters may be included to change how the result is displayed and how many iterations of the method are performed.
Table 12.10. A list of optional parameters for the NewtonsMethod() command
Parameter Description
output = value
Outputs the numerical result of Newton’s method.
output = plot
Outputs a plot showing the tangent line approximation approach to finding the root.
output = animation
Much like the plot output, only with each iteration as a separate frame.
output = sequence
Outputs the original guess and the result of each iteration of Newton’s method.
iterations = \(n\)
Specifies the number of iterations to perform in Newton’s method.
For the function \(f(x) = e^x - 2\text{,}\) we may start with an initial value of \(x=2\) to see how Newton’s method quickly iterates to give an accurate approximation of the root \(x = \ln(2)\text{.}\) Using the output=plot option shows how tangent lines are used to determine the root of \(f(x)\) in five iterations.
> with(Student[Calculus1]):
> NewtonsMethod(f(x), x=2, output=plot);
To see the decimal approximation of the root after each iteration, you may use the output=sequence option. The initial value is given first, along with the root after each of the five iterations.
> NewtonsMethod(f(x), x=2, output=sequence);
\begin{equation*} \displaystyle \begin{array}{l}2,\, 1.270670566,\, 0.8319573035,\, 0.7023505839,\, \\ 0.6931894021,\, 0.6931471814 \end{array} \end{equation*}
The output option may be omitted if we wish to simply evaluate the root, which behaves much like using fsolve() to find a single root. For more accuracy, the algorithm can be run with additional iterations.
> NewtonsMethod(f(x), x=2);
\begin{equation*} \displaystyle 0.6931471814 \end{equation*}
> NewtonsMethod(f(x), x=2, iterations=10);
\begin{equation*} \displaystyle 0.6931471804 \end{equation*}
You should try playing around with the various output options and setting the number of iterations to various values to see how quickly Newton’s method can reach ten (or more) digits of accuracy.