Skip to main content

NM1: Newton’s method

Stylised image of Newton's method iterative formula

You are used to solving equations using basic algebraic operations and perhaps the quadratic formula. However, some equations cannot be solved using these methods.

For example the equations: ex=x(1) or ln(x)=x3(2) cannot be solved using conventional methods. However they can be solved using numerical methods. The important aspect of equations (1) and (2) is that they can be re-arranged to f(x)=0. That is, the problem can be transformed to finding the root of a function f(x).1 A root of a function f(x) is the value of x for which f(x)=0.

Common numerical methods for root finding are:

  1. Newton’s method (also called the Newton-Raphson method)
  2. the Bisection method.

In this module we consider Newton’s method.

The Newton-Raphson method

Newton’s method (Newton-Raphson) can provide the value of x such that f(x)=0.

It has the form: xn+1=xnf(xn)f(xn)(1) where n starts at 0. The method is iterative, you start at n=0 and continue by incrementing n by one until you achieve the desired accuracy.

Note that:

  1. x0 is called the first estimate of the root, or the initial guess,
  2. xn+1 is the new estimate of the root, and xn is the old estimate of the root,
  3. f(xn) is the value of the function at xn and,
  4. f(xn) is the value of the derivative of f(x) at xn.

Example 1

Find the solution of ex=x for 0<x<1 to three decimal places.

Solution

First define the function:2 Note that you can also use f(x)=xex as it is equal to zero at the same value of x as f(x)=exx. f(x)=exx. We want to find x where f(x)=0. To do this we need an initial guess x0 of the root. This is easily done by graphing both y=x and y=ex. The point where the graphs intersect is the point where f(x)=0. The graphs are shown below.

Intersection of graphs of y equals e to the minus x and y equals x

A suitable value for x0 would be 0.5 and

f(x)=ex1

Using eqn (1), we can start the method x1=x0f(x0)f(x0)=0.5f(0.5)f(0.5)=0.5e0.50.5e0.51=0.5663x2=0.5663f(0.5663)f(0.5663)=0.5663e0.56630.5663e0.56631=0.5671x3=x2f(x2)f(x2)=0.5671e0.56710.5671e0.56711=0.5671. There has been no change to the first four places so we stop and the answer is x=0.567.

Example 2

Find the solution of ln(x)=x3 correct to five decimal places with an initial guess of x0=1.

Solution

Define the function f(x)=x3+ln(x) then f(x)=3x2+1x. In this case we have a value for x0 so there is no need to graph the functions. But we do it anyway.3 It is a good idea to graph the functions because it allows us to get an idea of the answer. If Newton’s method gives a result that is different to what we see in the graph, we have to consider that a mistake has been made or Newton’s method has found another root that we did not see on our graph.

Intersection of graphs for y equals minus log x and y equals x cubed

From the graph we see the answer should be about 0.7.

Using Newton’s method: x1=x0f(x0)f(x0)=113+ln(1)312+(11)=11+03+1=0.75x2=0.75(0.75)3+ln(0.75)3(0.75)2+(10.75)=0.7055775x3=0.7055775(0.7055775)3+ln(0.7055775)3(0.7055775)2+(10.7055775)=0.7047098x4=0.7047098(0.7047098)3+ln(0.7047098)3(0.7047098)2+(10.7047098)=0.7047095. As we have no change in the first five places after the decimal point we stop and take the answer as x=0.70471. Note that we round up the fifth digit.

Convergence of the Newton-Raphson method

Convergence indicates how quickly you will get an acceptable value of f(x)=0. Slow convergence implies many iterations, while fast convergence means few iterations.

Convergence of the method depends on the function f(x) and the initial guess. If the initial guess is in an area where the gradient of f(x) is nearly zero, convergence can be slow.

Consider the function f(x)=x41. It is graphed below.

Graph of x to the power of four minus 1 showing roots at x equals one and x equals negative one

Obviously the solutions of f(x)=0 are x=1 and x=1. These can be obtained by basic algebra and there is no need to use Newton’s method. However we will use this function to see what happens with different guesses for x0. We assume an accuracy to two decimal places and a calculation tolerance of 0.0000001.

Let x0=0.1. In this region the gradient of f(x) is close to zero. Newton’s method takes 25 iterations to get the result x=1.00.

Let x0=0.25 then it takes 15 iterations to get the result x=1.00.

Let x0=0.5 then it takes 9 iterations to get the result x=1.00.

Let x0=0.75 then it takes 6 iterations to get the result x=1.00.

So we see the number of iterations decrease (higher convergence) when the gradient of f(x) increases.

Convergence to another root

If the function f(x) has several roots, Newton’s method may converge to any of these. For example the function f(x)=x3+2x25x6 has three roots at x=3,1 and 2 as shown below.

Graph of x cubed plus two x squared minus 5 x minus 6 has roots at x equals negative 3, negative 1 and 2

If we set x0=2 we, perhaps, would think the method should find the root x=3 or 1 . But Newton’s method finds the root at x=2. This is why it is important to graph the function if possible.

Images on this page by RMIT, licensed under CC BY-NC 4.0


Keywords