Cubic Equation

The classic technique to solve a cubic equation x3+ax2+bx+c=0\begin{aligned} x^3 + ax^2 + bx + c = 0 \end{aligned}

is called Cardano’s formula, which reduces the original equation to the more simple form. t3+pt+q=0\begin{aligned} t^3 + pt + q = 0 \end{aligned}

Once the solution tt is found, xx can be naturally obtained from x=ta/3x = t - a/3. So, replacing xx by ta/3t - a/3 in the original equation to find pp and qq, (ta3)3+a(ta3)2+b(ta3)+c=(t33t2a3+3ta29a327)+a(t22ta3+a29)+b(ta3)+c=  t3+(ba23)t+2a327ab3+c=0p=ba23q=2a327ab3+c\begin{aligned} &\left( t - \frac{a}{3} \right)^3 + a \left( t - \frac{a}{3} \right)^2 + b \left( t - \frac{a}{3} \right) + c \\\\ = &\left( t^3 - 3t^2 \frac{a}{3} + 3t \frac{a^2}{9} - \frac{a^3}{27} \right) + a \left( t^2 - 2t \frac{a}{3} + \frac{a^2}{9} \right) + b \left( t - \frac{a}{3} \right) + c \\\\ = &\; t^3 + \left( b - \frac{a^2}{3} \right)t + \frac{2a^3}{27} - \frac{ab}{3} + c = 0 \\\\ \Longrightarrow &\quad p = b - \frac{a^2}{3} \qquad q = \frac{2a^3}{27} - \frac{ab}{3} + c \end{aligned}

Note that this note is only interested in finding real roots.

Case 1. p=0p = 0 or q=0q = 0

  • If p=q=0p = q = 0, the reduced form becomes t3=0t^3 = 0, which produces x=a/3x = -a/3.
  • If p=0p = 0 and q0q \ne 0, the reduced form becomes t3+q=0t^3 + q = 0, which produces x=q3a/3x = \sqrt[3]{-q} - a/3.
  • If q=0q = 0 and p0p \ne 0, the reduced form becomes t3+pt=t(t2+p)=0t^3 + pt = t(t^2 + p) = 0, which produces x=a/3x = -a/3, or x=±pa/3x = \pm \sqrt{-p} - a/3 if only p<0p < 0.


In the case of p0p \ne 0 and q0q \ne 0, the following identity can be considered. (uv)3+3uv(uv)=u3v3\begin{aligned} (u - v)^3 + 3uv(u - v) = u^3 - v^3 \end{aligned}

This identity can be reformed to t3+pt+q=0t^3 + pt + q = 0 form by setting t=uvt = u - v, p=3uvp = 3uv, and q=v3u3q = v^3 - u^3. Since p0p \ne 0 and q0q \ne 0, v=p3uq=v3u3=(p3u)3u3u3+q(p3u)3=0u6+qu3(p3)3=0u3=q±q2+4(p3)32=q2±(q2)2+(p3)3\begin{aligned} v = \frac{p}{3u} &\Longrightarrow q = v^3 - u^3 = \left( \frac{p}{3u} \right)^3 - u^3 \Longrightarrow u^3 + q - \left( \frac{p}{3u} \right)^3 = 0 \\\\ &\Longrightarrow u^6 + qu^3 - \left( \frac{p}{3} \right)^3 = 0 \\\\ &\Longrightarrow u^3 = \frac{-q \pm \sqrt{q^2 + 4\left( \frac{p}{3} \right)^3}}{2} = -\frac{q}{2} \pm \sqrt{\left( \frac{q}{2} \right)^2 + \left( \frac{p}{3} \right)^3} \end{aligned}

In a similar manner, u=p3vq=v3u3=v3(p3v)3v3q(p3v)3=0v6qv3(p3)3=0v3=q±q2+4(p3)32=q2±(q2)2+(p3)3\begin{aligned} u = \frac{p}{3v} &\Longrightarrow q = v^3 - u^3 = v^3 - \left( \frac{p}{3v} \right)^3 \Longrightarrow v^3 - q - \left( \frac{p}{3v} \right)^3 = 0 \\\\ &\Longrightarrow v^6 - qv^3 - \left( \frac{p}{3} \right)^3 = 0 \\\\ &\Longrightarrow v^3 = \frac{q \pm \sqrt{q^2 + 4\left( \frac{p}{3} \right)^3}}{2} = \frac{q}{2} \pm \sqrt{\left( \frac{q}{2} \right)^2 + \left( \frac{p}{3} \right)^3} \end{aligned}

From now on, let Δ=(q/2)2+(p/3)3\Delta = \left( q/2 \right)^2 + \left( p/3 \right)^3. u3=q2±Δ,v3=q2±Δ\begin{aligned} u^3 = -\frac{q}{2} \pm \sqrt{\Delta}, \qquad v^3 = \frac{q}{2} \pm \sqrt{\Delta} \end{aligned}

Case 2. Δ=0\Delta = 0 (All roots are real and two equal)

This case makes u3=q/2u^3 = -q/2 and v3=q/2v^3 = q/2. Recall that the solutions of y31=0y^3 - 1 = 0 are y=1,e2πi/3,e4πi/3y = 1, e^{2\pi i/3}, e^{4\pi i/3} according to the root of unity. Keeping in mind p=3uvp = 3uv is constant which means that uvuv must be constant, it indicates that uu and vv are rotated in the opposite direction of each other in the complex plane. u=q23,q23e2πi/3,q23e4πi/3v=q23,q23e2πi/3,q23e4πi/3\begin{aligned} u &= \sqrt[3]{-\frac{q}{2}}, \quad \sqrt[3]{-\frac{q}{2}} e^{-2\pi i/3}, \quad \sqrt[3]{-\frac{q}{2}} e^{-4\pi i/3} \\\\ v &= \sqrt[3]{\frac{q}{2}}, \quad \sqrt[3]{\frac{q}{2}} e^{2\pi i/3}, \quad \sqrt[3]{\frac{q}{2}} e^{4\pi i/3} \end{aligned}

  • If u=q/23u = \sqrt[3]{-q/2} and v=q/23v = \sqrt[3]{q/2}, the solution of the reduced form is t=uv=2q/23t = u - v = 2\sqrt[3]{-q/2}, which produces x=2q/23a/3x = 2\sqrt[3]{-q/2} - a/3.
  • If u=q/23e2πi/3u = \sqrt[3]{-q/2}e^{-2\pi i/3} and v=q/23e2πi/3v = \sqrt[3]{q/2}e^{2\pi i/3},
t=uv=q23e2πi/3q23e2πi/3=q23(cos(2π3)+isin(2π3)+cos(2π3)+isin(2π3))=q23(1)=q23\begin{aligned} t &= u - v = \sqrt[3]{-\frac{q}{2}} e^{-2\pi i/3} - \sqrt[3]{\frac{q}{2}} e^{2\pi i/3} \\\\ &= -\sqrt[3]{\frac{q}{2}} \left( \cos \left( -\frac{2\pi}{3} \right) + i \sin \left( -\frac{2\pi}{3} \right) + \cos \left( \frac{2\pi}{3} \right) + i \sin \left( \frac{2\pi}{3} \right) \right) \\\\ &= -\sqrt[3]{\frac{q}{2}} \left( -1 \right) = \sqrt[3]{\frac{q}{2}} \end{aligned}

which produces x=q/23a/3x = \sqrt[3]{q/2} - a/3.

  • If u=q/23e4πi/3u = \sqrt[3]{-q/2}e^{-4\pi i/3} and v=q/23e4πi/3v = \sqrt[3]{q/2}e^{4\pi i/3},
t=uv=q23e4πi/3q23e4πi/3=q23(cos(4π3)+isin(4π3)+cos(4π3)+isin(4π3))=q23(1)=q23\begin{aligned} t &= u - v = \sqrt[3]{-\frac{q}{2}} e^{-4\pi i/3} - \sqrt[3]{\frac{q}{2}} e^{4\pi i/3} \\\\ &= -\sqrt[3]{\frac{q}{2}} \left( \cos \left( -\frac{4\pi}{3} \right) + i \sin \left( -\frac{4\pi}{3} \right) + \cos \left( \frac{4\pi}{3} \right) + i \sin \left( \frac{4\pi}{3} \right) \right) \\\\ &= -\sqrt[3]{\frac{q}{2}} \left( -1 \right) = \sqrt[3]{\frac{q}{2}} \end{aligned}

which also produces x=q/23a/3x = \sqrt[3]{q/2} - a/3.

It is noticeable that two equal real roots rather come out after considering all the imaginary parts.

Case 3. Δ>0\Delta > 0 (One is a real root and two complex roots)

t=uv=q2±Δ3q2±Δ3=q2±Δ3+q2Δ3=q2+Δ3+q2Δ3\begin{aligned} t &= u - v = \sqrt[3]{-\frac{q}{2} \pm \sqrt{\Delta}} - \sqrt[3]{\frac{q}{2} \pm \sqrt{\Delta}} = \sqrt[3]{-\frac{q}{2} \pm \sqrt{\Delta}} + \sqrt[3]{-\frac{q}{2} \mp \sqrt{\Delta}} \\\\ &= \sqrt[3]{-\frac{q}{2} + \sqrt{\Delta}} + \sqrt[3]{-\frac{q}{2} - \sqrt{\Delta}} \end{aligned}

Note that ±\pm is eventually disappeared. So, x=q/2+Δ3+q/2Δ3a/3x = \sqrt[3]{-q/2 + \sqrt{\Delta}} + \sqrt[3]{-q/2 - \sqrt{\Delta}} - a/3.

Case 4. Δ<0\Delta < 0 (All roots are real and different)

In this case, uu and vv are complex numbers. u3=q2±iΔ,v3=q2±iΔ\begin{aligned} u^3 = -\frac{q}{2} \pm i \sqrt{-\Delta}, \qquad v^3 = \frac{q}{2} \pm i \sqrt{-\Delta} \end{aligned}

Recall that a complex number m+nim + ni can be represented as r(cosϕ+isinϕ)r (\cos \phi + i \sin \phi) where r=m2+n2r = \sqrt{m^2 + n^2}, cosϕ=m/r\cos \phi = m/r, and sinϕ=n/r\sin \phi = n/r. With this, u3u^3 can be rewritten as r(cosϕ+isinϕ)r (\cos \phi + i \sin \phi) where r=(q2)2Δ,cosϕ=q2r,sinϕ=±Δr\begin{aligned} r = \sqrt{\left( \frac{q}{2} \right)^2 - \Delta}, \qquad \cos \phi = -\frac{q}{2r}, \qquad \sin \phi = \frac{\pm \sqrt{-\Delta}}{r} \end{aligned}

Then, v3v^3 can be also rewritten, noting that it has the same rr of uu. rv=(q2)2Δ=r,cosϕv=q2r=cosϕ,sinϕv=±Δr=sinϕ\begin{aligned} r_v = \sqrt{\left( \frac{-q}{2} \right)^2 - \Delta} = r, \qquad \cos \phi_v = \frac{q}{2r} = - \cos \phi, \qquad \sin \phi_v = \frac{\pm \sqrt{-\Delta}}{r} = \sin \phi \end{aligned}

which means that v3=r(cosϕ+isinϕ)=r(cosϕisinϕ)=r(cos(ϕ)+isin(ϕ))v^3 = r(-\cos \phi + i \sin \phi) = -r(\cos \phi - i \sin \phi) = -r (\cos (-\phi) + i \sin (-\phi)). More simply, u3=reiϕu^3 = r e^{i \phi} and v3=reiϕv^3 = -r e^{-i \phi}. Again, keeping in mind uvuv is constant, rotate each uu and vv in the opposite direction in the complex plane. u=r3eϕi/3,r3e(ϕ+2π)i/3,r3e(ϕ+4π)i/3v=r3eϕi/3,r3e(ϕ+2π)i/3,r3e(ϕ+4π)i/3\begin{aligned} u &= \sqrt[3]{r} e^{\phi i/3}, \quad \sqrt[3]{r} e^{(\phi + 2 \pi)i/3}, \quad \sqrt[3]{r} e^{(\phi + 4 \pi)i/3} \\\\ v &= \sqrt[3]{-r} e^{-\phi i/3}, \quad \sqrt[3]{-r} e^{-(\phi + 2 \pi)i/3}, \quad \sqrt[3]{-r} e^{-(\phi + 4 \pi)i/3} \end{aligned}

  • If u=r3eϕi/3u = \sqrt[3]{r} e^{\phi i/3} and v=r3eϕi/3v = \sqrt[3]{-r} e^{-\phi i/3},
t=uv=r3eϕi/3r3eϕi/3=r3(cos(ϕ3)+isin(ϕ3)+cos(ϕ3)+isin(ϕ3))=2r3cos(ϕ3)\begin{aligned} t &= u - v = \sqrt[3]{r} e^{\phi i/3} - \sqrt[3]{-r} e^{-\phi i/3} \\\\ &= \sqrt[3]{r} \left( \cos \left( \frac{\phi}{3} \right) + i \sin \left( \frac{\phi}{3} \right) + \cos \left( -\frac{\phi}{3} \right) + i \sin \left( -\frac{\phi}{3} \right) \right) \\\\ &= 2\sqrt[3]{r} \cos \left( \frac{\phi}{3} \right) \end{aligned}

which produces x=2r3cos(ϕ/3)a/3x = 2\sqrt[3]{r} \cos \left( \phi/3 \right) - a/3.

  • If u=r3e(ϕ+2π)i/3u = \sqrt[3]{r} e^{(\phi + 2 \pi)i/3} and v=r3e(ϕ+2π)i/3v = \sqrt[3]{-r} e^{-(\phi + 2 \pi)i/3},
t=uv=r3e(ϕ+2π)i/3r3e(ϕ+2π)i/3=r3(cos(ϕ+2π3)+isin(ϕ+2π3)+cos(ϕ+2π3)+isin(ϕ+2π3))=2r3cos(ϕ+2π3)\begin{aligned} t &= u - v = \sqrt[3]{r} e^{(\phi + 2 \pi)i/3} - \sqrt[3]{-r} e^{-(\phi + 2 \pi)i/3} \\\\ &= \sqrt[3]{r} \left( \cos \left( \frac{\phi + 2 \pi}{3} \right) + i \sin \left( \frac{\phi + 2 \pi}{3} \right) + \cos \left( -\frac{\phi + 2 \pi}{3} \right) + i \sin \left( -\frac{\phi + 2 \pi}{3} \right) \right) \\\\ &= 2\sqrt[3]{r} \cos \left( \frac{\phi + 2 \pi}{3} \right) \end{aligned}

which produces x=2r3cos((ϕ+2π)/3)a/3x = 2\sqrt[3]{r} \cos \left( (\phi + 2 \pi)/3 \right) - a/3.

  • If u=r3e(ϕ+4π)i/3u = \sqrt[3]{r} e^{(\phi + 4 \pi)i/3} and v=r3e(ϕ+4π)i/3v = \sqrt[3]{-r} e^{-(\phi + 4 \pi)i/3},
t=uv=r3e(ϕ+4π)i/3r3e(ϕ+4π)i/3=r3(cos(ϕ+4π3)+isin(ϕ+4π3)+cos(ϕ+4π3)+isin(ϕ+4π3))=2r3cos(ϕ+4π3)\begin{aligned} t &= u - v = \sqrt[3]{r} e^{(\phi + 4 \pi)i/3} - \sqrt[3]{-r} e^{-(\phi + 4 \pi)i/3} \\\\ &= \sqrt[3]{r} \left( \cos \left( \frac{\phi + 4 \pi}{3} \right) + i \sin \left( \frac{\phi + 4 \pi}{3} \right) + \cos \left( -\frac{\phi + 4 \pi}{3} \right) + i \sin \left( -\frac{\phi + 4 \pi}{3} \right) \right) \\\\ &= 2\sqrt[3]{r} \cos \left( \frac{\phi + 4 \pi}{3} \right) \end{aligned}

which produces x=2r3cos((ϕ+4π)/3)a/3x = 2\sqrt[3]{r} \cos \left( (\phi + 4 \pi)/3 \right) - a/3.

Alternative Form

Besides all cos\cos forms as above, the alternative form can be derived with sin\sin and a quadratic equation. First, let the last root above be α\alpha. From cos(π/2+θ)=sinθ\cos \left( \pi/2 + \theta \right) = -\sin \theta and sinθ=sin(πθ)\sin \theta = \sin \left( \pi - \theta \right), α=2r3cos(ϕ+4π3)=2r3sin(ϕ3+5π6)=2r3sin(π(ϕ3+5π6))=2r3sin(π6ϕ3)=2r3sin(13(π2ϕ))\begin{aligned} \alpha &= 2\sqrt[3]{r} \cos \left( \frac{\phi + 4 \pi}{3} \right) = -2\sqrt[3]{r} \sin \left( \frac{\phi}{3} + \frac{5 \pi}{6} \right) = -2\sqrt[3]{r} \sin \left( \pi - \left( \frac{\phi}{3} + \frac{5 \pi}{6} \right) \right) \\\\ &= -2\sqrt[3]{r} \sin \left( \frac{\pi}{6} - \frac{\phi}{3} \right) = -2\sqrt[3]{r} \sin \left( \frac{1}{3} \left( \frac{\pi}{2} - \phi \right) \right) \end{aligned}

Since cosϕ=q2r=sin(π2ϕ)\begin{aligned} \cos \phi = -\frac{q}{2r} = \sin \left( \frac{\pi}{2} - \phi \right) \end{aligned}

α\alpha can be rewritten only using sin\sin and sin1\sin^{-1} forms. α=2r3sin(13(π2ϕ))=2r3sin(13sin1(q2r))\begin{aligned} \alpha &= -2\sqrt[3]{r} \sin \left( \frac{1}{3} \left( \frac{\pi}{2} - \phi \right) \right) = -2\sqrt[3]{r} \sin \left( \frac{1}{3} \sin^{-1} \left( -\frac{q}{2r} \right) \right) \end{aligned}

Once α\alpha is obtained, the reduced cubic equation can be factorized. t3+pt+q=(tα)(t2+αt+α2+p)=0\begin{aligned} t^3 + pt + q = (t - \alpha) (t^2 + \alpha t + \alpha^2 + p) = 0 \end{aligned}

This implies that the other roots come from the quadratic equation t2+αt+α2+pt^2 + \alpha t + \alpha^2 + p which is relatively easy work. t=α±α24(α2+p)2=α±3α24p2\begin{aligned} t = \frac{-\alpha \pm \sqrt{\alpha^2 - 4(\alpha^2 + p)}}{2} = \frac{-\alpha \pm \sqrt{-3\alpha^2 - 4p}}{2} \end{aligned}

To sum up, all solultions are x=2r3sin(13sin1(q2r))a3=αa3x=α+3α24p2a3x=α3α24p2a3\begin{aligned} x &= -2\sqrt[3]{r} \sin \left( \frac{1}{3} \sin^{-1} \left( -\frac{q}{2r} \right) \right) - \frac{a}{3} = \alpha - \frac{a}{3} \\\\ x &= \frac{-\alpha + \sqrt{-3\alpha^2 - 4p}}{2} - \frac{a}{3} \\\\ x &= \frac{-\alpha - \sqrt{-3\alpha^2 - 4p}}{2} - \frac{a}{3} \end{aligned}

References

[1] Solving the Cubic Equation (Algebra)

[2] Cubic Equation Solver II


© 2024. All rights reserved.