# Solving the Cubic Equation (Algebra)

Often it is extremely difficult to figure out an algorithm, but once it is discovered, proving it is considerably easier, and in the case of the solving the cubic, it means what was impossible to do, is now possible.

In 1545, Cardan (or Cardano) published methods to solve the cubic and quartic equations. His great achievement was to make public the work of others, which had been previously kept secret. This method is based on Cardan's published method.

Consider the following equation: While I do not know how to solve equation , I do know how to solve cubic equations of the form: And I know how to reduce equation  to equation , so effectively I can solve equation .

### Reducing the Cubic

Any cubic of the form of equation  can be reduced to one of the form of equation  by substituting: The algebra is a bit messy, but when solving cubics, it is much easier. [2.01]
Let us expand [2.01], bit by bit: [2.02] [2.03] [2.04] [2.05]
And finally, and trivially, the constant. [2.05]

Now adding up the above (Noting t2 cancels out): [2a]

By comparing the coefficients of [2a] with , [2, repeated from above]

we find: and ## Solving the Reduced Cubic

First recall equation [2, repeated]

If p and q are zero, then t is zero. Otherwise, we consider the cases when the value of p or q is zero and when both aren't zero:

### The Cubic Reduces to Immediately Solvable Equations

If p=0, then equation , becomes: , and so If q=0, then equation  becomes: , and so t=0 or If p=0, then t=∛(-q), and the roots of the original equation are:
x1=∛(-q) - a/3 (using equation 3:  x=t-a/3)
x2,3=∛(-q)[-1/2± √(3)i/2] - a/3 (multiplying t by the irrational cubic roots of one:  -1/2+√(3)i/2, and -1/2-√(3)i/2)
If q=0, then we have t3+pt=0, giving t1=0, and t2,3 are the solutions to t2+p=0, or
x1=-a/3 (using equation 3: x=t-a/3)
x2,3=±√(-p)-a/3  (multiplying t by the two roots of one: +1 and (-1) )
Naturally, if p or q are zero, then we have solved the equation. If not, we continue.

### The Cubic Reduces to an Equation in p and q, Where Neither is Zero

The values of p and q in the equation below are not zero. [2, repeated]
So, we must solve this equation. Consider, that, for two numbers u and v: [Note: This is the cubic equivalent of completing the square in quadratics.]
And, if we substitute in  :
p=3uv, and
-q=u3-v3 and let t=u-v
We find that, because the result is zero, that u-v is a root of our equation. By finding the values of u and v, we will be able to solve the cubic. The reason will become clear.
We substitute for v, using: (Note that u cannot be zero, because p would also be zero, and we have dealt with that case above. So neither u nor v is zero here.)
in: To get: Multiplying throughout by u3: Now, this equation is a quadratic in u3, so we know how to solve it, and hence the cubic! Or, simplified: There are 3 roots of a cubic, and not 6, as promised with the above, but thankfully, we find that it doesn't matter which of the ± values we take, and normally, I just take the plus sign. The occasions which might cause problems have already been dealt with above. So, I will quietly drop the ±, and keep the +. (Naturally, the serious reader will check this is true!)
From equation 5, we can find v3: Quite clearly, the discriminant, D or Δ, is the bit in the square root. If  Δ=0, then all the roots are real, and at least two are equal.
If Δ>0, then √(Δ) is a real number, and so one root (the principal root) is real, and the other two are complex numbers.
If Δ<0, then √(Δ) is imaginary, so all the roots are real, and u and v will be complex numbers. This is the so called irreducible case from antiquity (of course, it isn't irreducible with complex arithmetic), when we need to use complex arithmetic.

Substituting Δ in 7 and 8, we have: And: ## The Value of the Discriminant Δ

Three possibilities for the value of Δ that affect how we proceed:

### All Roots Real, and Two Equal

If Δ=0, then from 10 and 11, taking cube roots, noting √(Δ)=0:  Notice that v1=-u1, when Δ=0.
Because t=u-v, and x=t-a/3
x=u-v-a/3 Also, x1=u1-v1-a/3
=2u1-a/3 (because v1=-u1) We can find the other x's by multiplying by the cube roots of one. (The complex numbers must be conjugate because 3uv=p, which is real):  As v1=-u1 x2,3=u2,3 - v2,3  -a/3 (because t=u-v, and x=t-a/3) So we add the corresponding parts The imaginary part vanishes, leaving us with: That is both of these roots are the same (and real). Or ### One Real and Two Complex Roots

Here, Δ is not negative, so the square root is a real number. We continue from Equation 7  and reproduce the equations below, as a reminder:  The discriminant is: Substituting Δ in Equations 7, 8:  Taking cube roots, we find:   Remembering that t=u-v, and x=t-a/3, we have:
So: We can find the other u's using the cube roots of unity, but we need to note that the complex root of unity used for, v2, or v3 is the complex conjugate of the root used for the corresponding u2, u3. This is so because 3uv=p, a real number, so the imaginary parts must vanish.
If : Then v2 has the conjugate complex number: Again we use the formula: x=u-v-a/3: So, by simplifying, we get: And, similarly: So: We have now solved the equation 1, if two of the roots are complex and the other real.

### All the Roots Are Real and Different (Called the Irreducible Case)

Whilst with the quadratic when all the roots are real, the discriminant is also real, the cubic is different in that when all the roots are real and different, the discriminant (Δ) is a complex number.
We will remind ourselves of some basic equations which we have derived earlier:  The discriminant is: Substituting Δ in Equations 7, 8:  Taking cube roots, we find:  So, in this case, Δ is negative, so √(Δ) is an imaginary number. If Δ <0, then √(Δ)=√(-Δ)i. Therefore:  To discover the cube roots, we note that the complex number is of the form a+bi. When we convert to trigonometric form, absolute value of the complex number, r=√(a2+b2). The argument or phase, φ is the slope of r. The complex number, (a+bi) can be represented as r(cos (φ) +i sin (φ) ), where cos (φ)=a/r, and sin (φ)=b/4. For our cube root, de Moivre's law is: First, it is noticeable that the "r" for both u3 and v3 is the same. Also note that cos(φv)=-cos( iφu), and sin(φv)=sin( iφu), because the real parts of u and v have an opposite sign and the imaginary bits have the same sign.

#### Trigonometric Representation of u3

We find r2 using the normal formula for the absolute value of a complex number: Expanding Δ (it becomes minus): The q's cancel out leaving the p term: Finally, take the square root: Now we know r, and we can find cos(φ): We need φ for our calculations, and now we will go on to find the u's and v's and therefore the x's:  #### Finding u and v

Similarly, noting that for v, the r value is the same, the cosine negative, and the sign the same as the u value, we can just write down the v: Our first x, calling it x1=u1-v1-a/3 Because we know or can compute the value of the cosine, (getting phi from the inverse cosine, and dividing it by 3, etc), we have only to deal with the remaining x's. We simply add multiples of 2π to the old φ values. So:  The values cycle for further multiples of 2π

### Summary

We start with our normalised equation (that is, coefficient of xn is 1): Our ideal equation is: Where:  But we would normally find it by substituting x=t-a/3 and expand ans simplify to get Equation 2
If p or q or both are zero, then the equation is easily solved.
The secret to solving this equation is: And noticing: So 3uv=p, and u3 -v3=-q
The discriminant of the cubic is: The u and v values are:    We now have all the information needed to solve any cubic, but if  √(Δ) is a complex number, it is hard to solve Equations 18 and 19.
Therefore, we use trigonometry:  We use Equations 32 and 33 to find r and phi, finding phi with the inverse cosine.
The x's are then:   # Faster Arithmetic - by Ken Ward

Ken's book is packed with examples and explanations that enable you to discover more than 150 techniques to speed up your arithmetic and increase your understanding of numbers. Paperback and Kindle:
Buy now at Amazon.com 