Newton's Method for Finding Roots and How It Can Fail
Learn the tangent-line iteration that solves equations quickly, why it is so fast, and the ways it goes wrong.
Key takeaways
- The iteration is xₙ₊₁ = xₙ − f(xₙ)/f′(xₙ), where xₙ is the current guess.
- Near a simple root with a good starting value, the number of correct digits roughly doubles at each step.
- It fails or misbehaves when the derivative is zero or tiny, when the start is poor, or when the graph has awkward shape.
- At a repeated root it still can converge, but only slowly.
- Practical software combines it with safer bracketing methods and sensible stopping rules.
Newton's method solves an equation f(x) = 0 by guessing, drawing the tangent line to the graph at the guess, and using the point where that line crosses the horizontal axis as the next guess. Repeating this often homes in on a root with startling speed.
The same method can also stall, bounce forever between two values, run off to infinity or arrive at a root you did not want. Knowing why helps you use it safely.
Where the formula comes from
Suppose your current guess is xₙ. The tangent line to y = f(x) there has equation:
y = f(xₙ) + f′(xₙ) (x − xₙ) The tangent is the best straight-line stand-in for the curve nearby, the idea behind linear approximation. Solving for where the line hits y = 0 is easy:
0 = f(xₙ) + f′(xₙ) (x − xₙ)
x = xₙ − f(xₙ)/f′(xₙ) provided f′(xₙ) ≠ 0 That x becomes xₙ₊₁. You then repeat. A process that feeds its output back in as the next input is called an iteration.
Computing a square root
To find √2, solve f(x) = x² − 2 = 0. Since f′(x) = 2x, the formula simplifies:
xₙ₊₁ = xₙ − (xₙ² − 2)/(2xₙ) = (xₙ + 2/xₙ)/2 Each new guess is the average of the old guess and 2 divided by it. This rule for square roots was known long before calculus and is often called the Babylonian method.
| Step | Guess | Approximate error |
|---|---|---|
| 0 | 1 | 0.41 |
| 1 | 1.5 | 0.086 |
| 2 | 1.4166667 | 0.0025 |
| 3 | 1.4142157 | 0.0000021 |
| 4 | 1.4142135624 | 0.0000000000016 |
Four steps from a crude start give about eleven correct decimal places.
A cubic with no easy formula
A classic example, used by Newton himself, is x³ − 2x − 5 = 0. At x = 2 the left side is −1, and at x = 3 it is 16, so the intermediate value theorem guarantees a root between them, near 2.
f′(x) = 3x² − 2
x₀ = 2: f = −1, f′ = 10 x₁ = 2.1
x₁ = 2.1: f = 0.061, f′ = 11.23 x₂ ≈ 2.094568
x₂: one more step gives x₃ ≈ 2.094551 Although there is an algebraic formula for cubics, it is clumsy to use, and for general polynomials of degree five or higher no formula in radicals exists. Iterative methods are how such equations are solved in practice. Joseph Raphson published a version of the method in 1690, and it is often called the Newton-Raphson method.
An equation algebra cannot rearrange
Where does cos x equal x, with x in radians? No amount of algebra isolates x. Set f(x) = cos x − x, with f′(x) = −sin x − 1, and start at 1.
x₀ = 1
x₁ ≈ 0.750364
x₂ ≈ 0.739113
x₃ ≈ 0.739085 By the third step the first six decimals have settled. The slope −sin x − 1 stays well away from zero near the root, which is part of why the run is so well behaved. You can confirm the answer by pressing the cosine key on 0.739085 and seeing nearly the same number come back.
Dividing without dividing
Newton's method can even compute reciprocals using only multiplication and subtraction. To find 1/a for a > 0, solve f(x) = 1/x − a = 0. Since f′(x) = −1/x², the formula simplifies to:
xₙ₊₁ = xₙ (2 − a · xₙ) For a = 7 and a first guess of 0.1, the guesses are 0.13, then 0.1417, then about 0.142848, then about 0.14285714, closing in on 1/7.
This example shows quadratic convergence exactly. If you define the relative error as rₙ = 1 − a · xₙ, then a line of algebra gives rₙ₊₁ = rₙ². Here the errors are 0.3, 0.09, 0.0081 and 0.00006561. It also shows precisely which starts work: the errors shrink only if the size of r₀ is less than 1, meaning 0 < x₀ < 2/a. Start at 0.3 with a = 7 and the first error is −1.1, whose squares grow without bound. Variations of this iteration have been used inside computer arithmetic to carry out division.
Why it is so fast
Write eₙ for the error, the difference between xₙ and the true root r. If f has a continuous second derivative and f′(r) ≠ 0, then close to the root:
eₙ₊₁ ≈ [f″(r) / (2 f′(r))] · eₙ² The new error is proportional to the square of the old one. This is called quadratic convergence. If the constant is near 1 and the error is 0.001, the next is about 0.000001 and the one after about 0.000000000001.
For x² − 2, the constant is 1/(2√2), about 0.354. From step 1 to step 2, 0.354 × 0.086² ≈ 0.0026, which matches the table.
The statement is local. It promises nothing if you start far away.
Failure by flat tangents
If f′(xₙ) = 0, the tangent is horizontal and never meets the axis (unless you are already at a root). For x² − 2, starting at 0 halts the method immediately.
A slope that is merely small is also trouble. Starting x² − 2 at 0.01 throws the next guess to about 100. In this example the method then works its way back, roughly halving at each step until it gets close. In other examples a wild leap lands near a completely different root, or in a region it never leaves.
Failure by cycling and divergence
For f(x) = x³ − 2x + 2, start at x₀ = 0.
f(0) = 2, f′(0) = −2 gives x₁ = 1
f(1) = 1, f′(1) = 1 gives x₂ = 0 The guesses alternate between 0 and 1 forever. The function does have a real root, but it is negative, and starting near −2 finds it quickly.
Divergence is even more dramatic for f(x) = x^(1/3), the real cube root, whose only root is 0. The formula reduces to xₙ₊₁ = xₙ − 3xₙ = −2xₙ. Every step lands on the other side, twice as far away. The vertical tangent at the root violates the conditions for fast convergence.
The arctangent function offers a subtler case. It has a single root at 0 and a smooth graph with positive slope everywhere. Start close and the method converges rapidly. Start farther than about 1.39 from zero and the guesses swing outward without limit, because the flattening tails produce ever longer tangents.
Slow convergence and the wrong root
At a repeated root, where f and f′ are both zero, convergence weakens. For f(x) = x², the formula gives xₙ₊₁ = xₙ/2. The method reaches the root only by halving, gaining roughly one decimal digit every three or so steps. If you know the root has multiplicity m, using xₙ − m f(xₙ)/f′(xₙ) restores the speed.
When there are several roots, the one you reach depends on the starting point, sometimes very sensitively. Applied to z³ = 1 in the complex plane, which has three solutions, the sets of starting points leading to each root are separated by an infinitely intricate fractal boundary. Near that boundary, a tiny change of start can change the destination.
A start that cannot go wrong
There is one friendly situation in which you can be sure of success. Suppose f has a root r, and for every x ≥ r the function is increasing and its graph bends upward (f′ > 0 and f″ ≥ 0, with f′ still positive at r). Start anywhere to the right of r.
A graph that bends upward lies on or above each of its tangent lines. So where the tangent reaches zero, the curve is still at or above zero, which means the next guess has not passed the root. And since f is positive to the right of r with positive slope, the step moves left. The guesses therefore decrease steadily and stay on the right side of r, and they converge to it.
The square root iteration is an example. For x² − 2 with a positive start below √2, the first step jumps above the root, and from then on the guesses slide down toward it, just as the table shows. Similar statements hold for the other combinations of increasing or decreasing and bending up or down, with the safe side changing accordingly. Checking the signs of f′ and f″ near a root is a cheap way to pick a reliable start.
Using it safely
Good habits avoid most trouble.
- Sketch or tabulate the function first to locate a sign change.
- Start close to the root you want.
- Watch whether the size of f(x) decreases; if not, take a shorter step or restart.
- Keep a bracketing interval, and fall back on bisection (halving the interval and keeping the half with the sign change) when a step jumps outside.
- Stop when both the change in x and the size of f(x) are acceptably small, and cap the number of steps.
A small value of f alone can mislead if the graph is very flat, and a small step alone can mislead if the method is stalling.
Relatives of the method
When a derivative is expensive or unavailable, the secant method replaces the tangent with a line through the two most recent points. It converges somewhat more slowly per step but needs only one new function value each time.
For systems of several equations, the derivative becomes a matrix of partial derivatives, called the Jacobian, and each step solves a linear system. Applied to the derivative of a function, the method searches for critical points, a close cousin of gradient descent that uses curvature as well as slope.
Try it with a spreadsheet: put a starting guess in one cell, the update formula in the next, and copy downward. Then change the start and watch which of the behaviors above you can reproduce.