Cubic equation calculator
Enter the coefficients, get all three roots.
How do I solve a cubic equation?
Enter a, b, c and d for ax³ + bx² + cx + d = 0. x³ − 6x² + 11x − 6 = 0 has the roots 1, 2 and 3, since it factors as (x − 1)(x − 2)(x − 3).
How many roots does a cubic have?
Always three, counting repeats and complex roots. There is at least one real root; the other two are either real or a complex conjugate pair.
What method does the calculator use?
It removes the x² term to get t³ + pt + q = 0, then uses the trigonometric formula when there are three real roots and Cardano’s formula otherwise.
What are the roots of x³ − 1 = 0?
1, and the complex pair −0.5 ± 0.866025i — the cube roots of 1.
What about repeated roots?
x³ − 3x² + 3x − 1 = (x − 1)³ has the single root 1, repeated three times; the calculator lists it three times.
How can I tell whether the roots are real?
The sign of D = (q ÷ 2)² + (p ÷ 3)³ decides (Wolfram MathWorld, “Cubic Formula”): below 0 means three different real roots, 0 means all real with at least two equal, above 0 means one real root and a complex conjugate pair. For x³ + x + 2 = 0, p = 1 and q = 2, so D is positive and the roots are −1, 0.5 + 1.3229i and 0.5 − 1.3229i.
Can I solve a cubic by factoring instead?
Sometimes. By the Rational Zero Theorem (OpenStax Algebra and Trigonometry 2e, section 5.5), a rational root of an integer cubic is a factor of d over a factor of a. For x³ − 4x² + x + 6 the candidates are ±1, ±2, ±3, ±6; −1 works, and dividing by (x + 1) leaves (x − 2)(x − 3). For x³ − 5x² + 2x + 3 neither ±1 nor ±3 works, yet the calculator finds three real roots: −0.5758, 1.1873, 4.3885.
How the roots are found
Divide by a so the equation reads x³ + Bx² + Cx + D = 0, then substitute x = t − B ÷ 3 to remove the squared term. That leaves t³ + pt + q = 0 with p = C − B² ÷ 3 and q = 2B³ ÷ 27 − BC ÷ 3 + D (NIST DLMF, section 1.11(iii)). If D = (q ÷ 2)² + (p ÷ 3)³ is negative, the calculator uses t = 2√(−p ÷ 3)·cos((θ + 2πk) ÷ 3) for k = 0, 1, 2, with θ = arccos[(−q ÷ 2) ÷ √(−(p ÷ 3)³)] (MathWorld, whose q has the opposite sign); otherwise it uses Cardano’s cube-root formula. Each t is shifted back by −B ÷ 3. The coefficients must be real, and a cannot be 0.
Worked example: x³ − 4x² + x + 6 = 0
Here B = −4, C = 1 and D = 6, so p = 1 − 16 ÷ 3 = −4.3333 and q = 2.5926. Then D = −1.3333, which is negative, so all three roots are real and different. The shift is −B ÷ 3 = 1.3333, and the trigonometric formula returns −1, 2, 3. Expanding (x + 1)(x − 2)(x − 3) returns the original cubic.
Common mistakes
Leaving out a missing term instead of entering 0 shifts every coefficient: x³ − 7x + 6 = 0 needs b = 0, c = −7 and d = 6, which gives −3, 1, 2. Counting too few answers is another: a cubic has three roots counting repeats and complex ones (OpenStax, section 5.5), so one real number plus a complex pair makes three. With real coefficients the complex roots always arrive as a conjugate pair.
Sources: NIST DLMF, section 1.11(iii); Wolfram MathWorld, “Cubic Formula”; OpenStax, Algebra and Trigonometry 2e, section 5.5 “Zeros of Polynomial Functions”. Related tools: quadratic formula calculator, synthetic division calculator and equation solver. How we check our calculators.