# 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.

- Calculator id: `cubic-equation` · Category: Math (`math`) · Tool name: `solve_cubic_equation`
- Canonical page: https://tttkmbb.com/math/cubic-equation · This document: https://tttkmbb.com/math/cubic-equation.md · JSON definition: https://tttkmbb.com/math/cubic-equation.json

## Purpose

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.

**Use when:** 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).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `a` | number |  | required | Coefficient of x³. Must not be 0. |
| `b` | number |  | required | Coefficient of x². |
| `c` | number |  | required | Coefficient of x. |
| `d` | number |  | required | Constant term. |

## Output

| Field | 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). |

## 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.

## Data Sources

- Wikipedia – Cubic equation — https://en.wikipedia.org/wiki/Cubic_equation (reference, retrieved 2026-09-24)
- Wolfram MathWorld – Cubic Formula — https://mathworld.wolfram.com/CubicFormula.html (reference, retrieved 2026-09-24)
- Wikipedia – Discriminant — https://en.wikipedia.org/wiki/Discriminant (reference, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/cubic-equation?a=…&b=…&c=…&d=…`
- `POST https://tttkmbb.com/api/v1/calculate/cubic-equation` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/cubic-equation · OpenAPI operationId `solve_cubic_equation` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "cubic-equation", "inputs": {…}}`

## Example

- x³ − 6x² + 11x − 6 = 0: inputs `{"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: inputs `{"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
```

## Limitations

a is 0 (the equation is quadratic: use quadratic-equation) or the polynomial has degree 4 or more (use a numerical root finder). 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. All values are computed from the formula above; no measurement or live data is involved.

## 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

- [Quadratic Equation Solver](https://tttkmbb.com/math/quadratic-equation.md) — Second-degree equations and their discriminant.
- [Complex Number Calculator](https://tttkmbb.com/math/complex-numbers.md) — Arithmetic on the complex roots returned as strings.
- [Nth Root Calculator](https://tttkmbb.com/math/nth-root.md) — Cube roots used in Cardano's formula.
