Cubic Equation Solver
Solve ax³ + bx² + cx + d = 0 for its real roots using the trigonometric and Cardano methods, with near-integer roots snapped cleanly.
How it works
ax³ + bx² + cx + d = 0 · substitute x = t − b/(3a) → t³ + pt + q = 0 · Δ = (q/2)² + (p/3)³ · trig or Cardano roots
Every cubic is first simplified by the substitution x = t − b/(3a), which erases the x² term and leaves a depressed cubic t³ + pt + q = 0. The quantity Δ = (q/2)² + (p/3)³ then decides the method: when Δ is negative there are three distinct real roots, found with the trigonometric formula using cosines; when Δ is positive there is a single real root, found with Cardano’s cube-root formula (and a conjugate pair of complex roots this calculator omits). Roots are rounded and snapped to nearby integers so clean answers read cleanly.
Worked example
Solve x³ − 6x² + 11x − 6 = 0. Here a = 1, b = −6, c = 11, d = −6, giving p = −1 and q = 0, so Δ = −1/27 < 0 — three real roots. The trigonometric formula returns t = 1, 0, −1, and shifting by −b/(3a) = +2 gives x = 3, 2, 1. That matches the factored form (x − 1)(x − 2)(x − 3) = 0.
Sources: Cubic equation — Wikipedia
Frequently asked questions
Why does this show only real roots?
When the discriminant is positive a cubic has one real root and a pair of complex-conjugate roots. This solver reports the real root (or all three when they are real), which is what most applied problems need.
What is the depressed cubic?
It’s the cubic after substituting x = t − b/(3a), which cancels the squared term. The simpler t³ + pt + q = 0 form is what the trigonometric and Cardano formulas actually solve.
Why are my roots shown as whole numbers?
The formulas involve cube roots and cosines that introduce tiny floating-point errors, so a root landing within a millionth of an integer is snapped to it — turning 2.9999998 back into the intended 3.
Related calculators
This calculator is for educational purposes. Double-check important results before acting on them.