Newton-Raphson Root Finder for x³ − ax − b (Iterates, Residual & Convergence)

Compute Newton-Raphson root iterations x_{k+1} = x_k − (x_k³ − a·x_k − b)/(3x_k² − a).

Converged Root x* (After 6 Iterations) 2.095 x*
Derivative Slope f′(x*) at Root 11.161 slope
Verification x*³ (Equals a·x* + b) 9.189 x³
Absolute Residual |f(x*)| 0 error
Inputs
Try:
a
Coefficient a in x³ − a·x − b = 0.
b
Constant b in x³ − a·x − b = 0.
x₀
Starting guess x₀.
iterations
Number of Newton-Raphson iterations to run.
Results & Graph
Converged Root x* (After 6 Iterations)
2.095 x*
Derivative Slope f′(x*) at Root
11.161 slope
Verification x*³ (Equals a·x* + b)
9.189 x³
Absolute Residual |f(x*)|
0 error

Converged Root x* (After 6 Iterations)

Graph 1 • How the inputs feed Newton-Raphson Root Solver
Newton-Raphson Quadratic Convergence Root-Finder (x³ − a·x − b = 0) Calculator • Custom Domain Schematic (Numerical Analysis & Calculus) coeffLinconstantNewton-Raphson Root So Coeff Linear A: 2 a • Constant Term B: 5 b CONVERGED ROOT X* (AFTER 6 2.095 x* • Derivative Slope f′(x*: 11.161 slope • Verification x*³ (Equa: 9.189 x³ Eq: x_{n+1} = x_n − f(x_n) / f′(x_n)
Graph 2 • Converged Root x* (After 6 Iterations) as Coeff Linear A changes (40% to 160% of current)
0 x* 1.27 x* 2.55 x* 1.86 0.800a 1.94 1.20a 2.02 1.60a 2.10 2a 2.17 2.40a 2.24 2.80a 2.31 3.20a
Graph 3 • Coeff Linear A and Constant Term B together Compares Converged Root x* (After 6 Iterations) when Constant Term B is shifted +25% (solid) vs. −25% (dashed).
0 x* 1.27 x* 2.54 x* --- Constant Term B @ 75% 2.09 -30% 2.15 -15% 2.20 +0% 2.25 +15% 2.31 +30%
Summary: Solving x³ − 2x − 5 = 0 from x₀=2 converges to x = 2.094551 with residual |f(x)| = 8.88e-16.
Summary: Solving x³ − 2x − 5 = 0 from x₀=2 converges to x = 2.094551 with residual |f(x)| = 8.88e-16.
Interactive chart & math engine powered by CalculatorGraph

Formula: Newton-Raphson Root Solver Formula

xn+1 = xn − f(xn) / f′(xn), where f(x) = x³ − a·x − b and f′(x) = 3x² − a
x_{n+1} = x_n − f(x_n) / f′(x_n), where f(x) = x³ − a·x − b and f′(x) = 3x² − a
  • coeffLinearA: Coeff Linear A (a)
  • constantTermB: Constant Term B (b)
  • initialGuessX0: Initial Guess X0 (x₀)
  • iterationsCount: Iterations Count (iterations)

Frequently Asked Questions

How does the Newton-Raphson Quadratic Convergence Root-Finder (x³ − a·x − b = 0) Calculator compute the solution?

It evaluates x_{n+1} = x_n − f(x_n) / f′(x_n), where f(x) = x³ − a·x − b and f′(x) = 3x² − a directly in your browser and updates three custom SVG visualizations in real time.

How many iterations does the default equation really need?

Four. Running the engine at 1, 2, 3 and 4 iterations gives residuals of 0.061, 1.86e-4, 1.74e-9 and then 8.88e-16, the limit of double precision. Iterations five and six change nothing. For other equations or starting points, increase the count until the residual in the sentence stops shrinking. That pattern of rapid collapse is typical whenever the start is close to a simple root.

What does a Not Yet Converged headline mean?

It means the iterations you asked for ran out before the residual became negligible. From x0 = 0 with six iterations, the default stops at x = −1.608 with residual 5.942. The sentence suggests the two fixes: add iterations, up to 50, or pick a starting guess closer to where the curve crosses zero. From 0, 25 iterations reach the root.

Why does the residual on the card show 0 after only two iterations?

The card rounds to three decimal places. After two iterations the true residual is about 1.86e-4, which rounds to 0.000. The headline says Not Yet Converged at that point, and the sentence under the result gives the residual in scientific notation. Use those to judge accuracy, because the rounded card hides everything below about half a thousandth.

Can I solve a cubic with an x squared term?

Not directly. The engine only handles x³ − a·x − b, a depressed cubic with no x² term. Any cubic x³ + px² + qx + r can be converted to that form by substituting x = t − p/3, which removes the squared term. Solve for t here, then subtract p/3 to get back to x. The substitution keeps every root, so nothing is lost.

What does the derivative slope line tell me?

It is f′(x*) = 3x*² − a at the answer. At the default it is 11.161. A slope well away from zero means the root is simple and Newton converged quadratically. A slope near zero warns of a repeated root or a nearly flat crossing, where convergence is slow and small errors in x* matter more. At a flat spot the slope line reads exactly 0 and the headline says Stopped.

Is the secant method ever better than Newton for this kind of equation?

For this cubic, rarely, because f′ = 3x² − a is cheap to compute. The secant method shines when the derivative is costly or unknown. It needs one new function value per step against Newton's two, and with an order of about 1.618 it often reaches the same accuracy for less total work.

Why did a starting guess of 0 send the default off to a negative number?

At x = 0 the default derivative is 3 × 0 − 2 = −2, so the tangent slopes downward, and since f(0) = −5 the tangent crosses zero at −2.5. From there it takes many steps to come back. With six iterations the engine stops at −1.608 with residual 5.942; with 25 it finds 2.094551. Starting at 2 or 3 avoids the detour completely.

What is the iteration limit?

The count must be a whole number from 1 to 50. Zero, fractions or anything above 50 bring up a request to check the inputs. For a cubic with a sensible start, a handful of iterations is enough, and the default needs only four. If the residual is still large after 50, change the starting point rather than the count.

How can I find the root without a good starting guess?

Evaluate f at a few points and look for a sign change. For the default, f(2) is −1 and f(3) is 16, so a root lies between 2 and 3. Starting anywhere in that bracket converges quickly. Bisection on the bracket, then Newton from the midpoint, is a common robust combination. Any start between 2 and 3 reaches the root of the default within a handful of steps.

Does the method work with negative a or b?

Yes. The fields accept any real values. A negative a makes 3x² − a always positive, so the cubic has one real root and Newton cannot hit a flat spot. A negative b just moves the curve up. Check the residual as usual, since a poor start can still need extra iterations. Positive and negative values of a both work with the same three supporting lines.

Wallis's cubic: x cubed minus 2x minus 5 from x0 = 2

The default equation, x³ − 2x − 5 = 0, has a long history. It is the example Newton's method was famously demonstrated on, and it has one real root a little above 2. The calculator's fields give it as a = 2 and b = 5, so f(x) = x³ − a·x − b, with the starting guess x0 = 2 and six iterations.

After six steps the result is x* = 2.094551, shown on the card as 2.095. The sentence under the result reports a residual of 8.88e-16, which is as close to zero as double precision arithmetic allows. The supporting lines check the answer two ways: x* cubed is 9.189, which equals 2 × 2.094551 + 5, and the slope f′(x*) = 3x*² − 2 is 11.161.

Six iterations is more than this problem needs. I ran the engine with fewer. One step gives 2.1 with residual 0.061, and the headline says Not Yet Converged. Two give 2.094568 with residual 1.86e-4, still flagged as not converged. Three give 2.094551 with residual 1.74e-9, and from there the headline switches to Converged Root. Four already reach the 8.88e-16 floor, and the last two iterations change nothing.

So the default is a good showcase: a cubic with one real root, a starting point close to it and a derivative that stays well away from zero along the way. Every one of those conditions can fail on other inputs, and the rest of this guide is about what happens when they do.

The first step by hand: x1 = 2 − (−1)/10

The update rule is x_new = x − f(x)/f′(x). At the starting point, f(2) = 8 − 4 − 5 = −1 and f′(2) = 3 × 4 − 2 = 10. So x1 = 2 − (−1/10) = 2.1. That matches the one iteration run exactly.

Geometrically, the step draws the tangent line to the curve at x = 2 and slides down it to where it crosses zero. The curve is below the axis at 2, with a slope of 10, so the tangent hits zero one tenth to the right.

The second step uses x = 2.1. Here f(2.1) = 9.261 − 4.2 − 5 = 0.061 and f′(2.1) = 13.23 − 2 = 11.23. Dividing gives 0.00543, so x2 = 2.1 − 0.00543 = 2.094568, again matching the engine. The first step overshot the root slightly and the second came back from the other side.

You can carry on in a spreadsheet with two columns, f and f′, and the third column x − f/f′. Doing a few steps by hand is the best way to see why the method is fast near a root and wild far from one.

Quadratic convergence in the error column

Measured against the true root, the errors after each step on the default are about 0.0945 at the start, then 0.00545, then 0.0000166, then 0.000000000156. Each error is roughly a constant times the square of the one before. That is what quadratic convergence means, and in practice the number of correct digits roughly doubles each step: about one, then two, then four, then nine.

The constant is f″(x*) divided by twice f′(x*). For this cubic, f″(x) = 6x, so at the root it is about 12.57, and twice the slope is about 22.32. The ratio, close to 0.56, is exactly what you get by dividing each error by the square of the previous one in the list above.

That neat behaviour holds only near a simple root, where f′ is not zero. At a repeated root, such as x³ = 0 or a cubic with a double root, f′ is zero at the root itself and Newton slows to linear convergence, gaining a fixed fraction of a digit per step instead of doubling.

The calculator does not show you the iteration history, only the final value. To see the pattern, run it with the iteration count set to 1, 2, 3 and 4 in turn, as I did, and write down the root each time.

The secant method on the same cubic, by hand

The calculator only runs Newton, but the secant method is easy to do by hand alongside it. Instead of the derivative, it uses the slope of the line through the last two points: x_new = x1 − f(x1)(x1 − x0)/(f(x1) − f(x0)).

Starting from x0 = 2 and x1 = 2.1, where f is −1 and 0.061, the slope of the chord is 1.061 divided by 0.1, about 10.61. The next point is 2.1 − 0.061/10.61, which is about 2.094251. The step after that gives 2.0945506, and the one after reaches 2.0945515, agreeing with Newton to ten digits.

The secant errors fall from 0.00545 to 0.0003, then to about 9.2e-7, then to about 1.6e-10. That is fast, but slower per step than Newton. The secant method's order of convergence is the golden ratio, about 1.618, rather than 2, so the number of correct digits grows by roughly 60% each step rather than doubling.

Each secant step needs only one new function value, while each Newton step needs both f and f′. If the derivative is expensive or unavailable, the secant method often reaches a given accuracy with less total work. For this cubic the derivative is trivial, so Newton wins.

Not Yet Converged and other headline warnings

The headline changes with the outcome. When the residual has collapsed it reads Converged Root. When the requested iterations run out before that, it reads Not Yet Converged and the sentence suggests adding iterations or picking a starting guess closer to the root. Either way, the residual in the sentence is the number that tells you how close you are.

Try the default equation with a starting guess of 0. The first step goes from 0 to −2.5, because the derivative at zero is −2 and the tangent points the wrong way. After six iterations the engine reports x = −1.608 with a residual of 5.942 and a Not Yet Converged headline. Raise the iteration count to 25 and it eventually finds 2.094551 and reports Converged Root.

A starting guess of 10 shows a milder version. After six iterations the answer is 2.096664 with residual 0.024, close but not done, and the headline says so. Ten iterations reach 2.094551.

The iteration count must be a whole number from 1 to 50; anything else brings up a request to check the inputs. For a cubic that is almost always plenty when the start is reasonable, and if 50 steps do not bring the residual down, the starting point is the problem, not the count.

Starting on a flat spot of the curve

Newton's method divides by f′(x). If the derivative is zero, the tangent is horizontal and never crosses the axis. For f(x) = x³ − a·x − b the derivative is 3x² − a, which is zero at x = ±√(a/3).

The engine handles this by stopping and saying so. With a = 3, b = 5 and x0 = 1, the derivative at the start is exactly zero, so no step is taken. The headline reads Stopped: f′(x) = 0 (Try a Different x₀), the value shown is just your starting guess of 1, the slope is 0 and the residual is 7. The sentence explains that Newton's step is undefined there.

Starting near a flat spot rather than exactly on one is almost as bad. The derivative is tiny, the step is enormous, and the next point lands far away. It may still find the root after many steps, or it may bounce. Moving x0 a little further from √(a/3) is usually enough.

If a is zero or negative, 3x² − a is never zero for real x apart from the special case a = 0 at x = 0, and the cubic is steadily increasing, with exactly one real root. With a = 0 and b = 2 the engine finds the cube root of 2, 1.259921, from a start of 1.

Three real roots and which one you get

When a is positive and large enough compared with b, the cubic has three real roots, and the one Newton finds depends on where you start. Take a = 3 and b = 1. Starting at 2 gives 1.879385. Starting at 0 gives −0.347296. Starting at −2 gives −1.532089. All three have residuals at machine precision.

The default and the presets do not have this property. With b = 5, the cubics for a = 1.2, 2 and 3 each have one real root, at 1.943, 2.095 and 2.279 respectively, all with residuals that display as 0. Raising a moves the root up, because the line a·x + b that the cubic must meet becomes steeper.

A quick test for how many real roots there are: three when 4a³ is greater than 27b², one when it is smaller. For a = 3 and b = 5, 4a³ is 4 × 27 while 27b² is 27 × 25, more than six times larger, so only one real root exists. For a = 3 and b = 1, 4a³ is still 4 × 27 but 27b² is just 27, so there are three.

If you need all three, run the calculator three times from starting points spread across the curve, one below −√(a/3), one between the two flat spots and one above √(a/3).

Reading the residual and the verification lines

The residual line shows |f(x*)| rounded to three decimals, so anything smaller than about 0.0005 displays as 0. After two iterations on the default the true residual is 1.86e-4, but the card still shows 0. The headline, which says Not Yet Converged at that point, and the sentence under the result, which writes the residual in scientific notation, are the figures to trust.

A residual of about 1e-15 or smaller means the answer is correct to the precision of the computer. A larger residual is not automatically bad; what matters is how it compares with the size of the terms. Dividing the residual by the slope gives a rough estimate of how far x* is from the true root.

The verification line, x* cubed, is meant to be compared by eye with a·x* + b. At the default, 9.189 against 2 × 2.095 + 5. Rounding in both makes this only a loose check, but a big mismatch is a clear sign the method did not reach a root.