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=t−a/3x = t - a/3. So, replacing xx by t−a/3t - a/3 in the original equation to find pp and qq, (t−a3)3+a(t−a3)2+b(t−a3)+c=(t3−3t2a3+3ta29−a327)+a(t2−2ta3+a29)+b(t−a3)+c=  t3+(b−a23)t+2a327−ab3+c=0⟹p=b−a23q=2a327−ab3+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 q≠0q \ne 0, the reduced form becomes t3+q=0t^3 + q = 0, which produces x=−q3−a/3x = \sqrt[3]{-q} - a/3.
  • If q=0q = 0 and p≠0p \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=±−p−a/3x = \pm \sqrt{-p} - a/3 if only p<0p < 0.


In the case of p≠0p \ne 0 and q≠0q \ne 0, the following identity can be considered. (u−v)3+3uv(u−v)=u3−v3\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=u−vt = u - v, p=3uvp = 3uv, and q=v3−u3q = v^3 - u^3. Since p≠0p \ne 0 and q≠0q \ne 0, v=p3u⟹q=v3−u3=(p3u)3−u3⟹u3+q−(p3u)3=0⟹u6+qu3−(p3)3=0⟹u3=−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=p3v⟹q=v3−u3=v3−(p3v)3⟹v3−q−(p3v)3=0⟹v6−qv3−(p3)3=0⟹v3=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 y3−1=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,v)=(−q23,q23),(−q23e−2πi/3,q23e2πi/3),(−q23e−4πi/3,q23e4πi/3)\begin{aligned} \left( u, v \right) = \left( \sqrt[3]{-\frac{q}{2}}, \sqrt[3]{\frac{q}{2}} \right), \left( \sqrt[3]{-\frac{q}{2}} e^{-2\pi i/3}, \sqrt[3]{\frac{q}{2}} e^{2\pi i/3} \right), \left( \sqrt[3]{-\frac{q}{2}} e^{-4\pi i/3}, \sqrt[3]{\frac{q}{2}} e^{4\pi i/3} \right) \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=u−v=2−q/23t = u - v = 2\sqrt[3]{-q/2}, which produces x=2−q/23−a/3x = 2\sqrt[3]{-q/2} - a/3.
  • If u=−q/23e−2π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=u−v=−q23e−2πi/3−q23e2π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/23−a/3x = \sqrt[3]{q/2} - a/3.

  • If u=−q/23e−4π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=u−v=−q23e−4πi/3−q23e4π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/23−a/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=u−v=−q2±Δ3−q2±Δ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−Δ3−a/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=−re−iϕ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,v)=(r3eϕi/3,−r3e−ϕi/3),(r3e(ϕ+2π)i/3,−r3e−(ϕ+2π)i/3),(r3e(ϕ+4π)i/3,−r3e−(ϕ+4π)i/3)\begin{aligned} \left( u, v \right) = \left( \sqrt[3]{r} e^{\phi i/3}, \sqrt[3]{-r} e^{-\phi i/3} \right), \left( \sqrt[3]{r} e^{(\phi + 2 \pi)i/3}, \sqrt[3]{-r} e^{-(\phi + 2 \pi)i/3} \right), \left( \sqrt[3]{r} e^{(\phi + 4 \pi)i/3}, \sqrt[3]{-r} e^{-(\phi + 4 \pi)i/3} \right) \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=u−v=r3eϕi/3−−r3e−ϕ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=u−v=r3e(ϕ+2π)i/3−−r3e−(ϕ+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=u−v=r3e(ϕ+4π)i/3−−r3e−(ϕ+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 sin⁡−1\sin^{-1} forms. α=−2r3sin⁡(13(π2−ϕ))=−2r3sin⁡(13sin⁡−1(−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=−α±α2−4(α2+p)2=−α±−3α2−4p2\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 solutions are x=−2r3sin⁡(13sin⁡−1(−q2r))−a3=α−a3x=−α+−3α2−4p2−a3x=−α−−3α2−4p2−a3\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


© 2026. All rights reserved.