🔢 Cubic Equation Solver – Find All Roots of ax³ + bx² + cx + d = 0
A cubic equation is any polynomial equation of degree three, written in the standard form ax³ + bx² + cx + d = 0 where a ≠ 0. Unlike a quadratic that has at most two roots, every cubic with real coefficients has exactly three roots (counting multiplicity), though some may be complex. This tool solves any cubic instantly — returning all roots, a discriminant, a graph, and an optional step-by-step derivation.
📐 How Are Cubic Equations Solved?
The standard analytical path follows three stages: normalization, depression, and root extraction.
Stage 1 — Normalize
Divide every term by the leading coefficient a to produce:
x³ + Ax² + Bx + C = 0
where A = b/a, B = c/a, C = d/aStage 2 — Depress (Eliminate the x² Term)
Substitute x = t − A/3. This eliminates the quadratic term and yields the depressed cubic:
t³ + pt + q = 0
p = B − A²/3
q = 2A³/27 − AB/3 + CThe depressed form has only two parameters and is the foundation of all classical methods.
Stage 3 — Extract Roots
The solving method depends on the sign of the cubic discriminant Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d²:
| Discriminant Δ | Root Configuration | Method Used |
|---|---|---|
| Δ > 0 | Three distinct real roots | Trigonometric (casus irreducibilis) |
| Δ = 0 | Repeated root (double or triple) | Simplified Cardano formulas |
| Δ < 0 | One real root + two complex conjugates | Cardano's formula |
🔬 Cardano's Formula
When Δ < 0, Cardano's formula solves the depressed cubic directly. Define the Cardano discriminant:
Δ_c = (q/2)² + (p/3)³Then compute:
u = ∛(−q/2 + √Δ_c)
v = ∛(−q/2 − √Δ_c)
Real root: t = u + v, so x = t − A/3
Complex roots: x = −(u+v)/2 ± i(√3/2)|u−v| − A/3🌀 Trigonometric Method (Three Real Roots)
When Δ > 0, all three roots are real. Cardano's formula would involve the cube root of a complex number (the casus irreducibilis), so the elegant trigonometric method is used instead:
m = 2√(−p/3)
θ = (1/3) · arccos(3q / (pm))
x_k = m · cos(θ − 2πk/3) − A/3 for k = 0, 1, 2📊 What the Graph Shows
The interactive graph plots the cubic curve y = ax³ + bx² + cx + dover an auto-scaled range centered on the roots. Color-coded markers highlight:
- Green dots — real roots (x-intercepts where
y = 0) - Orange dot — y-intercept (
x = 0, equalsd) - Red dot — local maximum (where
f′(x) = 0, concave down) - Blue dot — local minimum (where
f′(x) = 0, concave up)
Critical points are found by solving the derivative f′(x) = 3ax² + 2bx + c = 0 as a standard quadratic.
The sign of Δclassifies the roots before any calculation. Δ > 0 guarantees three real crossings on the graph. Δ < 0 means the curve crosses the x-axis exactly once. Δ = 0 means the curve touches the x-axis without crossing at the repeated root.
🔁 Root Multiplicity
When Δ = 0 the cubic has a repeated root. If both depressed parameters p and q are zero, the root is a triple root at x = −b/(3a). Otherwise there is one double root and one simple root. The tool labels each root's multiplicity so you know whether the curve touches or crosses the x-axis.
📋 Worked Example: Three Distinct Roots
x³ − 6x² + 11x − 6 = 0 (a=1, b=−6, c=11, d=−6)
Δ = 18(1)(−6)(11)(−6) − 4(−6)³(−6) + ... = 4 > 0
Three distinct real roots: x = 1, x = 2, x = 3
Factored: (x−1)(x−2)(x−3)📋 Worked Example: Complex Roots
x³ + x + 1 = 0 (a=1, b=0, c=1, d=1)
Δ < 0 → one real root + two complex conjugates
Real root ≈ −0.6824
Complex roots ≈ 0.3412 ± 1.1615i🎓 Applications of Cubic Equations
Cubic equations appear throughout science, engineering, and mathematics:
- Physics: van der Waals equation of state for real gases involves a cubic in volume
- Engineering: beam deflection, structural load calculations, and fluid dynamics often produce cubic polynomials
- Computer graphics: Bézier curve intersections and parametric surface computations
- Economics: cubic cost and revenue functions for optimization
- Algebra coursework: factoring cubics, rational roots, and polynomial long division
⚠️ Accuracy and Limitations
This solver uses 64-bit floating-point arithmetic. Results are accurate to about 12–14 significant digits for well-conditioned inputs. Very large coefficient magnitudes (e.g., |a| > 10¹²) or very close roots may introduce rounding errors. The repeated-root detector uses a tolerance of 1×10⁻⁹, so near-but-not-exact repeated roots are reported as distinct. For exact symbolic results in algebra coursework, verify with rational root theorem or polynomial long division after identifying a rational root numerically.