Algorithm Search⌘K

Proofs: Cardano's formula

These are the human proofs of Cardano's formula, at full length.

Cardano's formula returns the three roots of the cubic with multiplicity full

This proof shows: correctness.

We work in exact complex arithmetic. Let a≠0a \ne 0 and f(x)=ax3+bx2+cx+df(x) = ax^3 + bx^2 + cx + d.

Lemma 1 (the shift). With s=b/(3a)s = b/(3a), C=c/aC = c/a, D=d/aD = d/a, p=C−3s2p = C - 3s^2 and q=D−sC+2s3q = D - sC + 2s^3, we have f(t−s)=a(t3+pt+q)f(t - s) = a(t^3 + pt + q) for all tt.

Proof. f(x)/a=x3+3sx2+Cx+Df(x)/a = x^3 + 3s x^2 + Cx + D, since b/a=3sb/a = 3s. Put x=t−sx = t - s: (t−s)3+3s(t−s)2+C(t−s)+D=t3−3st2+3s2t−s3+3st2−6s2t+3s3+Ct−Cs+D(t - s)^3 + 3s(t - s)^2 + C(t - s) + D = t^3 - 3st^2 + 3s^2t - s^3 + 3st^2 - 6s^2t + 3s^3 + Ct - Cs + D. The t2t^2 terms cancel, the tt terms give (C−3s2)t=pt(C - 3s^2)t = pt, and the constants give 2s3−sC+D=q2s^3 - sC + D = q. □\square

So xx is a root of ff of multiplicity mm if and only if t=x+st = x + s is a root of g(t)=t3+pt+qg(t) = t^3 + pt + q of multiplicity mm, and it suffices to show that t0,t1,t2t_0, t_1, t_2 are the roots of gg with multiplicity, that is, g(t)=(t−t0)(t−t1)(t−t2)g(t) = (t - t_0)(t - t_1)(t - t_2).

Lemma 2 (the quadratic). The numbers −q/2±r-q/2 \pm r with r2=q2/4+p3/27r^2 = q^2/4 + p^3/27 are the two roots of h(z)=z2+qz−p3/27h(z) = z^2 + qz - p^3/27. So their sum is −q-q and their product is −p3/27-p^3/27.

Proof. (z+q/2)2−r2=z2+qz+q2/4−q2/4−p3/27=h(z)(z + q/2)^2 - r^2 = z^2 + qz + q^2/4 - q^2/4 - p^3/27 = h(z), and (z+q/2)2−r2=(z+q/2−r)(z+q/2+r)(z + q/2)^2 - r^2 = (z + q/2 - r)(z + q/2 + r). Vieta's formulas for a monic quadratic give the sum and product. □\square

Case w=0w = 0. Line L4 picks the root of hh of larger modulus. If it is 00, both roots are 00, so their sum −q=0-q = 0 and their product −p3/27=0-p^3/27 = 0, so p=q=0p = q = 0. Then g(t)=t3g(t) = t^3 has the triple root 00, and line L5 returns x=−sx = -s three times, which is correct by Lemma 1.

Case w≠0w \ne 0. Let uu be a cube root of ww (line L6), so u≠0u \ne 0. For k=0,1,2k = 0, 1, 2 put uk=ωkuu_k = \omega^k u and vk=−p/(3uk)v_k = -p/(3u_k), so that line L9 gives tk=uk+vkt_k = u_k + v_k. Write v=v0=−p/(3u)v = v_0 = -p/(3u). Since ω3=1\omega^3 = 1, vk=ω−kv=ω2kvv_k = \omega^{-k}v = \omega^{2k} v, and ukvk=uv=−p/3u_k v_k = uv = -p/3.

Step 1: u3+v3=−qu^3 + v^3 = -q. We have u3=wu^3 = w, one root of hh, and v3=−p3/(27u3)=(−p3/27)/wv^3 = -p^3/(27u^3) = (-p^3/27)/w. By Lemma 2, the product of the two roots of hh is −p3/27-p^3/27, so v3v^3 is the other root of hh (this also holds if the two roots are equal). Their sum is −q-q.

Step 2: the elementary symmetric functions of t0,t1,t2t_0, t_1, t_2. Use 1+ω+ω2=01 + \omega + \omega^2 = 0.

  • t0+t1+t2=u(1+ω+ω2)+v(1+ω2+ω4)=0t_0 + t_1 + t_2 = u(1 + \omega + \omega^2) + v(1 + \omega^2 + \omega^4) = 0, since ω4=ω\omega^4 = \omega.
  • t02+t12+t22=∑k(ω2ku2+2uv+ω4kv2)=u2⋅0+6uv+v2⋅0=6uvt_0^2 + t_1^2 + t_2^2 = \sum_k (\omega^{2k}u^2 + 2uv + \omega^{4k}v^2) = u^2 \cdot 0 + 6uv + v^2 \cdot 0 = 6uv. Hence e2=∑j<ktjtk=12((∑tk)2−∑tk2)=−3uv=pe_2 = \sum_{j<k} t_j t_k = \tfrac12\big((\sum t_k)^2 - \sum t_k^2\big) = -3uv = p.
  • t0t1t2=(u+v)(ωu+ω2v)(ω2u+ωv)t_0 t_1 t_2 = (u + v)(\omega u + \omega^2 v)(\omega^2 u + \omega v). The product of the last two factors is ω3u2+ω2uv+ω4uv+ω3v2=u2−uv+v2\omega^3 u^2 + \omega^2 uv + \omega^4 uv + \omega^3 v^2 = u^2 - uv + v^2, using ω2+ω4=ω2+ω=−1\omega^2 + \omega^4 = \omega^2 + \omega = -1. So t0t1t2=(u+v)(u2−uv+v2)=u3+v3=−qt_0t_1t_2 = (u + v)(u^2 - uv + v^2) = u^3 + v^3 = -q.

Step 3. By Step 2, (t−t0)(t−t1)(t−t2)=t3−(∑tk)t2+e2t−t0t1t2=t3+pt+q=g(t)(t - t_0)(t - t_1)(t - t_2) = t^3 - (\sum t_k) t^2 + e_2 t - t_0t_1t_2 = t^3 + pt + q = g(t). So t0,t1,t2t_0, t_1, t_2 are the roots of gg with multiplicity, and by Lemma 1, xk=tk−sx_k = t_k - s are the roots of ff with multiplicity. ■\blacksquare

Remark (why line L9 and not a second cube root). The proof uses ukvk=−p/3u_k v_k = -p/3. Two independent cube roots u′u' of −q/2+r-q/2 + r and v′v' of −q/2−r-q/2 - r satisfy only (u′v′)3=−p3/27(u'v')^3 = -p^3/27, so u′v′=ωj(−p/3)u'v' = \omega^j(-p/3) for some j∈{0,1,2}j \in \{0, 1, 2\}. If j≠0j \ne 0 and p≠0p \ne 0, then u′+v′u' + v' is in general not a root.

Remark (the irreducible case). For real p,qp, q with q2/4+p3/27<0q^2/4 + p^3/27 < 0, rr is imaginary and ww and wˉ\bar w are the two roots of hh, with ∣w∣2=−p3/27|w|^2 = -p^3/27. Then ∣u∣2=−p/3|u|^2 = -p/3, so v=−p/(3u)=uˉv = -p/(3u) = \bar u and tk=2Re⁡(ωku)t_k = 2\operatorname{Re}(\omega^k u) is real for each kk. The three roots are real, and the formula reaches them through non-real uu.

Back to Cardano's formula