Cubic Equation Calculator for Real and Complex Roots

Discriminant-first cubic lab

Cubic Equation Calculator

Solve ax³ + bx² + cx + d = 0 for all three roots while keeping the algebra auditable. The lab normalizes the polynomial, removes the quadratic term, selects the stable real or complex branch, then checks every root and the three Vieta relationships.

Default: x³ − 6x² + 11x − 6 = 0Roots: 1, 2, and 3

Polynomial discriminant Δ = 4, so all three roots are real and distinct.

Enter cubic coefficients

The leading coefficient a must be nonzero. Scale-aware production solvers may need a relative tolerance; this educational calculator uses the entered absolute tolerance.

Root classification and audit

Root patternThree distinct real rootsEach root has multiplicity 1
Polynomial discriminant Δ4.000000positive
Substitutionx = y + 2.000000
Depressed coefficient p−1.000000
Depressed coefficient q0.000000
Root x₁1.000000Residual |f(x₁)|: 0.000e+0
Root x₂2.000000Residual |f(x₂)|: 0.000e+0
Root x₃3.000000Residual |f(x₃)|: 0.000e+0
Cardano branch value (q/2)² + (p/3)³−0.037037
Derivative critical points1.422650 and 2.577350
Largest root residual0.000e+0
Normalized equationx³ − 6x² + 11x − 6 = 0
Vieta audit

Sum roots: 6.000000 vs −b/a = 6.000000; pairwise sum: 11.000000 vs c/a = 11.000000; product: 6.000000 vs −d/a = 6.000000.

Rounded roots are for display. Residual and Vieta checks use the internal floating-point values. Near repeated roots are especially sensitive to coefficient rounding.

What a cubic solver must return

A genuine cubic has a nonzero x³ coefficient and exactly three complex roots when multiplicity is counted. Depending on the discriminant, those roots can be three distinct reals, a repeated real set, or one real plus a complex-conjugate pair for real coefficients.

The result panel never hides nonreal roots. It classifies the set, gives all three values, and reports multiplicity when the discriminant is numerically zero. If a equals zero, the equation is quadratic or lower and the calculator stops rather than silently switching formulas.

Normalize and depress the cubic

First divide by a to obtain x³ + Ax² + Bx + C = 0, where A = b/a, B = c/a, and C = d/a. Then use x = y − A/3 to eliminate the y² term. The result is y³ + py + q = 0.

p = B − A²/3
q = 2A³/27 − AB/3 + C

For the default, A = −6, B = 11, and C = −6. The substitution is x = y + 2. It produces p = −1 and q = 0, so the depressed equation is y³ − y = 0.

Polynomial discriminant

Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d²

For real coefficients, positive Δ indicates three distinct real roots. Zero indicates a repeated root. Negative Δ indicates one real root and two nonreal complex conjugates. The default Δ is 4, agreeing with its roots 1, 2, and 3.

Some references use the Cardano quantity DC = (q/2)² + (p/3)³. Its sign is opposite the root-pattern convention just described because Δ = −108a⁴DC. The interface labels both quantities to prevent a sign convention from being mistaken for a contradiction.

Three-real-root branch

When DC is negative, direct real cube-root radicals encounter the casus irreducibilis: intermediate complex values can appear even though all answers are real. The script instead uses a trigonometric form based on cosine, then sorts the three real roots for a predictable display.

yk = 2√(−p/3) cos[(φ + 2πk)/3]
φ = arccos[(3q/2p)√(−3/p)]

With p = −1 and q = 0, the shifted y roots are −1, 0, and 1. Adding 2 returns x = 1, 2, and 3.

One-real-root branch

When DC is positive, define u as the real cube root of −q/2 + √DC and v as the real cube root of −q/2 − √DC. The real depressed root is u + v. The other two combine −(u+v)/2 with imaginary parts ±√3(u−v)/2.

A real cube-root function must preserve the sign of a negative input. Using a generic fractional power can return NaN or a principal complex branch, so the implementation uses sign-aware real cube roots in this branch.

Repeated roots

When the discriminant is zero, at least two roots coincide. If p and q are both zero after the shift, all three roots are equal at −A/3. Otherwise, the depressed roots are 2u and −u twice, where u is the real cube root of −q/2.

Near-zero discrimination is delicate. Small coefficient changes can split a double root into separate real roots or a complex pair. Treat tolerance-based multiplicity as a numerical classification, and use exact arithmetic or higher precision when multiplicity matters.

Vieta checks

For ax³ + bx² + cx + d, the sum of all roots is −b/a, the sum of pairwise products is c/a, and the product is −d/a. These identities include complex roots and multiplicity. The default values are 6, 11, and 6.

Vieta relationships check the root set as a whole. A duplicated root and omitted root can sometimes hide in one aggregate, so the calculator also evaluates f(x) at each root. Independent checks are more convincing than one agreement.

Residual interpretation

A residual is |ax³ + bx² + cx + d| at a computed root. Zero indicates exact reconstruction in ideal arithmetic. Floating-point values can produce small residuals, especially after cancellation or for large coefficients.

An absolute residual should be compared with coefficient and root scale. A residual of one may be tiny in a polynomial whose terms are around 10¹⁶ and unacceptable when terms are near one. Specialist solvers use backward-error and conditioning analyses.

Turning points are not roots

The derivative is 3ax² + 2bx + c. When b² − 3ac is positive, it has two real critical points; zero gives one stationary point; negative gives no real turning point. The default critical x-values are approximately 1.422650 and 2.577350.

Critical points describe the graph’s local shape, not solutions of the original cubic. A three-real-root cubic must have two real critical points positioned so the curve crosses the axis three times, but derivative roots themselves usually do not make f(x) zero.

Numerical cancellation and scaling

Closed-form formulas are mathematically exact but can be numerically fragile when large nearly equal terms subtract. Coefficients with drastically different scales, clustered roots, and multiple roots are challenging. Rescaling x or using a tested polynomial eigensolver can improve production work.

The browser calculation uses JavaScript double precision. It is suitable for learning and moderate examples, not a substitute for arbitrary-precision algebra, interval methods, or certified roots in engineering and scientific systems.

Manual factor verification

When roots appear simple, multiply a(x − r₁)(x − r₂)(x − r₃). For the default, (x − 1)(x − 2)(x − 3) first gives x² − 3x + 2 times x − 3, producing x³ − 6x² + 11x − 6.

Cubic roots are not conversion factors; preserve the polynomial’s algebraic context.

Common input audit

CheckReason
Leading coefficienta must be nonzero for a cubic
SignsSubtraction errors change discriminant and roots
Equation sideMove every term to one side before entering coefficients
Coefficient orderEnter x³, x², x, then constant
ScaleVery large or small values may need specialist precision

Worked complex-conjugate example

For x³ − 1 = 0, enter a = 1, b = 0, c = 0, and d = −1. The polynomial discriminant is −27, so the real-coefficient cubic has one real root and a nonreal conjugate pair. The roots are 1, −1/2 + (√3/2)i, and −1/2 − (√3/2)i. Each root cubes to one.

The imaginary signs must be opposite because conjugating a polynomial evaluation with real coefficients is the same as evaluating at the conjugated input. If u + vi is a root, u − vi is therefore also a root. The pair contributes real values to the Vieta sum, pairwise sum, and product because their imaginary parts cancel. This is why all original coefficients can remain real even though two solutions are nonreal.

Root sensitivity to coefficient changes

Polynomial roots are outputs of the full coefficient vector, not independently rounded labels. A tiny change in d moves the curve vertically and can change whether it touches or crosses the axis near a repeated root. When Δ is near zero, a small perturbation can change the qualitative classification. Coefficients copied from measured or fitted data should not be treated as exact merely because they are displayed with many digits.

For a simple root r, the derivative f′(r) helps describe local sensitivity: if the slope is close to zero, a small function-value perturbation can require a comparatively large horizontal root movement. At a repeated root, f′(r) is zero, so the usual first-order correction becomes singular. Report input precision, residuals, and multiplicity assumptions together.

Exact forms versus decimal forms

A decimal solver is convenient for comparison and graphing, but it does not necessarily recover an exact radical or rational representation. The rational root theorem can identify candidate rational roots when coefficients are integers. Factoring out a verified rational root reduces the cubic to a quadratic and can yield cleaner exact results.

Do not infer exactness from a display such as 1.000000 unless substitution or symbolic algebra confirms it. Conversely, a root printed as 0.333333 may represent exactly 1/3 in a specially constructed equation. Preserve the original polynomial and state whether reported roots are exact, rounded, or numerical approximations.

Frequently asked questions

Why are there always three roots?

The fundamental theorem of algebra gives three complex roots counting multiplicity for a genuine cubic.

Can all three roots be complex?

With real coefficients, any nonreal roots form a conjugate pair, so at least one root is real.

What does a zero discriminant mean?

At least two roots repeat. Numerical near-zero values require careful tolerance and possibly higher precision.

Why does another source give the opposite discriminant sign?

It may report Cardano’s branch quantity rather than the polynomial discriminant. The two are related by a negative scale factor.

Can I enter a quadratic?

No. If a is zero, use a quadratic or linear solver rather than forcing the cubic method.

Are rounded roots exact?

Not necessarily. Use the residuals and retain internal precision; simple displayed integers may be exact for special coefficient sets.

References

NIST Digital Library of Mathematical Functions — Zeros of polynomials and cubic equations

Wolfram MathWorld — Cubic formula and discriminant cases

Wolfram MathWorld — Polynomial discriminant

Scroll to Top