Newton's Method to Find Zeros of a Function

Newton's method is an example of how the first derivative is used to find zeros of functions and solve equations numerically. Examples with detailed solutions on how to use Newton's method are presented.
An online Newton's method calculator may be used to check results.

\( \)\( \)\( \)\( \)

Newton's method

Newton's method or Newton-Raphson method is a procedure used to generate successive approximations to the zero of function f as follows:
\[ x_{n+1} = x_n - \dfrac{f(x_n)}{f'(x_n)} \] for \( n = 0,1,2,3,...\)
In order to use Newton's method, you need to guess a first approximation to the zero of the function and then use the above procedure. Below we show you how to use this method in order to find good approximations to the zero of a function or solution of an equation.
Newton's method may be easily programmed, using almost any programming language with mathematical functions, to solve complicated equations numerically.


Example 1

Use Newton's method to approximate the largest zero of function f given by
\[ f(x) = x^2 + 3x + 1 \]

Solution to Example 1

The given function is quadratic and we can easily find its zeros using the quadratic formulas. However we start with this example in order to be able to compare the zero found using Newton's method with the one using the quadratic formulas.
How to use Newton's method to find the largest zero of f?
First, we need to find a close approximation to the zero. This can be done graphically. The graph of f below clearly shows that f has two zeros, both of them negative and the largest one is closer to zero. We can use zero as a starting value in the Newton's method procedure
newton's method example 1

We now calculate the first derivative f '
\[ f '(x) = 2 x + 3 \]
Now we start the procedure as follows:
Let \( x_0 = 0 \) . This is the starting approximate value to the largest zero. You might decide to take another value as long as it is close to the zero you are approximating.
We now calculate \( x_1 \) using the above procedure for \( n = 0 \) as follows:
\[ x_1 = x_0 - \dfrac{f(x_0)}{f '(x_0)} \]
Substitute \( x_0 \) by its value 0 and calculate \( x_1 \)
\( x_1 = 0 - \dfrac{f(0)}{f '(0)} \)
Substitute
\( x_1 = 0 - \dfrac{(0)^2 + 3(0) + 1}{2(0) + 3} \)
Simplify
\( x_1 = -1/3 \)

We now calculate \( x_2 \) as follows
\[ x_2 = x_1 - \dfrac{f(x_1)}{f '(x_1)} \]
Substitute and simplify
\( x_2 = -1/3 - \dfrac{f(-1/3)}{f '(-1/3)} \approx -0.38095238 \)
We now calculate \( x_3 \) as follows
\[ x_3 = x_2 -\dfrac{f(x_2)}{f '(x_2)} \]
Substitute and approximate
\( x_3 \approx -0.38196555 \)
Continue with the procedure to find
\( x_4 \approx -0.38196601 \)
\( x_5 \approx -0.38196601 \)


Since \( x_5 \) and \( x_4 \) are very close, there is no need to continue as we will not be able to make any more progress in approximating the zero.

Note the zeros of \( f(x) = x^2 + 3x + 1 \) may be found analytically by solving the equation \( x^2 + 3x + 1 = 0 \).
Using quadratic formulas, we obtain two real zeros:

\( z_1 = \dfrac{-3 - \sqrt 5}{2} \approx -2.61803398875... \) and \( z_2 = \dfrac{-3 + \sqrt 5}{2} \approx -0.38196601125... \)

We now compare \( x_5 \) to the exact value of the largest of the two zeros which is \( z_2 = \dfrac{-3 + \sqrt 5}{2} \approx -0.38196601125... \) and we can say that they are equal up to 8 decimal places. Another way to check the accuracy of our approximation is to compute
\( f(x_5) \approx 2.8 \; 10^{-9} \)
Since \( f(x_5) \) is very close to zero, \( x_5 \approx -0.38196601 \) is a good approximate value to one of the the zeros of \( f(x) \).


Note: We started with example 1 where the zeros were obtained using analytical methods and that was for comparison only. Newton's method is mainly used to solve equations with no analytical solutions as we shall see in examples 2 and 3.



Example 2

Use Newton's method to solve the following equation
\[ e^{x-3} = - x + 2 \]

Solution to Example 2

Note that the solution to the above equation cannot be found analytically, hence the use of Newton's method.
We first write the equation with the right side equal to zero.
\( e^{x-3} + x - 2 = 0 \)
The solution to the given equation is equal to the zero of the function \( f(x) = e^{x-3} + x - 2\).
Calculate the first derivative \( f ' \).
\[ f '(x) = e^{x-3} + 1 \]
Below is the graph of \( f \) and it can easily be seen that the zero of \( f \) is closer to \( 2 \) hence the choice of \( x_0 = 2 \) as the starting value.
newton's method example 2
Let \( x_0 = 2\) and calculate \( x_1 \)
\( x_1 = x_0 - \dfrac{f(x_0)}{f '(x_0)} \)
Substitute
\( x_1 = 2 - \dfrac{e^{2 - 3} + 2 - 2}{e^{2 - 3} + 1} \)
Use a calculator and approximate
\( x_1 \approx 1.73105857... \)
We now continue the process to calculate more values that approximate the zero of \( f \).
\( x_2 = 1.72154537... \)
\( x_3 = 1.72153545... \)
\( x_4 = 1.72153545... \)

Now that \( x_4 \) and \( x_3 \) are equal up to 8 decimal places and we have reached the limit of accuracy of our calculator. As a final check let us compute
\[ f(x_4) \approx -9.3 \; 10^{-9} \]
and also calculate the left and right sides of the given equation \( e^{x-3} = - x + 2 \) at \( x_4 \) to show that they are very close.
Left side: \( \quad e^{x_4 - 3} \approx 0.278464540... \)
Right side: \( \quad - x_4 + 2 \approx 0.278464550... \)
We can say that \( x_4 = 1.72153545 \) is a good approximation to the solution of the given equation.


Example 3

Use Newton's method to approximate \( \sqrt[3] 5 \).

Solution to Example 3

\( \sqrt[3] 5 \) is the solution to the equation
\( x = \sqrt[3] 5 \)
Raise the two sides of the equation to power 3 to obtain the equation
\( x^3 = 5 \)
which can be written
\( f(x) = x^3 - 5 = 0 \)
The graph of \( f \) below shows that there is a zero close to \( 2 \) and we can use as a starting value.
newton's method example 3
The first derivative of \( f \) is given by
\( f '(x) = 3 x^2 \)
We now let \( x_0 = 2 \) an calculate \( x_1 \)
\( x_1 = x_0 - \dfrac{f(x_0)}{f '(x_0)} \)
Substitute and calculate
\( x_1 = 2 - \dfrac{f(2)}{f '(2)} = 2 - \dfrac{2^3-5}{3 \; 2^2} = 1.75 \)
We calculate more values that approximate the zero of f.
\( x_2 = 1.71088435... \)
\( x_3 = 1.70997642... \)
\( x_4 = 1.70997594... \)
\( x_5 = 1.70997594... \)

\( 1.70997594 \) is a good approximation to \( \sqrt[3] 5 \). Use your calculator to calculate \( \sqrt[3] 5 \) and compare the result of the calculation to the one obtained using Newton's method above.

More on applications of differentiation

applications of differentiation