Cubic Equation Calculator and Solver

A calculator for the solutions of the general cubic equations is presented at the bottom of the page. We also present the formulas that give the solutions to the general cubic equation that has the form: \[ A x^3 + B x^2 + C x + D = 0 \] This equation can be solved using Cardano's method; but we first requires converting it into a depressed cubic (one without an \(x^2\) term).

Convert The General Cubic Equation to a Depressed Cubic

First, divide by \( A \) (assuming \( A \neq 0 \)): \[ x^3 + \frac{B}{A} x^2 + \frac{C}{A} x + \frac{D}{A} = 0 \] Now, perform the Tschirnhaus transformation by substituting: \[ x = t - \frac{B}{3A} \] This eliminates the \( t^2 \) term and transforms the equation into: \[ t^3 + p t + q = 0 \] where: \[ p = \frac{3AC - B^2}{3A^2}, \quad q = \frac{2B^3 - 9ABC + 27A^2D}{27A^3} \]

Solve the Depressed Cubic

The nature of the roots of the depressed Cubic \( t^3 + pt + q = 0 \) are given by Cardano's formula and they depend the discriminant \( \Delta \) given by: \[ \Delta = \left( \frac{q}{2} \right)^2 + \left( \frac{p}{3} \right)^3 \] We have three cases depending on the sign of \( \Delta \) .
  1. If \( \Delta \gt 0 \): One real root and two complex conjugate roots.

    The real root is given by Cardano's formula: \[ t_1 = \sqrt[3]{ -\frac{q}{2} + \sqrt{\Delta} } + \sqrt[3]{ -\frac{q}{2} - \sqrt{\Delta} } \] where: \[ \Delta = \left( \frac{q}{2} \right)^2 + \left( \frac{p}{3} \right)^3 \] The two complex roots are obtained by multiplying the cube roots by the complex cube roots of unity: \[ t_2 = \omega \cdot t_1, \quad t_3 = \omega^2 \cdot t_1 \] where: \[ \omega = e^{2\pi i /3} = \frac{-1 + i\sqrt{3}}{2}, \quad \omega^2 = e^{-2 \pi i /3} = \frac{-1 - i\sqrt{3}}{2} \] So: \[ t_2 = \omega \cdot \sqrt[3]{ -\frac{q}{2} + \sqrt{\Delta} } + \omega^2 \cdot \sqrt[3]{ -\frac{q}{2} - \sqrt{\Delta} } \] \[ t_3 = \omega^2 \cdot \sqrt[3]{ -\frac{q}{2} + \sqrt{\Delta} } + \omega \cdot \sqrt[3]{ -\frac{q}{2} - \sqrt{\Delta} } \] Finally, the original roots of the cubic equation are: \[ x_k = t_k - \frac{B}{3A}, \quad (k = 1,2,3) \]
  2. If \( \Delta = 0 \): Three real roots, at least two are equal.

    If \( p = q = 0 \), then \( x = -\frac{B}{3A} \) is a triple root.
    Otherwise, there is one distinct real root and one double root: \[ t_1 = 2\sqrt[3]{-\frac{q}{2}} \] \[ t_2 = t_3 = -\sqrt[3]{-\frac{q}{2}} \] So the roots are: \[ x_1 = t_1 - \frac{B}{3A}, \quad x_2 = x_3 = t_2 - \frac{B}{3A} \]
  3. If \( \Delta \lt 0 \): Three distinct real roots, given by a trigonometric formula.

\[ t_k = 2\sqrt{-\frac{p}{3}} \cos\left( \frac{\theta + 2k\pi}{3} \right), \quad k = 0,1,2 \] where: \[ \cos \theta = \frac{-q}{2} \sqrt{-\frac{27}{p^3}} \quad \text{or} \quad \theta = \arccos \left( \frac{-q}{2} \sqrt{-\frac{27}{p^3}} \right) \] The roots are: \[ x_k = t_k - \frac{B}{3A}, \quad (k=0,1,2) \]

Calculator and Solver of General Cubic Functions

The above formulas have been used to develop the following calculator.

Enter coefficients \( A \) , \( B \) , \( C \) and \( D \) of the equation (\( A \ne 0 \)) \[ A x^3+ B x^2 + C x + D = 0 \]:

with the Number of Decimals

Roots:

More References and links

Maths Calculators and Solvers.