The Newton-Raphson method uses the tangent to the curve to jump towards the root. When it works, it is very fast.

Derivation

Let x0 be a guess near the root of f(x) = 0. The tangent to the curve y = f(x) at (x0, f(x0)) has slope f′(x0). Its equation is y − f(x0) = f′(x0)(x − x0). Setting y = 0 gives the point where the tangent cuts the x-axis: x1 = x0 − f(x0)/f′(x0). This x1 is usually closer to the root than x0. Repeating gives the Newton-Raphson formula: x(n+1) = x(n) − f(x(n)) / f′(x(n)). The same formula follows from the first two terms of the Taylor series of f about x(n).

Definition: Newton-Raphson method. An iterative method for finding a root of f(x) = 0 using the formula x(n+1) = x(n) − f(x(n))/f′(x(n)), which follows the tangent to the curve at each step.

Convergence

Near a simple root, the method has quadratic convergence: the number of correct digits roughly doubles at each step. It is therefore much faster than bisection. But it needs the derivative f′(x), and it may fail if f′(x(n)) is zero or very small, since the next step then shoots far away, if the starting guess is poor, or if the iterates go round in a cycle. In practice, a few bisection steps are often used to get close, and then Newton-Raphson finishes the job. The iteration is stopped when |x(n+1) − x(n)| is below a chosen tolerance.

Special Formulas

The method gives useful formulas. To find √N, solve x² − N = 0, which gives x(n+1) = (x(n) + N/x(n))/2. This is the ancient Babylonian method, and computers use it to compute square roots. To find 1/N without division, solve 1/x − N = 0, which gives x(n+1) = x(n)(2 − N x(n)).

Table 3.3: Bisection and Newton-Raphson

Feature Bisection Newton-Raphson
Starting values Two, with sign change One guess
Needs derivative No Yes
Convergence Linear, sure Quadratic, not sure
Speed Slow Fast

Example 3.3: Newton-Raphson on the same cubic

Problem: Find the root of x³ − x − 1 = 0 starting from x0 = 1.5.

Solution:

  1. f(x) = x³ − x − 1, f′(x) = 3x² − 1.
  2. x1 = 1.5 − 0.875/5.75 = 1.347826.
  3. x2 = 1.347826 − 0.100682/4.449905 = 1.325200.
  4. x3 = 1.325200 − 0.002058/4.268468 = 1.324718.
  5. x4 = 1.324718.

Result: The root is 1.324718, found in four steps, against fifteen or more by bisection.

f = lambda x: x**3 - x - 1
df = lambda x: 3 * x**2 - 1
x = 1.5
for n in range(1, 5):
    x = x - f(x) / df(x)
    print(n, round(x, 6))

Output

1 1.347826
2 1.3252
3 1.324718
4 1.324718

Common mistakes

  • Choosing a starting point where f′(x) is zero or near zero.
  • Getting the sign wrong in the formula: it is x − f/f′, not x + f/f′.
  • Stopping too early, before successive values agree to the required places.

Key takeaways

  • x(n+1) = x(n) − f(x(n))/f′(x(n)).
  • Convergence is quadratic near a simple root.
  • It needs the derivative and a good starting value.
  • For √N: x(n+1) = (x(n) + N/x(n))/2.

Practice questions

  1. Write the Newton-Raphson formula.
  2. What is the order of convergence of the method?
  3. When may the method fail?

Answers to the practice questions

  1. x(n+1) = x(n) − f(x(n))/f′(x(n)).
  2. Quadratic, near a simple root.
  3. When f′(x) is zero or very small, or the starting guess is poor.

Sources

  • Official BCA syllabus Mathematics Foundations to Computer Science II, course code 25BCA402DS01, Unit III