How to Solve a Cubic Equation

Finds the real roots of ax³ + bx² + cx + d = 0. Shifting x by b/(3a) removes the squared term, and the remaining t³ + pt + q = 0 is solved according to the sign of the discriminant. There is always at least one real root.

This finds the real roots of ax3+bx2+cx+d=0ax^3 + bx^2 + cx + d = 0. A cubic always has at least one real root: its graph runs from the bottom left to the top right, so it has to cross the xx axis somewhere.

x=tb3ax = t - \dfrac{b}{3a}

Shifting xx this way removes the squared term and leaves t3+pt+q=0t^3 + pt + q = 0. From there the sign of the discriminant q24+p327\dfrac{q^2}{4} + \dfrac{p^3}{27} decides how to carry on.

The three cases

A positive discriminant means one real root, found by adding two cube roots in Cardano's formula. Zero means there is a repeated root, leaving one or two real roots. A negative discriminant means three distinct real roots, but Cardano's formula then asks for the cube root of a negative number and cannot be written with real numbers, so trigonometry is used instead.

Example

For x36x2+11x6=0x^3 - 6x^2 + 11x - 6 = 0, the shift gives p=1p = -1 and q=0q = 0, so the discriminant is 127-\dfrac{1}{27}, which is negative. There are three distinct real roots: x=1,2,3x = 1, 2, 3. Expanding (x1)(x2)(x3)(x-1)(x-2)(x-3) returns the original equation.

Notes

Only distinct real roots are listed, smallest first. A repeated root counts once, so x3=0x^3 = 0 has the single root 0. Any unused slots are filled with a hyphen.

Complex roots are not given. With aa equal to 0 this is not a cubic, so use the quadratic calculator instead.