# Third degree equation

Let the generic equation ax3+bx2+cx+d = 0. Dividing by a, then substituting x = y+h :
(y+h)3+b(y+h)2/a+c(y+h)/a+d/a = 0. Expanding this expression, the y2 term is (3h+b/a)y2.
We can then choose h = -b/3a so as to get the "canonical" equation :

 x3+px+q = 0.

Let x = u+v : u3+v3+3uv(u+v)+p(u+v)+q = 0
We can assume 3uv+p = 0, hence u3+v3 = -q and u3v3 = -p3/27
u3 and v3 are then solutions of :
Z2+qZ-p3/27 = 0
This second degree equation can easily be solved. Its discriminant is Δ = q2+4p3/27 = 4(q2/4+p3/27)
Let u03, v03 the solution.
Let ε = (-1+i√3)/2 a primitive cubic root of 1. All solutions of X3 = 1 are then 1, ε and ε 2
Even more ε 2 = (-1-i√3)/2 is the conjugate of ε and εε 2 = ε 3 = 1
We can then write the formulaes for the 3rd degrée equation (Cardan's) :

If Δ is positive, u03 and v03 are real numbers, x0 = u0+v0 also, x1 and x2 are conjugate imaginary numbers
If Δ<0, u0 and v0 are conjugate imaginary numbers and the three roots are real numbers.

Unfortunatly, this theoretical solving method is not usefull in practice.
Take as example (x-1)(x-2)(x+3) = x3-7x+6 = 0 with simple roots 1,2 and -3
Δ = -400/27 being negative, the three roots are real.
But find a cubic root of -3 ± i√(100/27) is a hard job.
Even with Δ > 0, for instance (x-1)(x2+x+2) = x3+x-2 = 0, which hast the simple real root 1 and two conjugate complex solutions.
Δ = 4x28/27. although could you see that :

In practice, solving a 3rd degree equation is done by successive approximations, unless we find a "trivial" solution (like 0, 1, -1 ...)
A script using the Newton method.