Cubic equation solver
Enter the four coefficients (whole numbers, decimals or fractions like 3/4). The solver reduces the cubic to t³ + pt + q = 0, computes the exact discriminant and returns all three roots, real or complex.
Runs in your browser: nothing you enter is sent anywhere.
How to use it
- Type a, b, c and d. Use 0 for a missing term: x³ − 8 is a = 1, b = 0, c = 0, d = −8.
- Read the type of roots, the discriminant and the three roots. Complex roots are written a ± bi.
How it works
The discriminant and the depressed-cubic coefficients p = (3ac − b²)/(3a²) and q = (2b³ − 9abc + 27a²d)/(27a³) are computed with exact fractions, so the sign of Δ, and therefore the type of roots, is never decided by rounding. The roots themselves use the trigonometric method for three real roots and Cardano’s formula for one real root. For Δ = 0 the roots are exact: a simple root 3q/p and a double root −3q/(2p) (or a triple root when p = 0), each shifted by −b/(3a).
For a polynomial of degree 4 or 5, or when you want numeric roots of any degree up to 5, use the polynomial roots calculator.
Worked example
x³ − 6x² + 11x − 6 = 0:
- Δ = 18·(−6)·11·(−6) − 4·(−216)·(−6) + 36·121 − 4·1331 − 27·36 = 7128 − 5184 + 4356 − 5324 − 972 = 4, so there are three distinct real roots.
- The roots are 1, 2 and 3; their sum is 6 = −b/a and their product is 6 = −d/a.
x³ − 1 = 0 has Δ = −27: one real root 1 and the complex pair −0.5 ± 0.8660254i.
Tips
- A repeated root appears as two equal root lines, for example x³ − 3x + 2 = (x − 1)²(x + 2) gives −2, 1, 1.
- Floating-point roots are shown with up to 8 significant digits.
Frequently asked questions
What does the discriminant of a cubic tell me?
For ax³ + bx² + cx + d the discriminant is Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d². If Δ > 0 there are three distinct real roots, if Δ = 0 there is a repeated root and all roots are real, and if Δ < 0 there is one real root and a pair of complex conjugate roots.
How is a cubic solved?
Substitute x = t − b/(3a) to remove the x² term and get t³ + pt + q = 0. With three real roots the trigonometric method gives t = 2√(−p/3)·cos(⅓·arccos(3q/(2p)·√(−3/p)) − 2πk/3). Otherwise Cardano's formula gives t = ∛(−q/2 + √D) + ∛(−q/2 − √D) with D = q²/4 + p³/27.
Can a cubic have no real roots?
No. A real cubic goes from −∞ to +∞ (or the reverse), so it crosses the x-axis at least once. It has either one or three real roots, counting repeated roots.
Why are the roots written with i?
When Δ < 0 two roots are complex numbers a ± bi. They are always conjugates of each other, as the coefficients are real.
How can I check the answer?
The roots must add up to −b/a and multiply to −d/a (Vieta's formulas); both values are shown. You can also substitute a root back into the equation.