Cubic Equation Solver
Enter the coefficients a, b, c and d of ax³ + bx² + cx + d = 0 to get all three roots, real or complex. The solver shows the discriminant, the depressed cubic, Cardano's formula or the trigonometric method with your numbers, and a graph of the curve.
How to use the Cubic Equation Solver
- Enter a, b, c and d for ax³ + bx² + cx + d = 0 (use 0 for a missing term).
- Pick the decimal places you want to see.
- Press Solve (or just type; results update live).
- Read the roots, the discriminant and the factored form.
- Follow the steps and check the graph and the residual table.
How a cubic equation is solved
- Depress the cubic. Substituting x = t − b/(3a) removes the x² term and gives t³ + pt + q = 0 with p = (3ac − b²)/(3a²) and q = (2b³ − 9abc + 27a²d)/(27a³).
- Check the sign of q²/4 + p³/27. It has the opposite sign of the discriminant Δ (Δ = −108a⁴ · (q²/4 + p³/27)).
- One real root (q²/4 + p³/27 > 0): Cardano's formula, t = ∛(−q/2 + √(q²/4 + p³/27)) + ∛(−q/2 − √(q²/4 + p³/27)). With u and v the two cube roots, the complex pair is −(u + v)/2 ± i·(√3/2)(u − v).
- Three real roots (q²/4 + p³/27 < 0): tk = 2√(−p/3)·cos(⅓·arccos((3q/2p)·√(−3/p)) − 2πk/3) for k = 0, 1, 2.
- Repeated roots (= 0): a simple root t = 3q/p and a double root t = −3q/(2p), or a triple root t = 0 when p = q = 0.
- Shift back with x = t − b/(3a).
Worked examples
| Equation | Discriminant Δ | Roots |
|---|---|---|
| x³ − 6x² + 11x − 6 = 0 | 4 (> 0) | 1, 2, 3 |
| x³ − 1 = 0 | −27 (< 0) | 1, −0.5 ± 0.866025i |
| x³ − 3x + 2 = 0 | 0 | −2, 1 (double) |
| x³ − 3x² + 3x − 1 = 0 | 0 | 1 (triple) |
| x³ + x + 1 = 0 | −31 (< 0) | −0.682328, 0.341164 ± 1.161541i |
| 2x³ − 4x² − 22x + 24 = 0 | > 0 | −3, 1, 4 |
Useful facts about cubics
- Complex roots of a polynomial with real coefficients always come in conjugate pairs (p + qi and p − qi).
- The inflection point is at x = −b/(3a); the graph is point-symmetric about it.
- The curve has a local maximum and minimum only when b² − 3ac > 0.
- Rational roots, if any, are of the form ±(factor of d)/(factor of a) by the rational root theorem.
Frequently asked questions
How many roots does a cubic equation have?
Exactly three, counted with multiplicity, if complex roots are included. A cubic with real coefficients always has at least one real root, because the curve goes from −∞ to +∞ and must cross the x-axis.
What does the discriminant of a cubic tell you?
For ax³ + bx² + cx + d, Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d². If Δ > 0 there are three distinct real roots, if Δ = 0 there is a repeated root (all roots real), and if Δ < 0 there is one real root and two complex conjugate roots.
What is Cardano's formula?
After substituting x = t − b/(3a), the cubic becomes t³ + pt + q = 0. Cardano's formula gives t = ∛(−q/2 + √(q²/4 + p³/27)) + ∛(−q/2 − √(q²/4 + p³/27)). It is used when q²/4 + p³/27 > 0, which is the case of one real root.
Why use the trigonometric method for three real roots?
When there are three distinct real roots, the square root in Cardano's formula is of a negative number, so the formula needs complex arithmetic even though all answers are real (the casus irreducibilis). The trigonometric form t = 2√(−p/3)·cos(⅓·arccos((3q/2p)√(−3/p)) − 2πk/3) gives the three real roots directly.
What happens if a = 0?
Then the equation is not cubic. The solver tells you so and solves the remaining quadratic bx² + cx + d = 0 (or the linear equation cx + d = 0 if b is also 0).
How accurate are the roots?
Roots are computed in double-precision floating point and real roots are refined with Newton's method. The table shows the residual |f(x)| for each root, which is typically around 10⁻¹² or smaller for well-scaled coefficients.
How can I check the answer?
By Vieta's formulas the three roots add up to −b/a and multiply to −d/a. The solver shows both values, and you can also plug each root back into the equation (the residual column).