Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

Newton's Method Calculator

How to use
  1. Type the function whose root you want in the f(x)f(x) box. To solve an equation, move everything to one side first: for x2=2x^2 = 2 type x^2 - 2. Learn more about running the method
  2. Type a first guess in Starting guess x₀, and the number of steps (1 to 10) in Steps.
  3. Read the last guess under After n steps, how close ff is to 00 there, and the verdict. Learn more about reading the answer
  4. How it was found lists every step with its numbers, so you can follow or check a calculation done by hand.
  5. On the graph each amber line is a tangent followed down to the xx-axis, and each dashed line goes back up to the curve for the next step.

Newton's method
After 5 steps
x5≈1.414214\displaystyle x_{5} \approx 1.414214
How close to a root
f(x5)≈4.4×10−16\displaystyle f(x_{5}) \approx 4.4 \times 10^{-16}
Verdict
settled on a root\displaystyle \text{settled on a root}
How it was found

Newton's method improves a guess by following the tangent down to the xx-axis: xk+1=xk−f(xk)f′(xk)x_{k+1} = x_k - \dfrac{f(x_k)}{f'(x_k)}, with f(x)=x2−2f(x) = {x}^{2}-2 and f′(x)=2xf'(x) = 2 x.

x1=2−24=1.5x_{1} = 2 - \dfrac{2}{4} = 1.5

x2=1.5−0.253=1.416667x_{2} = 1.5 - \dfrac{0.25}{3} = 1.416667

x3=1.416667−0.0069442.833333=1.414216x_{3} = 1.416667 - \dfrac{0.006944}{2.833333} = 1.414216

x4=1.414216−6.0×10−62.828431=1.414214x_{4} = 1.414216 - \dfrac{6.0 \times 10^{-6}}{2.828431} = 1.414214

x5=1.414214−4.5×10−122.828427=1.414214x_{5} = 1.414214 - \dfrac{4.5 \times 10^{-12}}{2.828427} = 1.414214

The last steps no longer change the guess and ff is practically 00 there: the root is x≈1.414214x \approx 1.414214. Once a guess is close, each step roughly doubles the number of correct digits.

f(x)=x2−2f\left(x\right)={x}^{2}-2


Running Newton's method

DemoRun Newton's method
Step 0 of 4
Newton's method finds a root of a function: an xx where f(x)=0f(x) = 0. Type the function in the f(x)f(x) box, a first guess in Starting guess x₀, and how many steps to take in Steps.

To solve an equation, write it as "something =0= 0". For x2=2x^2 = 2 type x^2 - 2; for cos⁡(x)=x\cos(x) = x type cos(x) - x.

The guess should be reasonably near the root you are after. If you have no idea where the roots are, look at the graph first: they are where the curve crosses the xx-axis.

The number of steps can be anything from 11 to 1010. The calculator stops early if a guess hits a root exactly.

Reading the answer

  • After n steps is the latest guess, xnx_n, with six decimals.
  • How close to a root is f(xn)f(x_n). The closer to 00, the better the guess. Very small numbers are written like 4.4×10−164.4 \times 10^{-16}.
  • Verdict is one of: settled on a root (the guess has stopped changing and ff is practically 00 there), not settled yet (ask for more steps), moving away from the root, or a reason why the method stopped.

  • How it was found writes out every step, xk+1=xk−f(xk)f′(xk)x_{k+1} = x_k - \dfrac{f(x_k)}{f'(x_k)}, with the numbers filled in.

    On the graph, the hollow dots on the curve are the guesses x0x_0, x1x_1, x2x_2, and the filled dot on the axis is where the method has arrived.

How Newton's method works

Start at a guess x0x_0. Go up to the curve at (x0, f(x0))(x_0,\ f(x_0)), draw the tangent line there, and follow it down to the xx-axis. Where it lands is the next guess, x1x_1. Repeat.

The idea is that near a point a curve looks like its tangent line, and finding where a line crosses the axis is easy.

The tangent at xkx_k is y=f(xk)+f′(xk)(x−xk)y = f(x_k) + f'(x_k)(x - x_k). Setting y=0y = 0 and solving for xx gives the formula of the method:

xk+1=xk−f(xk)f′(xk)x_{k+1} = x_k - \frac{f(x_k)}{f'(x_k)}


For f(x)=x2−2f(x) = x^2 - 2 and x0=2x_0 = 2: f(2)=2f(2) = 2, f′(2)=4f'(2) = 4, so x1=2−24=1.5x_1 = 2 - \dfrac{2}{4} = 1.5.
One step for x2−2x^2 - 2: the tangent at x0=2x_0 = 2 meets the axis at x1=1.5x_1 = 1.5.

A worked example

Approximate 2\sqrt{2}, the positive root of f(x)=x2−2f(x) = x^2 - 2, with f′(x)=2xf'(x) = 2x and x0=2x_0 = 2.

1. x1=2−24=1.5x_1 = 2 - \dfrac{2}{4} = 1.5
2. x2=1.5−0.253=1.416667x_2 = 1.5 - \dfrac{0.25}{3} = 1.416667
3. x3=1.416667−0.0069442.833333=1.414216x_3 = 1.416667 - \dfrac{0.006944}{2.833333} = 1.414216
4. x4=1.414216−0.0000062.828431=1.414214x_4 = 1.414216 - \dfrac{0.000006}{2.828431} = 1.414214

The true value is 2=1.41421356…\sqrt{2} = 1.41421356\ldots After four steps the first six decimals are already right.

In practice you stop when two guesses in a row agree to as many decimals as you need.

How fast it closes in

When the start is good, Newton's method is very fast. The error is roughly squared at every step, which means the number of correct digits about doubles each time: 11, 22, 44, 88, and so on. This is called quadratic convergence.

In the example above the errors are about 0.090.09, 0.0020.002, 0.0000020.000002 and then far below anything six decimals can show.

The exception is a root where the graph only touches the axis, such as x2x^2 at 00. There f′f' is 00 at the root as well, and the method still works but only halves the error each step.

When the method fails

DemoStarts that go wrong
Step 0 of 4
    Newton's method is not guaranteed to work. The calculator recognises the usual ways it goes wrong.

  • A level tangent. If f′(xk)=0f'(x_k) = 0 the tangent never meets the axis and the formula divides by zero. x3−3xx^3 - 3x from x0=1x_0 = 1 stops at once. A nearly level tangent throws the next guess far away.
  • Leaving the domain. For ln⁡(x)\ln(x) from x0=3x_0 = 3 the first step lands at a negative number, where the function has no value.
  • Moving away. For x3\sqrt[3]{x} each guess is twice as far from the root as the one before, with the opposite sign, from any start.
  • Going round in circles. Some starts bounce between the same few values for ever.

  • The cure is almost always a better starting guess, chosen from the graph.
x3−3xx^3 - 3x at x0=1x_0 = 1: a level tangent never reaches the axis.
x3\sqrt[3]{x}: each tangent lands twice as far from the root, on the other side.

Which root it finds

A function can have several roots, and the method finds one of them. Which one depends on the start.

f(x)=x3−3xf(x) = x^3 - 3x has roots at −3-\sqrt{3}, 00 and 3\sqrt{3}. From x0=2x_0 = 2 the method settles on 1.7320511.732051; from x0=−2x_0 = -2 on −1.732051-1.732051; from x0=0.5x_0 = 0.5 on 00.

A start close to a root usually leads to that root. Starts near a peak or a valley, where the tangent is nearly level, can land almost anywhere. To find every root, run the method from several starts, one near each crossing you see on the graph.
x3−3xx^3 - 3x has three roots; the start decides which one is found.

Where it is used

    Most equations cannot be solved exactly. cos⁡(x)=x\cos(x) = x has no solution in terms of familiar functions, yet five steps from x0=1x_0 = 1 give 0.7390850.739085.

    Newton's method, also called the Newton-Raphson method, is the standard tool for such equations:

  • square roots and other roots: applied to x2−ax^2 - a, it gives the rule xk+1=12(xk+axk)x_{k+1} = \dfrac{1}{2}\left(x_k + \dfrac{a}{x_k}\right) for a\sqrt{a};
  • finding where a derivative is zero, for maxima and minima;
  • solving for interest rates, break-even points and equilibrium values, where the unknown sits inside a formula that cannot be turned around.

  • Calculators and computers use this method, or close relatives of it, behind the scenes.

Common mistakes

  • Not writing the equation as f(x)=0f(x) = 0. For x3=2x+5x^3 = 2x + 5 the function is x3−2x−5x^3 - 2x - 5.
  • Adding instead of subtracting. The formula is xkx_k minus f(xk)f′(xk)\dfrac{f(x_k)}{f'(x_k)}.
  • Turning the fraction upside down. It is ff over f′f'.
  • Rounding too early. Keep extra decimals during the steps; round at the end.
  • Using degrees. Trigonometric functions in calculus use radians.
  • Stopping after a fixed number of steps without looking. Check that the guesses have stopped changing and that ff is close to 00.