Solving the Cubic Equation (Algebra)

On this page:
  1.  Reducing the Cubic
    1. The Cubic Reduces to Immediately Solvable Equations
    2. The Cubic Reduces to an Equation in p and q, Where Neither is Zero 
  2. The_Value_of_the_Discriminant_Δ
    1. The Discriminant Δ is Zero: All Roots Real, and Two Equal
    2. The Discriminant Δ is negative: One Real and Two Complex Roots
    3. The Discriminant Δ is positive: All the Roots Are Real and Different (Called the Irreducible Case)
      1. Trigonometric Representation of u3
      2. Finding u and v
  3. Summary
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:
normalised Cubic [1]
While I do not know how to solve equation [1], I do know how to solve cubic equations of the form:
reduced cubic [2]
And I know how to reduce equation [1] to equation [2], so effectively I can solve equation [1].

Reducing the Cubic

Any cubic of the form of equation [1] can be reduced to one of the form of equation [2] by substituting:
3 [3]
The algebra is a bit messy, but when solving cubics, it is much easier.

equation 2 [2.01]
Let us expand [2.01], bit by bit:



b(t − a╱3) = bt − a b╱3[2.04]

And finally, and trivially, the constant.
c = c[2.05]

Now adding up the above (Noting t2 cancels out):

By comparing the coefficients of [2a] with [2],

[2, repeated from above]

we find:
coefficient p
coefficient q

Solving the Reduced Cubic

First recall equation [2]
reduced cubic [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:

  1. p or q is zero: The Cubic Reduces to an Immediately Solvable Form
  2. p and q are not zero: The Cubic Reduces to an Equation in p and q

The Cubic Reduces to Immediately Solvable Equations

If p=0, then equation [2], becomes:

 p=0, and so  

If q=0, then equation [2] becomes:

q=0 , 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. reduced cubic [2, repeated]
So, we must solve this equation. Consider, that, for two numbers u and v:
equation completing the cube

[Note: This is the cubic equivalent of completing the square in quadratics.]
And, if we substitute in [2] :
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:
vInTermsOfu.gif [4]
(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.)
u3-v3=-q.gif [5]
To get:
Multiplying throughout by u3:
u6-q3-(pdiv3)3=0.gif [6]
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:
v3=(+qDiv2.gif [8]
Quite clearly, the discriminant, D or Δ, is the bit in the square root.
cubicDiscriminant.gif [9]
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:
u3=(-qDiv2+Root(Delta).gif [10]
v3=(qDiv2+Root(Delta).gif [11]

The Value of the Discriminant Δ

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

  1. Δ is zero: All Roots Real, and Two Equal
  2. Δ is positive: One Real and Two Complex Roots
  3. Δ is negative: All the Roots Are Real and Different (Called the Irreducible Case)

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
Also, x1=u1-v1-a/3
=2u1-a/3 (because v1=-u1)

x1=2(3Root(-qDiv2)-aDiv3.gif [12]
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):

u(2,3)=u1(-0.5+-3Root(3)Div2).gif [13]
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:
x2,3=-u1-aDiv3.gif  [15]
That is both of these roots are the same (and real).
x2,3=-3Root(-qdiv2)-aDiv3 [16]
x2,3=3Root(qdiv2)-aDiv3.gif [17]

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:
u3=(-qDiv2.gif [7]
v3=(+qDiv2.gif [8]
The discriminant is:
cubicDiscriminant.gif [9]
Substituting Δ in Equations 7, 8:
u3=(-qDiv2+Root(Delta).gif [10]
v3=(qDiv2+Root(Delta).gif [11]
Taking cube roots, we find:
u=3Root(-qDiv2+Root(D)).gif [18]

v=3Root(qDiv2+Root(D)).gif [19]

Remembering that t=u-v, and x=t-a/3, we have:
x1=u1-v1-aDiv3.gif [20]
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 :
u2=u1(-0.5+Root(3)Div2)-aDiv3.gif [21]
Then v2 has the conjugate complex number:

Again we use the formula: x=u-v-a/3:
So, by simplifying, we get:
x2=-0.5(u1-v1)+(u1+v1)Root(3)Div2i-aDiv3.gif [23]

And, similarly:
x3=-0.5(u1-v1)-(u1+v1)Root(3)Div2-aDiv3.gif [24]
x2,3=-0.5(u1-v1)+-(u1+v1)Root(3)Div2i)-aDiv3.gif [25]
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:
u3=(-qDiv2.gif [7]
v3=(+qDiv2.gif [8]
The discriminant is:
cubicDiscriminant.gif [9]
Substituting Δ in Equations 7, 8:
u3=(-qDiv2+Root(Delta).gif [10]
v3=(qDiv2+Root(Delta).gif [11]
Taking cube roots, we find:
u=3Root(-qDiv2+Root(D)).gif [18]

v=3Root(qDiv2+Root(D)).gif [19]
So, in this case, Δ is negative, so √(Δ) is an imaginary number. If Δ <0, then √(Δ)=√(-Δ)i. Therefore:
uPower3=(-qDiv2+Root(-Delta)i.gif [26]
vpower3=(qDiv2+Root(-Delta)i.gif [27]
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:
cubicDeMorgan.gif [28]

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:rpow2=(-qDiv2)pow2+(Root(-Delta)pow2.gif  [29]
Expanding Δ (it becomes minus):
rpow2=(-qDiv2)pow2-((qDiv2)pow2+(pDiv3)pow3).gif  [30]
The q's cancel out leaving the p term:
rpow2=(-pDiv3)pow3.gif  [31]
Finally, take the square root:
r=Root((-pDiv3)pow3).gif  [32]

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π


We start with our normalised equation (that is, coefficient of xn is 1):
normalised Cubic [1]
Our ideal equation is:
reduced cubic [2]
coefficient p
coefficient q
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:
note equation
And noticing:
note equation
So 3uv=p, and u3 -v3=-q
The discriminant of the cubic is:
cubicDiscriminant.gif [9]
The u and v values are:
u=3Root(-qDiv2+Root(D)).gif [18]

v=3Root(qDiv2+Root(D)).gif [19]
x1=u1-v1-aDiv3.gif [20]
x2,3=-0.5(u1-v1)+-(u1+v1)Root(3)Div2i)-aDiv3.gif [25]
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:
r=Root((-pDiv3)pow3).gif  [32]
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
Faster Arithmetic for Adults