Cubic Equation Solver

Solve ax³ + bx² + cx + d = 0 — three real or one real and two complex roots.

Open tool

Overview

The Cubic Equation Solver finds all three roots of ax^3 + bx^2 + cx + d = 0. Depending on the coefficients you get three distinct real roots, one real with a repeated root or one real plus a complex conjugate pair — the solver reports whichever case applies.

It is useful for engineers analysing transfer functions, physics students solving kinematic problems, graphics programmers intersecting rays with parametric surfaces and anyone whose textbook problem went beyond quadratics.

How it works

The solver first divides through by a to get a monic cubic, then applies the depressed-cubic substitution x = y - b / (3a) to remove the quadratic term, giving y^3 + py + q = 0. The discriminant is Δ = -4p^3 - 27q^2.

If Δ > 0 there are three distinct real roots, found via the trigonometric cos / arccos formula. If Δ < 0 Cardano's formula yields one real root and a complex conjugate pair. The Δ = 0 case gives a repeated root. Roots are then shifted back by b / (3a).

Examples

x^3 - 6x^2 + 11x - 6 = 0  →  x = 1, 2, 3
x^3 + x = 0  →  x = 0, +i, -i
x^3 - 3x + 2 = 0  →  x = 1 (double), -2
2x^3 - 4x^2 - 22x + 24 = 0  →  x = 4, 1, -3

FAQ

Are the complex roots always conjugates?

Yes, for real coefficients. Any non-real root comes with its conjugate.

Why use the trigonometric form?

When three distinct real roots exist, Cardano's formula passes through complex intermediate values even though the final answers are real. The trig form avoids that detour.

What if a is zero?

It's not a cubic — fall back to the quadratic solver.

How accurate are the roots?

Double-precision throughout. For ill-conditioned cubics (very large coefficient ratios) a few digits of precision can disappear.

Can it factor the cubic?

Once you have the roots r1, r2, r3, the factorisation is a * (x - r1) * (x - r2) * (x - r3).

Try Cubic Equation Solver

An unhandled error has occurred. Reload ×