UTILS.
100% in-browser

Cubic Equation Solver

Solve ax³+bx²+cx+d=0 for all three roots using Cardano and the trigonometric method, with the discriminant and real-root count.

Enter a, b, c and d. a must not be 0.

About this tool

Solve any cubic equation ax³ + bx² + cx + d = 0 (with a ≠ 0). Enter the four coefficients and the solver returns all three roots, real and complex, along with the discriminant and how many roots are real. It runs entirely in your browser and recalculates as you type.

The cubic is first depressed with the substitution x = t - b/(3a) into t³ + pt + q = 0, and the discriminant Δ = (q/2)² + (p/3)³ decides the case. When Δ > 0 there is one real root by Cardano's formula plus a complex-conjugate pair. When Δ = 0 the roots are real with a repeated value. When Δ < 0 there are three distinct real roots found with the trigonometric method, tₖ = 2√(-p/3)·cos((1/3)·acos((3q/2p)·√(-3/p)) - 2πk/3). Each t is shifted back by -b/(3a) to give x.

Complex roots are shown in a ± bi form. For example x³ - 6x² + 11x - 6 = 0 returns the roots 1, 2 and 3. Coefficient a must not be zero, or the equation is not cubic.

Frequently asked questions

What does the discriminant tell me?
Its sign classifies the roots: positive means one real and two complex conjugate roots, zero means all roots are real with a repeat, and negative means three distinct real roots.
Why are three roots always returned?
By the fundamental theorem of algebra a cubic has exactly three roots counting multiplicity. Some may be complex, and repeated roots appear more than once.
Must the leading coefficient a be non-zero?
Yes. If a is zero the equation is at most quadratic, not cubic, so the solver requires a non-zero a and otherwise reports invalid input.
How are the three real roots found when the discriminant is negative?
By the trigonometric method, which uses a cosine formula on the depressed cubic to produce three distinct real roots without complex arithmetic.

More tools