What this calculator does
Find every value of x that solves a cubic equation, with each step shown. A cubic is an equation whose highest power is x³: ax³ + bx² + cx + d = 0. The letters a, b, c and d are the numbers in front of each power (the coefficients), and a can't be zero. The answers are called roots. Counting repeats and complex numbers (ones that use i, the square root of −1), there are always exactly three. A cubic's graph runs from one side of the x-axis to the other. So at least one root is always a real number.
Type in the four numbers, and you get all three roots. The calculator also says what kind they are. They may be three different real numbers, or include a repeated value. Or there may be one real number plus a complex conjugate pair (two complex roots that mirror each other). The working shows how it got there. It uses a simpler "depressed" version of the equation and its discriminant, a number that sorts out the kind of roots.
Where it's used
Why this math matters outside the classroom:
- Box design. A box made by cutting x-inch squares from a 10 by 10 inch sheet holds x(10 − 2x)² cubic inches, and setting that to 64 gives a cubic with x = 1 as a root.
- Spherical tanks. Finding the fluid depth h in a spherical tank of radius r that holds a volume V means solving πh²(3r − h) ÷ 3 = V, a cubic in h.
- Gas behavior. Chemical engineers solve the cubic van der Waals equation for a gas's molar volume at a given pressure and temperature.
- Beam deflection. Structural engineers find where a uniformly loaded beam sags most by solving a cubic for the point where its slope is zero.
- Checking roots. Students test the solver on x³ − 6x² + 11x − 6 = 0, which factors as (x − 1)(x − 2)(x − 3) and so has roots 1, 2 and 3.
How to use it
- Rearrange your equation so everything is on one side and zero is on the other. Write the powers of x from highest to lowest.
- Enter a, b, c and d with their signs. If a power is missing, its number is 0. So x³ − 8 = 0 is a = 1, b = 0, c = 0, d = −8.
- Read the roots at the top. Real roots are listed largest first. A complex pair is written p ± qi, and each of the two is also shown on its own.
- Check the discriminant and the kind of roots. Then open the working to follow each stage with your numbers.
What the inputs mean
- a (coefficient of x³)
- The number in front of x³. It can't be 0. Without the x³ term, the equation is quadratic (highest power x²) or linear.
- d (constant term)
- The plain number with no x (the constant term). When it's 0, x = 0 is one of the roots, and the rest come from a quadratic.
Formula and method
x = t − b ÷ 3a turns the equation into t³ + Pt + Q = 0 P = c/a − (b/a)² ÷ 3 Q = 2(b/a)³ ÷ 27 − (b/a)(c/a) ÷ 3 + d/a Δ = −(4P³ + 27Q²) Δ > 0: t = 2√(−P/3) · cos(φ/3 − 120°·k), cos φ = (3Q ÷ 2P)·√(−3/P), k = 0, 1, 2 Δ = 0: t = 3Q/P (single) and t = −3Q/2P (double)
First, the calculator divides by a and swaps x for t − b ÷ 3a. Here t is a shifted version of x. This removes the x² term. What's left is called the depressed cubic, t³ + Pt + Q = 0. It has only two numbers, P and Q. Its discriminant, Δ (the Greek letter delta), tells you the kind of roots. Positive means three different real roots. Zero means at least two roots are the same. Negative means one real root plus a complex pair. Shifting x doesn't change Δ. Multiply it by a⁴ and you get the discriminant of the original equation. That's the familiar 18abcd − 4b³d + b²c² − 4ac³ − 27a²d².
With three real roots, the calculator uses the trigonometric method, built on the cosine (cos). In that line, φ (phi) is an angle the method works out, and k = 0, 1, 2 gives the three roots. This avoids the complex in-between values that Cardano's formula would need. With one real root, it uses Cardano's formula in its hyperbolic form (a version that suits this case). Then it divides that root out and solves the leftover quadratic for the complex pair. Real roots are polished with a few rounds of Newton's method, a guess-and-improve technique, on the original equation. So they stay accurate even when the roots differ greatly in size.
Worked example
Solve x³ − 6x² + 11x − 6 = 0.
- Here a = 1, so the equation already starts with a plain x³ (it's "monic"): b/a = −6, c/a = 11, d/a = −6.
- P = 11 − (−6)² ÷ 3 = 11 − 12 = −1, and Q = 2 × (−216) ÷ 27 − (−6)(11) ÷ 3 + (−6) = −16 + 22 − 6 = 0.
- Δ = −(4 × (−1)³ + 27 × 0²) = 4, which is positive, so there are three distinct real roots.
- m = 2√(1/3) ≈ 1.154701 and cos φ = 0, so φ = 90° and φ/3 = 30°. The three values of t are m cos 30° = 1, m cos(−90°) = 0 and m cos(−210°) = −1.
- Shift back with x = t + 2: the roots are 3, 2 and 1.
Result: x = 3, x = 2 or x = 1, which factors the cubic as (x − 3)(x − 2)(x − 1).
Understanding the result
Real roots are where the graph of y = ax³ + bx² + cx + d crosses or touches the x-axis. A double root is where the curve touches the axis and turns back. A triple root is a flattened crossing, as in y = (x − 2)³ at x = 2.
When the answer includes a complex pair, the graph crosses the axis only once. The two complex roots are conjugates. Their real parts match, and their imaginary parts (the parts with i) differ only in sign. Two quick checks are built in. The three roots always add up to −b/a, and they multiply to −d/a.
Assumptions and limitations
- The numbers a, b, c and d are real numbers, and a isn't zero.
- The math uses standard computer decimals (double-precision floating point). A discriminant smaller than its own likely rounding error is treated as exactly zero. That way, a true repeated root is reported as one root. It won't show up as two nearly equal roots, or as a complex pair with a tiny imaginary part.
- Roots are shown as rounded decimals, not as exact expressions with square or cube roots.
- Roots that differ by less than about one part in a million are reported as a single repeated root. At that closeness, computer rounding error can no longer tell them apart reliably.
- It doesn't handle complex numbers for a, b, c or d, or equations with x⁴ or higher powers.
Frequently asked questions
Does every cubic have a real root?
Yes. For large positive x, the x³ term takes over, and the value has the same sign as a. For large negative x, it has the opposite sign. So the graph must cross zero somewhere in between, and at least one root is real.
Why not just use Cardano's formula for everything?
When all three roots are real, Cardano's formula still has to take square roots of negative numbers along the way. This puzzle is known as the irreducible case. The trigonometric method gives the same roots using only real numbers. That's both simpler and more accurate.
What does a negative discriminant mean?
It means there's one real root and two complex roots that mirror each other (conjugates), such as −1 + 2i and −1 − 2i. On a graph, the curve crosses the x-axis exactly once.
How can I check the answer?
Put each root back into the equation. The result should be zero, give or take rounding. You can also use the sum and product shown with the results. For any cubic, the roots add up to −b/a and multiply to −d/a.
How this calculator is checked
Method: Depressed cubic via the substitution x = t − b/3a; Viète's trigonometric solution for Δ > 0, the hyperbolic form of Cardano's formula for Δ < 0, closed forms for Δ = 0; Newton refinement of real roots. The calculation is covered by automated tests with known reference values and edge cases. Last updated 2026-10-18. Found a problem? Tell us.
Embed this calculator
Put this Cubic Equation Calculator on your own website or blog for free. Paste this code where you want it to appear: