Home › Math › Cubic Equation Solver
Cubic Equation Solver
Solves ax³ + bx² + cx + d = 0 by depressing the cubic and applying Cardano's formula (one real root) or the trigonometric method (three real roots), and reports the discriminant, the nature of the roots and every root, complex roots as strings.
When to use
You need the solutions of a third-degree polynomial equation, including repeated roots and complex conjugate pairs.
Do not use when: a is 0 (the equation is quadratic: use quadratic-equation) or the polynomial has degree 4 or more (use a numerical root finder).
Formula
Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d²; x = t − b/(3a) gives t³ + pt + q = 0. Δ > 0: t_k = 2√(−p/3)·cos(⅓·arccos((3q/(2p))·√(−3/p)) − 2πk/3), k = 0, 1, 2. Δ < 0: u = ∛(−q/2 + √(q²/4 + p³/27)), v = ∛(−q/2 − √(q²/4 + p³/27)), real root u + v, complex pair −(u + v)/2 ± i·(u − v)·√3/2. Δ = 0: double root −3q/(2p) and simple root 3q/p (triple root t = 0 when p = q = 0).
Real roots from the closed forms are refined with up to three Newton steps on the original polynomial; a discriminant within 10^-10 of the size of its terms is treated as zero.
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
a | number | yes | Coefficient of x³. Must not be 0. | |
b | number | yes | Coefficient of x². | |
c | number | yes | Coefficient of x. | |
d | number | yes | Constant term. |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
discriminant | number | Δ = 18abcd − 4b³d + b²c² − 4ac³ − 27a²d²; positive → three distinct real roots, zero → a repeated root, negative → one real root and a complex pair. | |
nature | string | Classification of the roots from the sign of the discriminant. | |
roots | string | All three roots as text: real roots in ascending order, complex roots written like '0+1i, 0-1i'. | |
root1 | number | Smallest real root. | |
root2 | number | Middle real root (only when all three roots are real). | |
root3 | number | Largest real root (only when all three roots are real). | |
real_roots | number_list | Real roots in ascending order; a repeated root is listed once per multiplicity. | |
depressed_p | number | p = c/a − b²/(3a²) in t³ + pt + q = 0, obtained with x = t − b/(3a). | |
depressed_q | number | q = 2b³/(27a³) − bc/(3a²) + d/a. | |
sum_of_roots | number | −b / a (Vieta's formula). | |
product_of_roots | number | −d / a (Vieta's formula). |
Example
x³ − 6x² + 11x − 6 = 0: {"a":1,"b":-6,"c":11,"d":-6} → {"discriminant":4,"nature":"Three distinct real roots","roots":"1, 2, 3","root1":1,"root2":2,"root3":3,"real_roots":[1,2,3],"depressed_p":-1,"depressed_q":0,"sum_of_roots":6,"product_of_roots":6}
x³ + x² + x + 1 = 0: {"a":1,"b":1,"c":1,"d":1} → {"discriminant":-16,"nature":"One real root and two complex conjugate roots","roots":"-1, 0+1i, 0-1i","root1":-1,"real_roots":[-1],"sum_of_roots":-1,"product_of_roots":-1}
GET https://tttkmbb.com/api/v1/calculate/cubic-equation?a=1&b=-6&c=11&d=-6
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/cubic-equation(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/cubic-equation · Markdown: https://tttkmbb.com/math/cubic-equation.md · JSON definition: https://tttkmbb.com/math/cubic-equation.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="cubic-equation" - OpenAPI operationId:
solve_cubic_equation - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- Wikipedia – Cubic equation (reference)
- Wolfram MathWorld – Cubic Formula (reference)
- Wikipedia – Discriminant (reference)
FAQ
Why does a cubic always have at least one real root?
A real cubic polynomial tends to −∞ on one side and +∞ on the other, so it must cross the x-axis; the other two roots are either real or a complex conjugate pair.
How are repeated roots reported?
A double root appears twice in real_roots (e.g. x³ − 3x + 2 gives [-2, 1, 1]) and a triple root three times; nature names the multiplicity.
Why the trigonometric method for three real roots?
When Δ > 0 Cardano's formula needs cube roots of complex numbers (the casus irreducibilis); the trigonometric identity for cos 3θ gives the three real roots directly.
Related calculators
- Quadratic Equation Solver — Second-degree equations and their discriminant.
- Complex Number Calculator — Arithmetic on the complex roots returned as strings.
- Nth Root Calculator — Cube roots used in Cardano's formula.