# Cubic and Quartic Equations

### Cubic Equation x3 + a1x2 + a2x + a3 = 0

Let $Q = \frac{3a_2 - a_1^2}{9}$

$R = \frac{9a_1a_2 - 27a_3 - 2a_1^3}{54}$

$S = \sqrt{R+\sqrt{Q^3+R^2}}$

$T = \sqrt{R-\sqrt{Q^3+R^2}}$

Solutions:
$\begin{cases}x_1 = S + T - \frac{1}{3}a_1 \\ x_2 = -\frac{1}{2}(S+T) - \frac{1}{3}a_1+\frac{1}{2}i\sqrt{3}(S-T) \\ x_3 = -\frac{1}{2}(S + T) - \frac{1}{3}a_1-\frac{1}{2}i\sqrt{3}(S-T) \end{cases}$

If a1, a2, a3 are real and if D = Q3 + R2 is the discriminant, then
(i)     one root is real and two complex conjugate if D > 0
(ii)     all roots are real and at least two are equal if D = 0
(iii)     all roots are real and unequal if D < 0.
If D < 0, computation is simplyfied by use of trigonometry.

Solutions if D < 0 :
$\begin{cases} x_1 = 2 \sqrt{-Q} \cos \left( \frac{1}{3} \theta \right) \\ x_2 = 2 \sqrt{-Q} \cos \left( \frac{1}{3} \theta + 120^{\circ} \right) \\ x_3 = 2 \sqrt{-Q} \cos \left( \frac{1}{3} \theta + 240^{\circ} \right) \end{cases}$

where $\cos \theta = -\frac{R}{\sqrt{-Q^3}}$

x1 + x2 + x3 = -a1,      x1x2 + x2x3 + x3x1 = a2,      x1x2x3 = - a3
where x1, x2 , x3 are the three roots.

### Quartic equation x4 + a1x3 + a2x2 + a3x + a4 = 0.

Let $y_1$ be a real root of the cubic equation
(1)   $y^3 - a_2y^2 + (a_1a_3 - 4a_4)y + (4a_2a_4 - a_3^2 - a_1^2a_4) = 0$

Solutions:    The roots of
$z^2+\frac{1}{2}(a_1 \pm \sqrt{a_1^2-4a_2+4y_1})z+\frac{1}{2}(y_1 \pm \sqrt{y_1^2 - 4a_4})=0$

If all roots of (1) are real, computation is simplified by using that particular real root which produces all real coefficients in the quadratic equation. where x1,x2,x3,x4 are the four roots.

Contact email: 