Newton's Method
calculator.
Find where f(x) reaches 0 by following tangent lines down from a starting guess.
To solve g(x) = h(x), enter g(x) − h(x).
- Steps taken
- 4
- Last step size
- 4.44 × 10⁻¹⁶
- Observed order
- 1.99
The number of correct digits about doubled at each step near the end, which is the quadratic convergence you expect at a simple root.
Tangent steps toward the root
Drag the point to change x₀The curve y = cos(x) - x with Newton's path. From each xₙ go up to the curve, then follow the tangent line down to the x-axis to get xₙ₊₁. The path ends at the root x ≈ 0.739085133215.
Working
- 1Follow the tangent line at xₙ down to the x-axisxₙ₊₁ = xₙ −f(xₙ)f′(xₙ), with f′(x) = −sin(x) − 1
- 2Step 1: from x₀0.785398163397 −−0.078291−1.707107= 0.739536133515
- 3Step 2: from x₁0.739536133515 −−0.000755−1.673945= 0.739085178106
- 4Step 3: from x₂0.739085178106 −−7.51 × 10⁻⁸−1.673612= 0.739085133215
- 5Step 4: from x₃0.739085133215 −below 10⁻¹²−1.673612= 0.739085133215
- 6Check: put the root back into ff(0.739085133215) is below 10⁻¹²
- 7Check: f changes sign across the rootf(root − 0.001) = 0.001673 and f(root + 0.001) = −0.001674
Iterations
| n | xₙ | f(xₙ) | f′(xₙ) | xₙ₊₁ | Step size |
|---|---|---|---|---|---|
| 0 | 0.785398163397f(xₙ) −0.078291f′(xₙ) −1.707107xₙ₊₁ 0.739536133515 | −0.078291 | −1.707107 | 0.739536133515 | 0.045862 |
| 1 | 0.739536133515f(xₙ) −0.000755f′(xₙ) −1.673945xₙ₊₁ 0.739085178106 | −0.000755 | −1.673945 | 0.739085178106 | 0.000451 |
| 2 | 0.739085178106f(xₙ) −7.51 × 10⁻⁸f′(xₙ) −1.673612xₙ₊₁ 0.739085133215 | −7.51 × 10⁻⁸ | −1.673612 | 0.739085133215 | 4.49 × 10⁻⁸ |
| 3 | 0.739085133215f(xₙ) below 10⁻¹²f′(xₙ) −1.673612xₙ₊₁ 0.739085133215 | below 10⁻¹² | −1.673612 | 0.739085133215 | 4.44 × 10⁻¹⁶ |
Same f, other starts
| Start at | Ends at | Steps |
|---|---|---|
| −3.214602 | Not settled yet | 30 |
| −1.214602 | Not settled yet | 30 |
| −0.214602 | 0.739085 | 5 |
| 0.285398 | 0.739085 | 5 |
| 0.535398 | 0.739085 | 4 |
| 0.785398 | 0.739085 | 4 |
| 1.035398 | 0.739085 | 4 |
| 1.285398 | 0.739085 | 4 |
| 1.785398 | 0.739085 | 4 |
| 2.785398 | 0.739085 | 6 |
| 4.785398 | Ran away | 9 |
Each row runs the same method from a nearby start, so you can see which root it reaches and where it fails.
Stopping rule
How it's worked out
Newton's method, also called Newton-Raphson, replaces a curve with its tangent line. The tangent is easy to solve, so you jump to where it crosses the x-axis, and that crossing becomes your next guess. Repeat it until the guesses stop moving.
The formula comes straight from the tangent line. At the line has height and slope . Set its height to 0, solve for x, and you get the step above. The tool differentiates your formula with exact rules, so each slope is as good as the arithmetic allows.
To solve an equation with something on both sides, move it all to one side first. For cos x = x you enter cos x − x. The search stops when a step is smaller than your tolerance, scaled by the size of x once x is above 1. It also stops at the step limit, on a flat tangent, on a repeat of an earlier value, or when the values run away.
Near a simple root, the error is roughly squared at each step, so the number of correct digits about doubles. That is called quadratic convergence, and a simple root is one where the slope is not 0. The observed order is measured from your last three step sizes.
Worked examples
Priya works out the square root of 2 by hand
Priya wants √2 with no square root key. She solves x² − 2 = 0 from x₀ = 1. The first steps give 1.5, 1.4166666667, 1.4142156863, 1.4142135624.
The step sizes are 0.5, 0.083333, 0.002451, 0.000002. You can watch the correct digits double, and the search settles after 6 steps at 1.41421356237.
Lena finds all three crossings of a cubic
Lena has f(x) = x³ − 3x + 1 from her textbook. A sketch shows a crossing between 1 and 2, so she starts at 2. The guesses run 1.666666667, 1.548611111, 1.532390162, 1.532088989, and they settle at 1.532088886.
One start finds one root. From 0 she reaches 0.347296, and from −2 she reaches −1.879385. That gives her all three, since a cubic has at most three real roots.
Ben hits a start that loops forever
Ben tries x³ − 2x + 2 from 0. The values go 0, 1, 0, 1 and then repeat, so the tool reports a cycle and gives no root.
The function does have a real root, and a better start finds it. From −2 the method settles at −1.769292 in 5 steps. When you hit a loop, change the start and do not raise the step limit.
Reading your result
The observed order. A figure near 2 means quadratic convergence at a simple root. Near 1 means slow, steady progress, which points to a repeated root. Near 3 can happen when the second derivative is also 0 at the root, as it is for arctan x at 0.
A repeated root. With , one step removes exactly of the distance to r. So (x − 1)² only halves the gap each time, and it takes 40 steps from 2. The tool estimates the multiplicity m, here 2, and you can multiply each step by m to bring the speed back. That is more than the default limit of 30 steps, so raise the limit for a root like this.
The last step size. Once steps are tiny, the size of the last one is a good cap on the remaining error at a simple root. The check in the working then puts the root back into f and looks at the sign either side. A sign change shows a true crossing. No change means the curve only touches the axis.
Common mistakes
- Starting too far out on a curve that flattens. For arctan x the root is 0. From 1.3 the method reaches 0, but from 1.5 each tangent overshoots further: 1.5, −1.69, 2.32, −5.11, and then it runs away.
- Starting at a turning point. There the tangent is flat and never meets the axis, and the formula would divide by 0. Move the start a little to either side.
- Assuming you got the root you wanted. With several roots, a start can jump past the nearest one. The table of other starts shows which root each one reaches.
- Entering an equation without moving everything to one side. The method finds where f is 0, so g(x) = h(x) must go in as g(x) − h(x).