Cubic Equation Solver

Solve ax³ + bx² + cx + d = 0
Next

A cubic equation has the general form ax³ + bx² + cx + d = 0 and always has three roots over the complex numbers. Enter the four coefficients and the solver returns them using Cardano’s formula: three real roots when the discriminant is non-positive, one real root plus a complex conjugate pair when the discriminant is positive, and a double-root configuration when the discriminant equals zero.

How the solver finds the roots

  1. 1

    Enter coefficients

    Four numbers: a, b, c, d. The leading coefficient a must be non-zero: otherwise the equation is quadratic, not cubic.

  2. 2

    Depressed cubic

    The solver shifts the equation by -b/(3a) to eliminate the quadratic term, producing the form `t³ + pt + q = 0`.

  3. 3

    Discriminant check

    Δ = (q/2)² + (p/3)³ decides the path: Δ > 0 gives one real root, Δ = 0 gives a double root, Δ < 0 gives three real roots via trigonometry.

  4. 4

    Shift back

    Each root found in t-space is shifted by -b/(3a) to recover x. The solver returns them in descending order where applicable.

Discriminant cases and what they mean

Cardano’s method routes through one of three branches depending on the sign of the discriminant Δ = (q/2)² + (p/3)³. The geometry of the cubic graph mirrors this exactly.

Case table

Discriminant Roots Graph shape
Δ > 0 1 real, 2 complex conjugates Crosses x-axis once
Δ = 0 3 real, at least two equal Touches x-axis at a double root
Δ < 0 3 distinct real roots Crosses x-axis three times

Worked example

For x³ − 6x² + 11x − 6 = 0 (coefficients 1, −6, 11, −6):

  • Shift by −b/(3a) = 2 to get the depressed form: p = −1, q = 0.
  • Δ = (q/2)² + (p/3)³ = 0 + (−1/3)³ = −1/27 < 0, so we take the three-real-roots (trigonometric) path.
  • The trigonometric formula gives the three distinct real roots x = 1, 2, 3.

Numerical considerations

  • Floating-point error creeps in when the three roots are close together (a near-triple root). Displayed roots may differ in the last few decimal places from the exact values.
  • Very small a makes b/(3a) large, which dominates the arithmetic and reduces precision. If |a| is below around 1e-12, solve as a quadratic instead.
  • Integer coefficients give the cleanest output: rational roots will appear at their exact values up to floating-point rounding.

Related equations

  • Quadratic: ax² + bx + c = 0. Use the Quadratic Equation Solver, closed form and simpler.
  • Quartic: ax⁴ + bx³ + cx² + dx + e = 0. Ferrari’s method reduces to a resolvent cubic; not covered here.
  • Depressed cubic: set b = 0 to skip the shift and feed x³ + px + q = 0 directly.

Frequently Asked Questions

The equation is no longer cubic. The solver refuses to proceed in that case, switch to the Quadratic Equation Solver for bx² + cx + d = 0.

The solver returns the single real root in that case. The other two roots are a complex conjugate pair that Cardano’s formula gives in closed form; compute them as -x1/2 ± (√3/2) × i × modulus if you need them for a symbolic answer.

Numerical implementations of Cardano’s method can produce residuals on the order of 1e-15 due to floating-point rounding. Treat anything below 1e-10 as real; this solver already filters those residuals out for the Δ < 0 branch.

The four coefficients are sent to the server only to compute the roots and are not stored. When you use the step-by-step view, the coefficients also appear in the page link.

Related Tools

Tool available in other languages