DigitHelm

Cubic Equation Solver | ax³+bx²+cx+d=0

Solve cubic equations (ax³ + bx² + cx + d = 0) and find all three roots with step-by-step working, graph, and factored form.

0 = 0

Presets

Coefficients for ax³ + bx² + cx + d = 0

Press Enter to solve, Esc to reset. Inputs auto-saved in your browser.

What Is the Cubic Equation Solver | ax³+bx²+cx+d=0?

A cubic equation is a polynomial of degree 3. By the Fundamental Theorem of Algebra, every cubic with real coefficients has exactly three roots in the complex numbers, counted with multiplicity. Unlike quadratics, a cubic always has at least one real root because its graph must cross the x-axis at least once (continuous function with opposite limits at ±∞).

The key step in every solution method is the Tschirnhaus–Viète substitution x = t − b/(3a), which eliminates the quadratic term and reduces the equation to the simpler “depressed” form t³ + pt + q = 0. From there, the discriminant Δ selects the correct method.

When Δ > 0, the Viète trigonometric method avoids complex intermediate values and gives all three real roots directly. When Δ < 0, Cardano's formula (1545, the first published general algebraic solution for any polynomial beyond quadratics) uses cube roots of real numbers to find the unique real root.

Formula

Standard Form & Depressed Cubic

Standard form: ax³ + bx² + cx + d = 0, a ≠ 0

Substitute: x = t − b/(3a) → eliminates the x² term

Depressed form: t³ + pt + q = 0

p = (3ac − b²) / 3a²

q = (2b³ − 9abc + 27a²d) / 27a³

Discriminant & Root Cases

Discriminant: Δ = −(4p³ + 27q²)

Δ > 0: Three distinct real roots (Viète trigonometric method)

Δ = 0: Repeated root(s), one double or one triple root

Δ < 0: One real root + two complex conjugates (Cardano's formula)

Solution Methods

Viète (Δ > 0): tₖ = m·cos(⅓·arccos(3q/(p·m)) − 2πk/3), k=0,1,2

m = 2√(−p/3)

Cardano (Δ < 0): t = ∛(−q/2 + √D) + ∛(−q/2 − √D)

D = q²/4 + p³/27 = −Δ/108

Back-substitute: x = t − b/(3a)

SymbolMeaningNotes
a, b, c, dPolynomial coefficientsa ≠ 0 required
tVariable in the depressed cubicx = t − b/(3a)
pLinear coefficient of depressed cubic(3ac − b²)/(3a²)
qConstant term of depressed cubic(2b³ − 9abc + 27a²d)/(27a³)
ΔDiscriminant−(4p³ + 27q²)
mAmplitude in Viète method2√(−p/3); real only when p < 0
DCardano discriminantq²/4 + p³/27 = −Δ/108

How to Use

  1. 1Enter coefficients: Type a, b, c, d for ax³ + bx² + cx + d = 0. The live preview shows your equation updating as you type.
  2. 2Use a preset (optional): Click any preset equation to see a worked example with different root cases.
  3. 3Solve: Press "Solve" or hit Enter. Results show root types, values, factored form, and a graph.
  4. 4Read the roots: Real roots (blue cards) are x-axis intercepts. Complex roots appear as pairs a ± bi.
  5. 5Verify: The verification table shows |f(root)|, it should be near zero (≤ 1×10⁻⁷) for each root.
  6. 6Step-by-step: Click "Step-by-step solution" to expand the full derivation showing p, q, Δ, and each root calculation.

Example Calculation

Example 1, Three real roots: x³ − 6x² + 11x − 6 = 0

  • a=1, b=−6, c=11, d=−6
  • Shift: x = t + 2 (since −b/(3a) = 6/3 = 2)
  • p = (33 − 36)/3 = −1, q = (−432 + 594 − 162)/27 = 0
  • Δ = −(4·(−1)³ + 0) = 4 > 0 → three distinct real roots
  • m = 2√(1/3) ≈ 1.1547, cos(3θ) = 0
  • Roots: x₁ = 3, x₂ = 2, x₃ = 1, verified by (x−1)(x−2)(x−3)

Example 2, One real + two complex: x³ + x − 2 = 0

  • a=1, b=0, c=1, d=−2
  • p = 1, q = −2 (no shift since b=0)
  • Δ = −(4 + 27·4) = −112 < 0 → Cardano's formula
  • D = 4/4 + 1/27 = 1.037, √D = 1.0185
  • C = ∛(1 + 1.0185) = ∛2.0185 ≈ 1.264, D = ∛(−0.0185) ≈ −0.264
  • x₁ = 1 (real), x₂,₃ ≈ −0.5 ± 1.323i (complex conjugates)

Example 3, Double root: x³ − 3x + 2 = 0

  • a=1, b=0, c=−3, d=2
  • p = −3, q = 2
  • Δ = −(4·(−27) + 27·4) = −(−108 + 108) = 0 → repeated root
  • Simple root: t₁ = 3q/p = 6/(−3) = −2 → x₁ = −2
  • Double root: t₂ = −3q/(2p) = −6/(−6) = 1 → x₂ = x₃ = 1
  • Roots: x₁ = −2, x₂ = x₃ = 1 (double), factored: (x+2)(x−1)²

Understanding Cubic Equation | ax³+bx²+cx+d=0

History: From Cardano to Viète

The general cubic was first solved in the 1530s by Niccolò Fontana Tartaglia, who shared his method (under oath of secrecy) with Gerolamo Cardano. Cardano published the formula in his 1545 work Ars Magna, breaking his promise but securing his place in history. The formula was the first algebraic solution of a polynomial beyond degree 2, and it inspired centuries of further work on polynomial equations, culminating in Galois theory and the proof that degree-5 polynomials have no general formula.

The Discriminant and Root Classification

ΔRoot typeFactored structure
Δ > 0Three distinct real rootsa(x−r₁)(x−r₂)(x−r₃)
Δ = 0, p≠0One simple + one double real roota(x−r₁)(x−r₂)²
Δ = 0, p=0One triple roota(x−r)³
Δ < 0One real + two complex conjugatesa(x−r)(x²+Bx+C), B²<4C

Numerical Accuracy and Conditioning

This solver uses 64-bit IEEE 754 floating-point arithmetic, giving approximately 15–16 significant decimal digits of precision. For well-conditioned equations (coefficients of similar magnitude), all roots should be accurate to at least 10 significant digits. Ill-conditioned cases arise when roots are very close together, or when coefficients span many orders of magnitude, in those cases, the verification column (|f(root)|) is the best indication of accuracy.

Frequently Asked Questions

What is the difference between Cardano's formula and the Viète method?

  • Cardano's formula (1545) uses cube roots of (possibly complex) numbers, it works for any depressed cubic.
  • When Δ < 0, the cube roots are real and the formula gives the unique real root directly.
  • The problem: when Δ > 0 (three real roots), Cardano produces cube roots of complex numbers, the casus irreducibilis.
  • The Viète trigonometric method solves this by using cosine instead, keeping all arithmetic real when Δ > 0.

Does a cubic always have at least one real root?

  • Yes, always. Every cubic polynomial with real coefficients has at least one real root.
  • This follows from the Intermediate Value Theorem: as x → +∞, f(x) → +∞ (for a > 0), and as x → −∞, f(x) → −∞.
  • Since f is continuous, it must cross zero at least once.
  • Complex roots of real polynomials always come in conjugate pairs, so 1 or 3 real roots are possible, never 2.

What is the discriminant Δ and what does it tell me?

  • Δ = −(4p³ + 27q²) where p and q are the depressed cubic's coefficients.
  • Δ > 0: three distinct real roots.
  • Δ = 0: at least two roots coincide, either a double root (one simple + one double) or a triple root (all three equal).
  • Δ < 0: one real root and two non-real complex conjugate roots.

What does the factored form show?

  • The factored form expresses the cubic as a product of linear and/or quadratic factors.
  • For three real roots r₁, r₂, r₃: f(x) = a(x−r₁)(x−r₂)(x−r₃).
  • For one real + two complex roots r₁ and α ± βi: f(x) = a(x−r₁)(x²+Bx+C).
  • The quadratic factor x²+Bx+C has no real roots, its discriminant B²−4C < 0.

Why might the verification show a value slightly above zero?

  • Floating-point arithmetic (IEEE 754 double precision) introduces rounding errors of about 10⁻¹⁵.
  • For most equations, |f(root)| will be ≤ 10⁻⁸, effectively zero at any practical precision.
  • If you see |f(root)| ≈ 10⁻⁴ or larger, the equation likely has coefficients that cause numerical cancellation.
  • In that case, try scaling your coefficients (divide through by a constant) to improve conditioning.

Can I solve higher-degree polynomials with this tool?

  • No, this solver handles exactly degree-3 equations. If a = 0, it reduces to a quadratic.
  • For degree 2: use the Quadratic Equation Solver for exact roots via the quadratic formula.
  • For degree 4 and above: closed-form solutions exist for degree 4 (Ferrari's method) but no general formula exists for degree ≥ 5 (Abel–Ruffini theorem).
  • Numerical methods like Newton-Raphson can approximate roots of any degree polynomial.

What is the casus irreducibilis?

  • When Δ > 0 (three real roots), Cardano's formula requires cube roots of complex numbers, even though the final answers are real.
  • This is the casus irreducibilis ("irreducible case"), it cannot be avoided using real-number arithmetic alone in Cardano's approach.
  • The trigonometric (Viète) method sidesteps this by rewriting the problem using cosines, keeping everything real.
  • This is why the two methods exist: Cardano for the Δ < 0 case; Viète for the Δ > 0 case.

When would I need to solve a cubic in practice?

  • Finding the roots of a cubic Bézier curve at a given y-value (used in computer graphics).
  • Solving certain kinematics problems: e.g. time at which a particle with cubic position law reaches a target.
  • Van der Waals equation of state (gas pressure) reduces to a cubic in volume.
  • Computing eigenvalues of 3×3 matrices involves solving the characteristic polynomial, a cubic.

Related Calculators