Cubic equation solver — all three roots of ax³ + bx² + cx + d = 0

Enter the four coefficients of a cubic equation and the solver returns all three roots, real or complex, together with the exact discriminant that decides which kind they are.

Live demo · real result from this tool
Nature of rootsThree distinct real roots (Δ > 0)
Discriminant Δ
4

Roots

x₁ = 3x₂ = 2x₃ = 1

Method

Trigonometric method (casus irreducibilis — Cardano would need complex cube roots). Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d² Sum of roots = −b/a = 6; product = −d/a = 6

Processed on your device — nothing is uploaded.

How to use the cubic equation solver

  1. Rearrange your equation into the form ax³ + bx² + cx + d = 0.
  2. Enter a (x³), b (x²), c (x) and d (constant). Use 0 for a missing term, and remember the signs.
  3. Read the Nature of roots and the Discriminant Δ.
  4. Read the Roots box (x₁, x₂, x₃), then the Method box with the sum and product of the roots.

What it does and when to use it

Cubic equations come up in algebra and calculus classes, in finding where a curve crosses the x-axis, in volume problems (such as a box cut from a sheet, where V = x(l − 2x)(w − 2x)), and in physics and engineering models. Solving them by hand is long, so this tool is a quick way to get the roots or check your factorisation.

For second-degree equations, use the quadratic solver, which also gives exact surd answers. Complex roots can be explored further with the complex number calculator. If a root is a decimal you suspect is a fraction, try decimal to fraction.

How it works

  1. Discriminant, computed with exact fractions: Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d². Decimal coefficients are read exactly as typed, so Δ = 0 is detected reliably.
  2. Depressed cubic: substituting x = t − b/(3a) gives t³ + pt + q = 0, with p = (3ac − b²)/(3a²) and q = (2b³ − 9abc + 27a²d)/(27a³).
  3. Roots, by case:
    • Δ > 0: the trigonometric method, t = 2√(−p/3) × cos(θ − 2πk/3) for k = 0, 1, 2, where θ = ⅓ × arccos(3q ÷ (p × 2√(−p/3))).
    • Δ = 0: a double root at t = −3q/(2p) and a single root at t = 3q/p, or a triple root at x = −b/(3a) when p = 0.
    • Δ < 0: Cardano’s formula, with u and v the cube roots of −q/2 ± √(q²/4 + p³/27); the real root is u + v.
  4. A few steps of Newton’s method then polish each real root.

Worked examples

Three real roots, step by step. Solve 2x³ − 4x² − 22x + 24 = 0, so a = 2, b = −4, c = −22, d = 24.

  1. Work out the five parts of Δ: 18abcd = 76,032; −4b³d = 6,144; b²c² = 7,744; −4ac³ = 85,184; −27a²d² = −62,208.
  2. Add them: Δ = 112,896, which is positive, so expect three different real roots.
  3. The tool uses the trigonometric method and gives x₁ = 4, x₂ = 1 and x₃ = −3.
  4. Check: the sum 4 + 1 − 3 = 2 matches −b/a = 2, and the product 4 × 1 × (−3) = −12 matches −d/a = −12.

So 2x³ − 4x² − 22x + 24 = 2(x − 4)(x − 1)(x + 3). The tool shows Discriminant Δ: 112,896.

A repeated root. x³ − 3x + 2 = 0 gives Δ = 0 and Three real roots, two of them equal (Δ = 0): x = 1 twice and x = −2.

Complex roots. x³ + x + 1 = 0 gives Δ = −31, one real root x₁ = −0.6823278038, and the pair x₂ = 0.3411639019 + 1.1615414i and x₃ = 0.3411639019 − 1.1615414i.

Limits and tips

  • Coefficients must be real numbers; complex coefficients are not supported.
  • The coefficients are typed as numbers. For fractions such as ½, enter 0.5, or multiply the whole equation by the denominator first.
  • Roots are numerical, shown to 10 significant figures, not exact radicals.
  • Everything runs in your browser.

Frequently asked questions

Does every cubic have a real root?
Yes. A cubic with real coefficients always crosses the x-axis at least once, so at least one root is real. The other two are either both real or a complex conjugate pair.
What does the discriminant tell me?
If Δ > 0 there are three different real roots. If Δ = 0 at least two roots are equal. If Δ < 0 there is one real root and two complex roots of the form m ± ni.
Why does it say a is 0?
Without the x³ term the equation is a quadratic, not a cubic. Use the quadratic solver for bx² + cx + d = 0.
How can I check the roots by hand?
The roots must add up to −b/a and multiply to −d/a. The tool prints both values. You can also put each real root back into the equation and confirm it gives 0.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close