Ben's blog

Cardano's formula

A quadratic equation is relatively easy to solve, and the Babylonians were aware of methods to solve them in 1600 BC. The cubic formula is significantly harder to solve and it took much longer to find the solution to the general form of the cubic equation: In the 16th century, Italian mathematicians Scipione del Ferro and Niccolo Tartaglia found methods to solve the general cubic equation. Gerolamo Cardano was the first one to publish this method, and the formula is still best known by his name.

Somewhat surprisingly, it is possible to derive Cardano’s formula by using a method that is a three-dimensional analogue of completing the square. I present the derivation here, which is based on Mieke Jansen’s master thesis. To fully understand this article, some understanding of roots of unity is necessary. However, the lion’s share will be understandable even for those without understanding of roots of unity.

Before considering the cubic formula, we’ll have a look at the method that is called ‘completing the square’.

Completing the square

Suppose we have a quadratic equation of the form x2+ax=c x^2 + ax = c

Any quadratic equation can be written in this form. If we now add some expression, to both sides so that the left side is a perfect square, we can take the square root of both sides. Indeed, this is possible, since we have (x+a2)2=x2+ax+(a2)2 (x + \frac{a}{2})^2 = x^2 + ax + (\frac{a}{2})^2

So if we add a24\frac{a^2}{4} from both sides, the left side is now the square of a linear factor, and we obtain (x+a2)2=c+a24 (x + \frac{a}{2})^2 = c +\frac{a^2}{4}

which is quite easy to work out. Assuming that aa and cc are positive for the moment, we can gain some geometric intuition for the procedure by using this figure:

Square, divided into four sections.

The blue square has width and height xx. The red rectangles are chosen so that their area adds up to axax, which means that they have one side with length xx and one side with length a2\frac{a}{2}. The green square has area (a2)2(\frac{a}{2})^2 and represents the quantity we added.

Solving the cubic equation

It is not easy to attack the general cubic equation with the same strategy. To make the equation simpler, we use substitution to reduce it to the form x3+px=q x^3 + px = q

This form is called the depressed cubic. I now show that the general cubic equation can be reduced to this form. This means that solving cubics of this form means that we are also able to solve cubics of the general form.

Start with an equation in the general form x3+ax2+bx=c x^3 + ax^2 + bx = c

If we substitute x=ya3x = y - \frac{a}{3}, we obtain y3+(ba23)y=c+a9b2a227 y^3 + (b - \frac{a^2}{3})y = c + a\frac{9b - 2a^2}{27}

For simplicity, put p=ba23p = b - \frac{a^2}{3} and q=c+a9b2a227q = c + a\frac{9b - 2a^2}{27} to end up with y3+py=qy^3 + py = q

So, if we have cubic equation in the form x3+ax2+bx=cx^3 + ax^2 +bx = c, we can compute pp and qq, and try to find the solution of y3+py=qy^3 + py = q. If we have found yy we can use x=ya3x = y - \frac{a}{3} to find xx.

Completing the cube

Consider a depressed cubic of the form y3+py=q y^3 + py = q

Now, consider the following three-dimensional analogue of the figure in the last section:

Cube, divided into five sections.

Let uu be the length of the side of the large cube that is formed by the blue cube, the red boxes, and the green cube. Let v=uyv = u - y. Now, the green cube has side vv and the blue cube has side yy. The three red rectangular boxes have sides with lengths uu, vv, and yy, and the big cube that is formed by all the other shapes has side length uu.

Analogously to the completion of the square, we demand that the volume of the blue cube and the red boxes to add up to y3+pyy^3 + py. Then, since all these boxes have the same volume as the volume of the big cube (with sides uu) minus the volume of the small cube (with sides vv), we have u3v3=y3+py=qu^3 - v^3 = y^3 + py = q. Since the blue cube has a volume of y3y^3, each of the three red boxes has volume py3\frac{py}{3}. Since each red rectangular box has a volume of uvyuvy, we find uvy=p3yuvy = \frac{p}{3}y. It follows that u3v3=(p3)3u^3 v^3 = (\frac{p}{3})^3.

Setting r=(p3)3,s:=u3,t:=v3r = -(\frac{p}{3})^3, s := u^3, t := -v^3, we obtain the equations s+t=qs + t = q and st=rst = r. In other words, we are looking for two numbers s,ts, t which have sum qq and product rr. Note that this is equivalent to solving the quadratic equation z2qz+r=0 z^2 - qz + r = 0

Since (zs)(zt)=z2qz+r=0(z - s)(z - t) = z^2 - qz + r = 0 exactly when the sum of ss and tt is qq and their product is rr. The solutions are q2+(q2)2r\frac{q}{2} + \sqrt{(\frac{q}{2})^2 - r} and q2(q2)2r\frac{q}{2} - \sqrt{(\frac{q}{2})^2-r}. Note that the expressions are symmetric in ss and tt, so we can choose freely which expression we pick for ss and which one for tt (as long as we pick ss as one of them and tt as the other).

Using that s=u3s = u^3 and t=v3t = -v^3 , we find u=q2±(q2)2+(p3)33u = \sqrt[3]{\frac{q}{2} \pm \sqrt{(\frac{q}{2})^2+(\frac{p}{3})^3}}

v=q2(q2)2+(p3)33 v = -\sqrt[3]{\frac{q}{2} \mp \sqrt{(\frac{q}{2})^2+(\frac{p}{3})^3}}

Note that u+vu + v stays the same, regardless of how we pick the signs in the expression for uu and vv. Using x=ya3=a3+uvx = y - \frac{a}{3} = -\frac{a}{3} + u - v, we find x=a3+q2+(q2)2+(p3)33+q2(q2)2+(p3)33x = -\frac{a}{3} + \sqrt[3]{\frac{q}{2} + \sqrt{(\frac{q}{2})^2+(\frac{p}{3})^3}} + \sqrt[3]{\frac{q}{2} - \sqrt{(\frac{q}{2})^2+(\frac{p}{3})^3}}

Where we have p=ba23p = b - \frac{a^2}{3} and q=c+a9b2a227q = c + a\frac{9b - 2a^2}{27}.


Algebraically, we can summarize the steps we took as follows:

Take the equation x3+ax2+bx=c x^3 + ax^2 + bx = c

Substitute y=x+a3p=ba23q=c+a9b2a227 y = x + \frac{a}{3} \\ p = b - \frac{a^2}{3} \\ q = c + a \frac{9b-2a^2}{27}

We now have the following polynomial equation in yy: y3+py=q y^3 + py = q

Introduce u,vu, v that satisfy y=uvy = u - v and uv=p3uv = \frac{p}{3}. From this, we can derive u3v3=qu3v3=(p3)3 u^3 - v^3 = q \\ u^3 v^3 = (\frac{p}{3})^3

Now substitute s=u3t=v3r=(p3)3 s = u^3 \\ t = v^3 \\ r = (\frac{p}{3})^3

So that we have st=qst=r s - t = q \\ st = r

These equations have the following solution, where ss and tt are interchangible: s,t=q2±(q2)2+(p3)3 s, t = \frac{q}{2} \pm \sqrt{(\frac{q}{2})^2 + (\frac{p}{3})^3}

If we substitute back and try to express ss and tt in a,ba, b, and cc, we find x=ya3 x = y - \frac{a}{3}

where y=q2+(q2)2+(p3)33+q2(q2)2+(p3)33 y = \sqrt[3]{\frac{q}{2} + \sqrt{(\frac{q}{2})^2+(\frac{p}{3})^3}} + \sqrt[3]{\frac{q}{2} - \sqrt{(\frac{q}{2})^2+(\frac{p}{3})^3}}

and p=ba23q=c+a9b2a227 p = b - \frac{a^2}{3} \\ q = c + a \frac{9b-2a^2}{27}

You might have noticed that we find only one solution. It is actually possible to find the other two solutions with a slight change in the formula, which I’ll explain in the last section. If you like a good challenge, try to find out why we don’t find all solutions, and try to modify the formula to provide all complex solutions of the cubic formula (if you need a hint, take a look at the second paragraph).

Simplifying the result

In retrospect, it would be easier to use variables that equal p3\frac{p}{3} and q2\frac{q}{2} instead. Using this, and some other simplifications, we find the solution x=A+C+D3+CD3x = -A + \sqrt[3]{C + \sqrt{D}} + \sqrt[3]{C - \sqrt{D}}

where A=a3,B:=b3A2,C=c+A(b2A2)2A = \frac{a}{3}, B := \frac{b}{3} - A^2, C = \frac{c + A(b - 2A^2)}{2} and D=C2+B3D = C^2+B^3

for the equation x3+ax2+bx=cx^3 + ax^2 + bx = c

What about the other solutions?

As we know from the fundamental theorem of algebra, a cubic equations has three (complex) solutions. Yet the formula we found only provides a formula for one of those roots. Indeed we missed some solutions. Specifically, when we took the cube root of ss and tt, we only considered the single real solution. Instead, there are three solutions, which can be deduced from the fundamental theorem of algebra. Specifically, for a real number ww, the formula z3=w z^3 = w

has the solutions w3,ωw3\sqrt[3]{w}, \omega \sqrt[3]{w}, and ω2w3\omega^2 \sqrt[3]{w}. We missed the last two solutions. However, if we consider all those solutions in uu and vv, we obtain 8 new solutions, which is more than expected. Not all of these are indeed solutions of the cubic equation. While all our solutions satisfy u3v3=(p3)3u^3 v^3 = (\frac{p}{3})^3, the stronger condition uv=p3uv = \frac{p}{3} is not always satisfied. This condition can be satisfied by making sure that we pick solutions ω3ks3\omega_3^k \sqrt[3]{s} and ω3kt3\omega_3^{-k} \sqrt[3]{t} for uu and vv (so that uv=s3t3=p3uv = \sqrt[3]{s} \sqrt[3]{t} = \frac{p}{3}).

Statement of the final result

Theorem: Consider the equation x3+ax2+bx=cx^3 + ax^2 + bx = c. Let A=a3,B:=b3A2,C=c+A(b2A2)2A = \frac{a}{3}, B := \frac{b}{3} - A^2, C = \frac{c + A(b - 2A^2)}{2}, D=C2+B3D = C^2 + B^3, and ω3=1\omega_3 \not = 1 a cube root of unity. Substituting k=0,1,2k = 0, 1, 2 in x=A+ω3kC+D3+ω3kCD3x = -A + \omega_3^k \sqrt[3]{C + \sqrt{D}} + \omega_3^{-k}\sqrt[3]{C - \sqrt{D}}

gives all three solutions of the equation. Moreover, if D0D \geq 0, the solution for k=0k = 0 is real.

Proof: Substitute the expression in x3+ax2+bx=cx^3 + ax^2 + bx = c, simplify, and observe that the result is 0. If D0D \geq 0 and k=0k = 0, the expression involves only real numbers, so the result will be real as well. \square