HomeMath › Cubic Equation Solver

Cubic Equation Solver

Solves ax³ + bx² + cx + d = 0 by depressing the cubic and applying Cardano's formula (one real root) or the trigonometric method (three real roots), and reports the discriminant, the nature of the roots and every root, complex roots as strings.

When to use

You need the solutions of a third-degree polynomial equation, including repeated roots and complex conjugate pairs.

Do not use when: a is 0 (the equation is quadratic: use quadratic-equation) or the polynomial has degree 4 or more (use a numerical root finder).

Formula

Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d²; x = t − b/(3a) gives t³ + pt + q = 0. Δ > 0: t_k = 2√(−p/3)·cos(⅓·arccos((3q/(2p))·√(−3/p)) − 2πk/3), k = 0, 1, 2. Δ < 0: u = ∛(−q/2 + √(q²/4 + p³/27)), v = ∛(−q/2 − √(q²/4 + p³/27)), real root u + v, complex pair −(u + v)/2 ± i·(u − v)·√3/2. Δ = 0: double root −3q/(2p) and simple root 3q/p (triple root t = 0 when p = q = 0).

Real roots from the closed forms are refined with up to three Newton steps on the original polynomial; a discriminant within 10^-10 of the size of its terms is treated as zero.

Inputs

ParameterTypeUnitRequiredDescription
anumberyesCoefficient of x³. Must not be 0.
bnumberyesCoefficient of x².
cnumberyesCoefficient of x.
dnumberyesConstant term.

Outputs

OutputTypeUnitDescription
discriminantnumberΔ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d²; positive → three distinct real roots, zero → a repeated root, negative → one real root and a complex pair.
naturestringClassification of the roots from the sign of the discriminant.
rootsstringAll three roots as text: real roots in ascending order, complex roots written like '0+1i, 0-1i'.
root1numberSmallest real root.
root2numberMiddle real root (only when all three roots are real).
root3numberLargest real root (only when all three roots are real).
real_rootsnumber_listReal roots in ascending order; a repeated root is listed once per multiplicity.
depressed_pnumberp = c/a − b²/(3a²) in t³ + pt + q = 0, obtained with x = t − b/(3a).
depressed_qnumberq = 2b³/(27a³) − bc/(3a²) + d/a.
sum_of_rootsnumber−b / a (Vieta's formula).
product_of_rootsnumber−d / a (Vieta's formula).

Example

x³ − 6x² + 11x − 6 = 0: {"a":1,"b":-6,"c":11,"d":-6}{"discriminant":4,"nature":"Three distinct real roots","roots":"1, 2, 3","root1":1,"root2":2,"root3":3,"real_roots":[1,2,3],"depressed_p":-1,"depressed_q":0,"sum_of_roots":6,"product_of_roots":6}

x³ + x² + x + 1 = 0: {"a":1,"b":1,"c":1,"d":1}{"discriminant":-16,"nature":"One real root and two complex conjugate roots","roots":"-1, 0+1i, 0-1i","root1":-1,"real_roots":[-1],"sum_of_roots":-1,"product_of_roots":-1}

GET https://tttkmbb.com/api/v1/calculate/cubic-equation?a=1&b=-6&c=11&d=-6

Machine access

Sources

FAQ

Why does a cubic always have at least one real root?

A real cubic polynomial tends to −∞ on one side and +∞ on the other, so it must cross the x-axis; the other two roots are either real or a complex conjugate pair.

How are repeated roots reported?

A double root appears twice in real_roots (e.g. x³ − 3x + 2 gives [-2, 1, 1]) and a triple root three times; nature names the multiplicity.

Why the trigonometric method for three real roots?

When Δ > 0 Cardano's formula needs cube roots of complex numbers (the casus irreducibilis); the trigonometric identity for cos 3θ gives the three real roots directly.

Related calculators