Method: depressed cubic and discriminant
Substituting x = t − b/(3a) removes the x² term and gives the depressed cubic t³ + pt + q = 0, with p = (3ac − b²)/(3a²) and q = (2b³ − 9abc + 27a²d)/(27a³).
The discriminant Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d² tells you the kind of roots before you solve: Δ > 0 gives three different real roots, Δ = 0 gives a repeated root, and Δ < 0 gives one real root and a complex-conjugate pair.
For Δ > 0 the calculator uses the trigonometric form t = 2√(−p/3)·cos[⅓·arccos((3q/(2p))·√(−3/p)) − 2πk/3]. This avoids the complex cube roots that Cardano's formula needs in that case. For Δ < 0 it uses the matching hyperbolic form, then divides out the real root to find the complex pair. Newton's method then refines each real root.
| Discriminant | Roots |
|---|---|
| Δ > 0 | Three distinct real roots |
| Δ = 0 | A repeated real root (double or triple) |
| Δ < 0 | One real root and two complex-conjugate roots |
Worked examples
x³ − 6x² + 11x − 6 = 0: x = t + 2 gives p = −1 and q = 0, Δ = 4 > 0, and the roots are 1, 2 and 3. Check: 1 + 2 + 3 = 6 = −b/a, and 1 × 2 × 3 = 6 = −d/a.
x³ − 1 = 0: Δ = −27 < 0, so there is one real root x = 1 and a complex pair x = −0.5 ± 0.8660254038i.
Precision
The roots are calculated in double precision and shown to 10 significant digits. If Δ is smaller than about 10⁻¹² of the size of its own terms, it is treated as exactly zero. That means two roots closer together than the precision can resolve are reported as a repeated root.