Cubic Equation Calculator

Solve ax³ + bx² + cx + d = 0: all real and complex roots, the discriminant and whether the roots are distinct, repeated or complex.

Must not be 0, otherwise the equation is not cubic.

Results

Roots
x₁ = 1, x₂ = 2, x₃ = 3
x₁
1
x₂
2
x₃
3
Nature of the roots
Three distinct real roots.
Discriminant Δ
4
Δ > 0: three distinct real roots. Δ = 0: a repeated root. Δ < 0: one real root and two complex ones.
Depressed cubic t³ + pt + q = 0: p
-1
Substituting x = t − b/(3a) removes the x² term.
Depressed cubic: q
0

How it’s calculated

A cubic equation ax³ + bx² + cx + d = 0 always has three roots (counting repeats), which may be real or complex. The discriminant tells you which case you are in:

Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d²

The solver substitutes x = t − b/(3a) to get the depressed cubic t³ + pt + q = 0 with p = (3ac − b²)/(3a²) and q = (2b³ − 9abc + 27a²d)/(27a³). With one real root it uses Cardano's formula; with three real roots it uses the trigonometric form. Each real root is then refined by Newton's method on your original cubic, and the complex pair is found from the leftover quadratic.

Example: x³ − 6x² + 11x − 6 = 0. Δ = 4 > 0, so there are three real roots, and the polynomial factors as (x − 1)(x − 2)(x − 3): x = 1, 2, 3. By contrast x³ − 1 = 0 has Δ = −27, so one real root x = 1 and two complex roots −0.5 ± 0.866i.

Whole-number coefficients and decimals with up to 6 decimal places are converted to exact integers, so Δ and the nature of the roots are exact: (x − 100)(x − 101)(x − 102) is correctly three distinct roots, and (x − 0.1)²(x − 0.3) is correctly a double root. Coefficients with more decimal places already carry rounding, so two roots that agree to about one part in a million are then reported as a repeated root.

Frequently asked questions

What happens if a = 0?

The equation is no longer cubic. It is the quadratic bx² + cx + d = 0, so the calculator asks you to use the quadratic equation calculator instead.

Can a cubic have no real roots?

No. A cubic with real coefficients always has at least one real root, because its graph goes from −∞ to +∞ (or the reverse). The other two are real or a complex pair.

What does the discriminant tell me?

Its sign sorts the roots: positive for three distinct real roots, zero for a repeated root, negative for one real and two complex roots.

How do I check an answer?

Substitute the root back into ax³ + bx² + cx + d. For a real root the result should be 0 (up to rounding). For three roots, their sum is −b/a and their product is −d/a.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator