Calculus · Newton’s method

Newton’s method

Newton’s method approximates a root of f by repeating one step: from a guess xₙ, take the tangent line at (xₙ, f(xₙ)) and use the point where it crosses the x-axis as the next guess. Drag the start and watch it converge fast, loop, or fly off.

Newton’s method in this visualization

Newton’s method approximates a root of f, a number r with f(r)=0f(r) = 0, by repeating one step. At the current guess xnx_n, take the tangent line to the graph at (xn,f(xn))(x_n, f(x_n)), which is L(x)=f(xn)+f′(xn)(x−xn)L(x) = f(x_n) + f'(x_n)(x - x_n). Near xnx_n the tangent stays close to the curve, so where it crosses the x-axis is a better guess for where the curve does. Solving L(x)=0L(x) = 0 gives the next guess. On the graph each step goes along the faint dashed line from xnx_n to the curve, then along the tangent to the axis.

One step of Newton’s method, defined when f′(xₙ) ≠ 0
xn+1=xn−f(xn)f′(xn)x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}

Write en=xn−re_n = x_n - r for the error. If r is a simple root (f′(r)≠0f'(r) \ne 0) and f has a continuous second derivative, a Taylor expansion of the step gives en+1≈f′′(r)2f′(r) en2e_{n+1} \approx \frac{f''(r)}{2f'(r)}\,e_n^2 once xnx_n is close to r. Squaring the error roughly doubles the number of correct digits. For x² − 2 from x₀ = 1 the errors are 0.086, 0.0025, 2.1 × 10⁻⁶ and 1.6 × 10⁻¹², and the readout shows en/en−12e_n/e_{n-1}^2 settling near 1/(22)≈0.3541/(2\sqrt2) \approx 0.354. Far from the root there is no such guarantee. Where f′′(r)=0f''(r) = 0 the squared term drops out and it is faster still: for arctan x the error is about −23en3-\tfrac23 e_n^3, cubed each step.

The step needs f′(xn)≠0f'(x_n) \ne 0. A flat tangent never meets the axis, and a nearly flat one meets it far away: for x² − 2 from 0.1 the first step lands at 10.05. The method can also fail without running away. For x³ − 2x + 2 the tangent at 0 lands on 1 and the tangent at 1 lands back on 0, and starts near 0 are pulled into this loop: the sequence stays bounded but has no limit. For arctan x there is a boundary α ≈ 1.3917, the number with 2α=(1+α2)arctan⁡α2\alpha = (1 + \alpha^2)\arctan\alpha. Starts with |x₀| < α converge, and starts beyond it land farther out on the other side each time. Every start colours the x-axis by where each start ends. For x³ − 2x + 2 about a fifth of [−3, 3] ends in the loop, including narrow bands that crowd toward the flat points ±2/3\pm\sqrt{2/3}. Starting from complex numbers turns those bands into the Newton fractal.

At a multiple root f′(r)=0f'(r) = 0 too, and the squaring is lost. For (x−1)2(x - 1)^2 the step is exactly xn+1=(xn+1)/2x_{n+1} = (x_n + 1)/2, so the error halves every step. That is linear convergence, about 3.3 steps for each new decimal digit. Near a root of multiplicity m the ratio en+1/ene_{n+1}/e_n tends to (m−1)/m(m - 1)/m.

Things to notice

  • Newton discussed x3−2x−5=0x^3 - 2x - 5 = 0 in 1669. From 2 the method as used today gives 2.1, 2.0945681 and 2.0945514817, correct to nine decimal places after three steps.
  • For f(x)=x2−af(x) = x^2 - a the step is xn+1=12(xn+a/xn)x_{n+1} = \tfrac12\left(x_n + a/x_n\right): the old rule for square roots, which averages a guess with a divided by it.

Controls

  • Drag the blue point x₀ along the x-axis, or press on the axis to put it there. It catches at multiples of 0.5.
  • Set n to show that many steps, or press n → ∞ to step to n = 10. The record keeps each xₙ and its error, and stops early at the root, at a flat tangent or past 10⁶.
  • Turn on Every start to colour the x-axis by where each start ends.

Related