# Trigonometry/The solution of cubic equations

A cubic equation is an equation of the form

ax3 + bx2 + cx + d = 0

to be solved for x. There are three possible values for x, known as the roots of the equation, though two or all three of the values may be equal (repeated root). If a, b, c and d are all real numbers, at least one value of x must be real. There are two possible cases: the other two roots may be real, or they may be a pair of complex conjugate numbers.

The roots can always be expressed exactly as surds. However, if all three roots are real, the surds involve the cube roots of complex numbers. In that case, they are in general most easily calculated using trigonometric functions.

In the above equation, a is non-zero (or the equation would be quadratic). Divide through by a to get the equation in the form

x3 + Ax2 + Bx + C = 0.

Let

$Q = \frac{3B-A^2}{9}, \,\, R = \frac{9AB - 27C -2A^3}{54}, \,\, D = Q^3+R^2.$

D is called the discriminant. If D > 0, two roots are complex; if D = 0 there is a (real) repeated root; if D < 0 there are three unequal real roots.

Assume D < 0. Clearly, Q3 = D-R2 must be less than D so is also negative; thus, -Q3 and -Q are both positive. Let

$\cos (\theta) = \frac{R}{\sqrt{-Q^3}}.$

Then the three roots are

$x_1 = 2\sqrt{-Q} \cos \left( \frac{\theta}{3} \right) - \frac{A}{3}$
$x_2 = 2\sqrt{-Q} \cos \left( \frac{\theta}{3} + 120^O \right) - \frac{A}{3}$
$x_3 = 2\sqrt{-Q} \cos \left( \frac{\theta}{3} + 240^O \right) - \frac{A}{3}$