Cubic Polynomial Calculator: Solve & Explain
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
This calculator solves a cubic polynomial of the form ax³ + bx² + cx + d = 0 for real and complex roots, given the coefficients a, b, c, and d. You enter the four coefficients, and you get back all three roots (including complex ones when they exist), plus the discriminant and a step-by-step explanation of the method used. It handles the general case with Cardano’s formula, so it works for any cubic, not just those with nice integer roots.
Formula
The general cubic equation is:
ax³ + bx² + cx + d = 0, where a ≠ 0.
To solve it, we first compute the discriminant Δ (delta):
Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d²
The sign of Δ tells you the nature of the roots:
- Δ > 0 : three distinct real roots
- Δ = 0 : multiple roots (at least two equal, or a triple root)
- Δ < 0 : one real root and two complex conjugate roots
For the actual roots, we use a method based on Cardano’s formula. Define:
p = (3ac − b²) / (3a²)
q = (2b³ − 9abc + 27a²d) / (27a³)
Then the three roots are:
x₁ = 2√(−p/3) · cos( (1/3) arccos( (3q/(2p)) · √(−3/p) ) − 2π/3 ) − b/(3a)
x₂ = 2√(−p/3) · cos( (1/3) arccos( (3q/(2p)) · √(−3/p) ) ) − b/(3a)
x₃ = 2√(−p/3) · cos( (1/3) arccos( (3q/(2p)) · √(−3/p) ) + 2π/3 ) − b/(3a)
This trigonometric form works cleanly for the case of three real roots (Δ ≥ 0). For Δ < 0, the arccos argument goes outside [−1, 1], and you must use the hyperbolic or algebraic (Cardano) form with complex numbers. The calculator above implements the full algebraic Cardano solution that handles all cases, including complex roots, using cube roots of possibly complex numbers.
Worked Example
Let’s solve the cubic: x³ − 6x² + 11x − 6 = 0 (the default values).
Here a = 1, b = −6, c = 11, d = −6.
Step 1 – Compute the discriminant:
Δ = 18(1)(−6)(11)(−6) − 4(−6)³(−6) + (−6)²(11)² − 4(1)(11)³ − 27(1)²(−6)²
= 7128 − 3456 + 4356 − 5324 − 972 = −268
Since Δ < 0, there is one real root and two complex conjugate roots.
Step 2 – Compute p and q:
p = (3(1)(11) − (−6)²) / (3(1)²) = (33 − 36)/3 = −1
q = (2(−6)³ − 9(1)(−6)(11) + 27(1)²(−6)) / (27(1)³) = (−432 + 594 − 162)/27 = 0
Step 3 – Apply the algebraic Cardano formula. Since q = 0, the roots simplify nicely:
Let u = cbrt(−q/2 + √(Δ/108)) = cbrt(0 + √(−268/108)) = cbrt(√(−2.48148)) ≈ cbrt(1.575i)
In complex cube roots, this yields u = 1.1447 + 0.6603i (approximately). Then the three roots are given by:
x₁ = u + v − b/(3a), x₂ = uω + vω² − b/(3a), x₃ = uω² + vω − b/(3a)
where v = −p/(3u) and ω = −1/2 + i√3/2.
After simplification (or using a computer algebra system), we get:
x₁ = 1, x₂ = 2, x₃ = 3
Indeed, the polynomial factors as (x−1)(x−2)(x−3) = 0, so the roots are 1, 2, and 3. The calculator gives these as 1.000000, 2.000000, 3.000000 (with tiny rounding errors from the numerical method).
When to Use a Cubic Polynomial Calculator
You’ll likely need this when:
- You’re solving a cubic equation in algebra, precalculus, or calculus class.
- You’re finding critical points of a cubic function (setting the derivative, a quadratic, to zero is easier, but the original cubic may appear in optimization problems).
- You’re working with cubic splines in numerical analysis or computer graphics.
- You’re analyzing cubic Bezier curves or other parametric curves.
- You’re solving physics or engineering problems that involve cubic relationships, such as van der Waals equation of state.
In many practical cases, you might only need the real root. But the calculator gives all three, so you can see the complete solution set. For example, in a cubic Bezier curve, the roots of a cubic equation tell you where the curve crosses a horizontal line, and complex roots simply mean no crossing.
How to Read the Results
The calculator outputs three roots (x₁, x₂, x₃) and the discriminant. Here’s how to interpret them:
- Real roots are shown as plain numbers (e.g., 2.000000).
- Complex roots are shown in the form a + bi (e.g., 1.500000 + 0.866025i).
- The discriminant tells you the nature of the roots before you even look at them. If it’s positive, all three roots are real and distinct; if zero, there’s a repeated root; if negative, one real and two complex.
Always check that the coefficient ‘a’ is not zero. If a = 0, the equation is actually quadratic, and this calculator won’t work correctly (it would divide by zero).
Common Mistakes and Pitfalls
- Misreading the sign of coefficients: For example, the equation x³ − 6x² + 11x − 6 = 0 has b = −6, not 6. A sign error changes every root.
- Assuming all roots are real: Many cubics have complex roots. If the discriminant is negative, you’ll get one real and two complex roots – that’s not an error.
- Rounding too early: If you round intermediate values in Cardano’s formula, you can get significant errors. The calculator uses high precision internally, but when you copy results, keep at least 6 decimal places.
- Forgetting that a ≠ 0: If you enter a = 0, the formula breaks. Check your equation is truly cubic.
- Using the quadratic formula on a cubic: That only works if one root is known and you factor it out.
Limits of the Formula and Calculator
Cardano’s formula is exact but involves cube roots of complex numbers, which can be tricky to evaluate by hand. The calculator handles this internally, but you should know:
- Numerical precision is about 10⁻⁶, so roots are rounded to 6 decimal places. For exact answers (like √2), you’ll get a decimal approximation.
- The formula assumes a ≠ 0. If a is very small but not zero, the equation is nearly quadratic, and numerical instability can occur. In such cases, consider solving the quadratic after factoring out the small root.
- For real-world data, coefficients often have measurement errors. A small change in coefficients can cause a large change in roots, especially near multiple roots. This is called ill-conditioning.
Alternative Methods
If you don’t have a cubic calculator, you can try:
- Rational Root Theorem: Test possible rational roots (factors of d divided by factors of a). If you find one, factor it out and solve the remaining quadratic.
- Graphical method: Plot the function and estimate the x-intercepts. This gives approximate real roots.
- Numerical methods: Newton’s method or bisection can find real roots to high precision.
- Computer algebra systems: Software like Mathematica, Maple, or even Python’s sympy can solve cubics symbolically.
Each method has trade-offs: the rational root theorem is fast but only works for rational roots; numerical methods are versatile but require initial guesses and only give real roots.
Frequently Asked Questions
Can this calculator find complex roots?
Yes. It uses the full Cardano formula with complex arithmetic, so it returns both real and complex roots. If the discriminant is negative, you’ll see one real root and two complex conjugates (e.g., 1.000000 + 0.000000i and 1.500000 ± 0.866025i).
What if my equation is not in standard form?
You must rearrange it to the form ax³ + bx² + cx + d = 0. For example, x³ = 2x + 1 becomes x³ − 2x − 1 = 0, so a=1, b=0, c=−2, d=−1. Enter zero for any missing term.
Why does the calculator show three roots when my graph only crosses the x-axis once?
That’s because the other two roots are complex numbers, which don’t appear on the real plane. The graph shows only real roots. Complex roots always come in conjugate pairs when the coefficients are real, which is why you get one real and two complex for Δ < 0.
How accurate are the results?
Results are rounded to 6 decimal places. For most purposes, that’s more than enough. If you need exact values, you should use symbolic computation, but for numerical answers, this precision is fine.
What does the discriminant tell me exactly?
The discriminant Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d². If Δ > 0, three distinct real roots; Δ = 0, a multiple root; Δ < 0, one real and two complex. It's a quick way to know what kind of roots to expect without solving.
Can I use this for a quadratic equation?
No, this is specifically for cubic equations. For a quadratic ax² + bx + c = 0, use a quadratic formula calculator. If you set a = 0 in a cubic, the formula fails because division by zero occurs.
Related
Formula used
in a | Coefficient a | - | 1 | 0 in b | Coefficient b | - | -6 | 0 in c | Coefficient c | - | 11 | 0 in d | Coefficient d | - | -6 | 0 out x1 | First root | - | (-b/(3a)) - (cbrt(2)*(-b^2+3ac))/(3a*cbrt(-2b^3+9abc-27a^2*d+sqrt(-4*(-b^2+3ac)^3+(-2b^3+9abc-27a^2*d)^2))) + (cbrt(-2b^3+9abc-27a^2*d+sqrt(-4*(-b^2+3ac)^3+(-2b^3+9abc-27a^2*d)^2)))/(3a*cbrt(2)) | 6 out x2 | Second root | - | -(-b/(3a)) + (cbrt(2)*(-b^2+3ac))/(3a*cbrt(-2b^3+9abc-27a^2*d+sqrt(-4*(-b^2+3ac)^3+(-2b^3+9abc-27a^2*d)^2))) - (cbrt(-2b^3+9abc-27a^2*d+sqrt(-4*(-b^2+3ac)^3+(-2b^3+9abc-27a^2*d)^2)))/(3a*cbrt(2)) | 6 out x3 | Third root | - | (-b/(3a)) + (cbrt(2)*(-b^2+3ac))/(3a*cbrt(-2b^3+9abc-27a^2*d+sqrt(-4*(-b^2+3ac)^3+(-2b^3+9abc-27a^2*d)^2))) - (cbrt(-2b^3+9abc-27a^2*d+sqrt(-4*(-b^2+3ac)^3+(-2b^3+9abc-27a^2*d)^2)))/(3a*cbrt(2)) | 6 out disc | Discriminant | - | 18abcd-4b^3*d+b^2*c^2-4ac^3-27a^2*d^2 | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.