Hexa Scholar

Newton's method: fast, until it isn't

The question

Newton's method follows tangent lines toward a root of x³ − 2x + 2. From which starts does it get there, and from which never?

Move the start yourself; the page draws every step.

  1. 1 SeeHunt for starts that make Newton fail.
  2. 2 TryPredict the speed at other roots.
  3. 3 ProveBuild the error bound, line by line.
  4. 4 ApplyProblems to check yourself.
Before you start · 3 quick checks on tangent lines, bisection and derivatives, about 3 min

Two ideas before you start

2 ideas

Follow the tangent down to the axis

Figure: the parabola y = x² − 2, its tangent line at x₀ and the point x₁ where the tangent meets the axis. It needs JavaScript.

Start x₀

Step: x₁ = 2 − 2/4 = 1.5

Here f(x) = x² − 2. Newton's method replaces the curve by its tangent line at the current guess and moves to where that line meets the axis. Then it repeats from the new point.

Exact definition

One step. Let \(f\) be differentiable, and let \(x_k\) be a number with \(f'(x_k) \ne 0\). The tangent line at \(x_k\) is \(y = f(x_k) + f'(x_k)(x - x_k)\). It meets the axis \(y = 0\) at

\[x_{k+1} = x_k - \frac{f(x_k)}{f'(x_k)}.\]

Newton's method. Start at a number \(x_0\), and repeat the step for \(k = 0, 1, 2, \dots\) as long as \(f'(x_k) \ne 0\). The map \(N(x) = x - f(x)/f'(x)\) is the Newton map, so \(x_{k+1} = N(x_k)\). A root \(r\) of \(f\) with \(f'(r) \ne 0\) satisfies \(N(r) = r\), so the method stays at such a root once it lands on it.

Count the correct decimal places

Figure: the parabola near √2, a dotted line at √2, a dashed line at the guess x, and a shaded band of numbers within 0.5 × 10⁻ᵈ of √2. It needs JavaScript.

Guess x

x = 1.4: |x − √2| ≈ 0.0142

1 correct decimal place: |x − √2| ≤ 0.5 × 10⁻¹, but not ≤ 0.5 × 10⁻².

The error of a guess x is its distance to the root. This page counts x as having d correct decimal places when that distance is at most 0.5 × 10⁻ᵈ. Each tap zooms in on the shaded band of such numbers.

Exact definition

Error. For a guess \(x_k\) of a root \(r\), the error is \(e_k = x_k - r\), and its size is \(|e_k|\).

Correct decimal places. On this page, \(x_k\) has \(d\) correct decimal places when \(d\) is the largest whole number \(d \ge 0\) with \(|e_k| \le 0.5 \times 10^{-d}\). If \(|e_k| \gt 0.5\), the count is 0.

Fine print: names and scope

Newton's method is also called the Newton–Raphson method. This page treats one equation \(f(x) = 0\) in one unknown. For a system of equations the same idea uses the matrix of partial derivatives in place of \(f'\); that version is not treated here.

The method needs the derivative \(f'\), but no bracket: unlike bisection, nothing keeps the iterates close to a root.

1 See

Hunt for starts that make Newton fail

The iterates from your start. Every value is rounded: xk to 6 decimal places, the error |xk − r| to 3 significant digits. Places: the count of correct decimal places. ⋯ marks skipped steps.
kxk|xk − r|Places
How the page decides

The page runs up to 50 Newton steps from \(x_0\) and stops at the first of these events. Root: an iterate within \(10^{-12}\) of the root. Trapped (only for \(x^3 - 2x + 2\)): an iterate lands in a small interval from which, as the summary after the goals proves, Newton can never reach the root. Run off: an iterate larger than \(10^6\) in size. If none happens in 50 steps, the page gives no verdict.

For \(x^3 - 2x + 2\) the page computes with 100 decimal digits, because a start that wanders for many steps would otherwise end with iterates whose last digits depend on rounding. For \(\arctan x\) it uses floating point, with a series for the step near 0. A summary of why each verdict holds opens after the four goals.

2 Try

Count the digits at other roots

A prediction first. The explorer below it opens once it is answered.

The explorer and its goals open after you answer the prediction.

One more function

3 Prove

Why the error is squared

Theorem

Assumptions. \(f\) is twice continuously differentiable on \(I = [r - \delta, r + \delta]\) with \(\delta \gt 0\), and \(f(r) = 0\). There are numbers \(m \gt 0\) and \(M \gt 0\) with \(|f'(x)| \ge m\) and \(|f''(x)| \le M\) for every \(x\) in \(I\). Let \(C = M/(2m)\).

Conclusion. If \(x_0\) lies in \(I\) and \(C|x_0 - r| \lt \tfrac{1}{2}\), then every Newton iterate \(x_k\) is defined and lies in \(I\), and the errors \(e_k = x_k - r\) satisfy

\[|e_{k+1}| \le Ce_k^2\]

for every \(k \ge 0\). In particular \(C|e_k| \le (C|e_0|)^{2^k}\), so \(x_k \to r\).

When it applies. If \(f\) is twice continuously differentiable near a root \(r\) with \(f'(r) \ne 0\), such \(\delta\), \(m\) and \(M\) exist: by continuity \(|f'(x)| \ge \tfrac{1}{2}|f'(r)|\) on a short enough interval around \(r\), and \(|f''|\) is bounded there. So every start close enough to a simple root gets this speed.

Facts the proof uses.

  • Taylor's theorem with the Lagrange remainder, from the lesson on Taylor polynomials: for \(a\) and \(x\) in \(I\) there is a \(\xi\) between \(a\) and \(x\) with \[\begin{aligned} f(x) &= f(a) + f'(a)(x - a) \\ &\quad + \tfrac{1}{2}f''(\xi)(x - a)^2; \end{aligned}\]
  • \(f'\) is continuous and never 0 on \(I\), so it keeps one sign there; then \(f\) is strictly monotone on \(I\), and \(r\) is its only root in \(I\);
  • ordinary algebra and the rules for absolute values.

Fix a step \(k\) with \(x_k\) in \(I\) and \(C|e_k| \lt \tfrac{1}{2}\). If \(e_k = 0\), then \(x_k = r\), \(f(x_k) = 0\) and \(x_{k+1} = r\), so the bound holds. From here on \(e_k \ne 0\). Then \(f(x_k) \ne 0\), since \(r\) is the only root in \(I\), and \(f'(x_k) \ne 0\), since \(|f'(x_k)| \ge m\).

Each option is one step about this \(k\). Pick the one that is true for every function and every \(x_k\) the setup allows, with \(e_k \ne 0\) and \(C|e_k| \lt \tfrac{1}{2}\).

What else follows
  • Digits double. Line 5 gives \(C|e_{k+1}| \le (C|e_k|)^2\) at every step, so \(C|e_k| \le (C|e_0|)^{2^k}\). If \(C|e_k| \le 10^{-j}\), then \(C|e_{k+1}| \le 10^{-2j}\): the exponent in this bound at least doubles at each step, so the correct decimal places of \(x_k\) roughly double once \(e_k\) is small.
  • The exact constant. Line 3 gives \(e_{k+1}/e_k^2 = f''(\xi_k)/(2f'(x_k))\) whenever \(e_k \ne 0\). As \(x_k \to r\), \(\xi_k \to r\) too, so the ratio tends to \(f''(r)/(2f'(r))\). When \(f''(r) = 0\), as for \(\arctan x\) at 0, the error shrinks even faster than squaring.
  • Where the assumptions fail. At a double root \(f'(r) = 0\), so no \(m \gt 0\) works next to \(r\); stage 2 showed the speed drop to halving. For \(\sqrt[3]{x}\), \(f\) is not differentiable at the root. And a start with \(C|e_0| \ge \tfrac{1}{2}\) is not covered at all: stage 1 showed what can happen then.
4 Apply

Problems

Each problem has hints and a full solution. Exact answers can be typed as a decimal or a fraction.

Key point One Newton step is \(x_{k+1} = x_k - f(x_k)/f'(x_k)\). Near a simple root, with \(f'\) away from 0 and \(f''\) bounded, the error obeys \(|e_{k+1}| \le Ce_k^2\), so a few steps give many digits. At a repeated root that speed drops to a fixed ratio, and from a poor start Newton can fail altogether. When a sign change is known, a bracketing method such as bisection is the safer first step.
Level Intro Prerequisites Taylor polynomials and bisection; tangent lines and derivatives (refreshed in Before you start) Time ~35 min

Related: numerical integration is another place where the error of a method shrinks like a power, there of the grid spacing; floating point explains why a computed root can only be as accurate as the arithmetic.

Further reading