Skip to content

Newton-Raphson method: finding roots numerically

The Newton-Raphson method finds an approximate root of an equation f(x)=0f(x)=0. Starting from an estimate x0x_0, it repeatedly uses

xn+1=xnf(xn)f(xn).\boxed{x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}}.

When the starting value is suitable and the iteration converges, the approximations usually become accurate very quickly.

You should be able to:

  • rearrange an equation into the form f(x)=0f(x)=0;
  • differentiate polynomial, exponential, logarithmic and trigonometric functions;
  • find the equation and intercepts of a tangent;
  • substitute accurately using a calculator;
  • round to decimal places and significant figures.

Review differentiating standard functions, tangents to curves, and locating roots by a change of sign if needed.

Suppose xnx_n is an estimate of a root. At the point (xn,f(xn))(x_n,f(x_n)), the tangent to y=f(x)y=f(x) has equation

yf(xn)=f(xn)(xxn).y-f(x_n)=f'(x_n)(x-x_n).

Use the point where this tangent crosses the xx-axis as the next estimate. At that intercept, y=0y=0 and x=xn+1x=x_{n+1}, so

f(xn)=f(xn)(xn+1xn).-f(x_n)=f'(x_n)(x_{n+1}-x_n).

Provided f(xn)0f'(x_n)\ne0,

xn+1xn=f(xn)f(xn),x_{n+1}-x_n=-\frac{f(x_n)}{f'(x_n)},

which gives

xn+1=xnf(xn)f(xn).\boxed{x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}}.

Geometrically, each step follows the tangent down to the axis. If the graph is nearly straight near the root, that tangent intercept is a much better estimate than xnx_n.

Use this reliable process:

  1. Write the equation as f(x)=0f(x)=0.
  2. Find f(x)f'(x).
  3. Substitute both into the Newton-Raphson formula.
  4. Choose or use the given starting value x0x_0.
  5. Calculate x1,x2,x_1,x_2,\ldots, retaining full calculator precision.
  6. Stop only when you have enough evidence for the requested accuracy.

Use Newton-Raphson with x0=1.5x_0=1.5 to solve

x3x1=0.x^3-x-1=0.

Let

f(x)=x3x1,f(x)=3x21.f(x)=x^3-x-1, \qquad f'(x)=3x^2-1.

The iteration is

xn+1=xnxn3xn13xn21.x_{n+1}=x_n-\frac{x_n^3-x_n-1}{3x_n^2-1}.

Now substitute repeatedly:

x1=1.51.531.513(1.5)21=1.3478260869,x2=1.3478260869(1.3478260869)31.347826086913(1.3478260869)21=1.325200399,x3=1.324718174,x4=1.324717957.\begin{aligned} x_1 &=1.5-\frac{1.5^3-1.5-1}{3(1.5)^2-1}\\ &=1.3478260869\ldots,\\[4pt] x_2 &=1.3478260869\ldots- \frac{(1.3478260869\ldots)^3-1.3478260869\ldots-1} {3(1.3478260869\ldots)^2-1}\\ &=1.325200399\ldots,\\[4pt] x_3&=1.324718174\ldots,\\ x_4&=1.324717957\ldots. \end{aligned}

Thus the root is approximately

x=1.32472\boxed{x=1.32472}

to 55 decimal places.

Do not round x1x_1 before calculating x2x_2. Store each value or use the calculator’s previous answer key.

For f(x)=x27f(x)=x^2-7, use x0=3x_0=3 to find x1x_1 and x2x_2.

Answer

Since f(x)=2xf'(x)=2x,

xn+1=xnxn272xn.x_{n+1}=x_n-\frac{x_n^2-7}{2x_n}.

Therefore

x1=3976=83=2.666666,x_1=3-\frac{9-7}{6}=\frac83=2.666666\ldots,

and

x2=83(8/3)272(8/3)=12748=2.645833.x_2=\frac83-\frac{(8/3)^2-7}{2(8/3)} =\frac{127}{48}=2.645833\ldots.

Newton-Raphson applies to f(x)=0f(x)=0, so first move every term to one side. Different correct choices of ff can produce different iterations, even though they have the same roots.

Find the solution of

ex=3xe^x=3x

near x=1.5x=1.5, using x0=1.5x_0=1.5.

Define

f(x)=ex3x,f(x)=ex3.f(x)=e^x-3x, \qquad f'(x)=e^x-3.

Hence

xn+1=xnexn3xnexn3.x_{n+1}=x_n-\frac{e^{x_n}-3x_n}{e^{x_n}-3}.

The iterates are

nxn01.50000000011.51235814621.51213462531.512134552\begin{array}{c|c} n & x_n \\\hline 0 & 1.500000000\\ 1 & 1.512358146\\ 2 & 1.512134625\\ 3 & 1.512134552 \end{array}

Therefore the required solution is x1.51213x\approx1.51213 to 55 decimal places.

The equation actually has another positive solution. A starting value near that root may converge to it instead. A numerical method finds a root, not automatically every root.

Worked example 3: deriving a given iteration

Section titled “Worked example 3: deriving a given iteration”

Show that Newton-Raphson applied to

lnx+x=2\ln x+x=2

can be written as

xn+1=xn(3lnxn)xn+1.x_{n+1}=\frac{x_n(3-\ln x_n)}{x_n+1}.

Take

f(x)=lnx+x2,f(x)=1x+1=x+1x.f(x)=\ln x+x-2, \qquad f'(x)=\frac1x+1=\frac{x+1}{x}.

Then

xn+1=xnlnxn+xn2(xn+1)/xn=xnxn(lnxn+xn2)xn+1=xn(xn+1)xn(lnxn+xn2)xn+1=xn(3lnxn)xn+1.\begin{aligned} x_{n+1} &=x_n-\frac{\ln x_n+x_n-2}{(x_n+1)/x_n}\\ &=x_n-\frac{x_n(\ln x_n+x_n-2)}{x_n+1}\\ &=\frac{x_n(x_n+1)-x_n(\ln x_n+x_n-2)}{x_n+1}\\ &=\boxed{\frac{x_n(3-\ln x_n)}{x_n+1}}. \end{aligned}

The domain condition xn>0x_n>0 matters because lnxn\ln x_n must be defined.

Derive a Newton-Raphson iteration for

cosx=x.\cos x=x.
Answer

Let f(x)=cosxxf(x)=\cos x-x, so f(x)=sinx1f'(x)=-\sin x-1. Therefore

xn+1=xncosxnxnsinxn1=xn+cosxnxn1+sinxn.x_{n+1} =x_n-\frac{\cos x_n-x_n}{-\sin x_n-1} =x_n+\frac{\cos x_n-x_n}{1+\sin x_n}.

Angles must be in radians when differentiating and evaluating these functions.

Two successive displayed values agreeing is useful evidence of convergence, but it is not by itself a proof that the rounded root is correct. A slowly changing or temporarily stalled sequence can mislead.

For a secure final answer:

  1. iterate using extra guard digits;
  2. identify the proposed rounded value;
  3. if justification is required, use a change of sign at its rounding boundaries.

Worked example 4: justify the rounded answer

Section titled “Worked example 4: justify the rounded answer”

Newton-Raphson gives the root of f(x)=x3x1f(x)=x^3-x-1 as

α1.324717957.\alpha\approx1.324717957\ldots.

To prove that alpha=1.325alpha=1.325 correct to 33 decimal places, test the boundaries 1.32451.3245 and 1.32551.3255:

f(1.3245)=0.000929<0,f(1.3245)=-0.000929\ldots<0, f(1.3255)=0.003338>0.f(1.3255)=0.003338\ldots>0.

The polynomial is continuous, so a root lies between these boundaries. Also,

f(x)=3x21>0f'(x)=3x^2-1>0

throughout this short interval, so the root there is unique. Every number in the interval rounds to 1.3251.325 to 33 decimal places. Therefore

α=1.325 correct to 3 decimal places.\boxed{\alpha=1.325\text{ correct to }3\text{ decimal places}.}

See change of sign and rounding boundaries for the full justification method.

Let alphaalpha be a root with

f(α)=0andf(α)0.f(\alpha)=0 \qquad\text{and}\qquad f'(\alpha)\ne0.

If xnx_n is already close to alphaalpha and ff is sufficiently smooth, Newton-Raphson usually converges quadratically. Roughly, once the approximations are close enough, the number of correct digits can double at each step.

The method is fast because the tangent captures the local slope as well as the current function value. This advantage depends on being near a simple root and away from places where f(x)f'(x) is zero or very small.

Newton-Raphson is powerful, but it is not guaranteed to converge.

If f(xn)=0f'(x_n)=0, the formula divides by zero. If f(xn)f'(x_n) is merely very small, the correction

f(xn)f(xn)-\frac{f(x_n)}{f'(x_n)}

can be enormous and send the next estimate far away.

For f(x)=x31f(x)=x^3-1, choosing x0=0x_0=0 fails immediately because f(0)=0f'(0)=0.

For

f(x)=x32x+2,f(x)=x^3-2x+2,

the iteration started at x0=0x_0=0 gives

x1=1,x2=0,x3=1,x_1=1, \qquad x_2=0, \qquad x_3=1,

so it cycles and never approaches a root.

If a function has several roots, the starting value affects which root is reached. The nearest root is not always the one obtained because the tangent may cross the axis elsewhere.

At a repeated root, often f(α)=0f'(\alpha)=0. Convergence can become much slower. For example, applying the usual formula to

f(x)=(x2)2f(x)=(x-2)^2

gives

xn+1=xn(xn2)22(xn2)=xn+22,x_{n+1}=x_n-\frac{(x_n-2)^2}{2(x_n-2)} =\frac{x_n+2}{2},

so the error only halves each time. The usual rapid quadratic convergence is lost.

Read when numerical iteration fails for broader comparisons and recovery strategies.

  • Using the wrong derivative: differentiate f(x)f(x) exactly as defined.
  • Forgetting to set the equation equal to zero: Newton-Raphson finds zeros of ff.
  • Using f(xn+1)f'(x_{n+1}) in the denominator: every quantity on the right uses the current value xnx_n.
  • Rounding during iteration: retain the full stored value until the final answer.
  • Claiming proof from stable decimals: verify rounding boundaries when the question asks for justification.
  • Ignoring domains: logarithms, square roots and denominators can make an iterate invalid.
  • Using degrees with trigonometric calculus: standard derivatives assume radians.
  • Assuming every starting value works: inspect the graph or use a sign-changing interval to choose a sensible start.

Let

f(x)=x3+2x5.f(x)=x^3+2x-5.
  1. Write down the Newton-Raphson iteration.
  2. Starting with x0=1x_0=1, calculate x1x_1 and x2x_2 to 66 decimal places.
  3. Explain briefly why there is only one real root.
Answer

Since f(x)=3x2+2f'(x)=3x^2+2,

xn+1=xnxn3+2xn53xn2+2.x_{n+1}=x_n-\frac{x_n^3+2x_n-5}{3x_n^2+2}.

Then

x1=11+253+2=1.4,x_1=1-\frac{1+2-5}{3+2}=1.4,

and

x2=1.41.43+2(1.4)53(1.4)2+2=1.330964.x_2=1.4-\frac{1.4^3+2(1.4)-5}{3(1.4)^2+2} =1.330964\ldots.

Finally,

f(x)=3x2+2>0f'(x)=3x^2+2>0

for every real xx. Hence ff is strictly increasing and can have at most one real root. Since, for example, f(1)<0<f(2)f(1)<0<f(2), continuity also proves that a root exists. Therefore it has exactly one real root.