Quartic Equation Solution and Conditions for real roots?

Solution 1:

What about a set of expressions in the quartic's coefficients that discriminate between all cases? There are 9 cases:

  1. 4 distinct real roots.

  2. 3 distinct real roots with one of them being a double root.

  3. 2 distinct double roots both real.

  4. Triple root and and a distinct fourth root.

  5. Quadruple root.

  6. 2 distinct real roots and two complex roots.

  7. double real root and 2 complex roots.

  8. 2 double roots both complex.

  9. four distinct complex roots.

Such sets are known for quadratic and cubic polynomials:

Quadratic ($ ax^2+bx+c $):

Discriminant: $b^2-4ac$

Positive for two distinct real roots, zero for double root, and negative for complex conjugate roots.

Cubic ($ ax^3+bx^2+cx+d $):

$\Delta_1=2b^3-9abc+27a^2d$ and $\Delta_2=\Delta_1^2-4(b^2-3ac)^3$.

Then:

$ \Delta_2>0 $ gives one real root and two complex roots.

$ \Delta_2<0$ gives three distinct real roots.

$ \Delta_2=0 $ but $ \Delta_1\neq 0$ gives a double root plus one different root.

$ \Delta_1=\Delta_2=0$ gives a triple root.

Solution 2:

The method is based on a paper by Herbert E. Salzer "A Note on the Solution of Quartic Equations" (Am. Math Society Proceedings, 1959).

Suppose there is an equation $X^4+AX^3+BX^2+CX+D=0$, with real or complex roots $X_1$, $X_2$, $X_3$, $X_4$.

First, solve the cubic equation $ax^3+bx^2+cx+d$ where $a=1$, $b=-B$, $c=AC-4D$, $d=D(4B-A^2)-C^2$; only 1 real root is needed, call it $x_1$.

Find $m=\sqrt{\frac{1}{4}A^2-B+x_1}$, and $n=\frac{Ax_1-2C}{4m}$.

If m=0, take $n=\sqrt{\frac{1}{4}x_1^2-D}$.

Proceed to the case I or case II depending on whether m is real or imaginary.

Case I. $m$ is real;

Let $\alpha=(\frac{1}{2}A^2-x_1-B)$ and $\beta=4n-Am$

$\gamma=\sqrt{\alpha+\beta}$ and $\delta=\sqrt{\alpha-\beta}$.

With the above notations

$X_1=\frac{-\frac{1}{2}A+m+\gamma}{2}$, $X_2=\frac{-\frac{1}{2}A-m+\delta}{2}$, $X_3=\frac{-\frac{1}{2}A+m-\gamma}{2}$, $X_4=\frac{-\frac{1}{2}A-m-\delta}{2}$.

Case II. $m$ is imaginary. Take $m=im'$, then $n$ is also imaginary, take $n=in'$;

Let $\alpha=(\frac{1}{2}A^2-x_1-B)$ and $\beta=4n'-Am'$

$\rho=\sqrt{\alpha^2+\beta^2}$, $\gamma=\sqrt{\frac{\alpha+\rho}{2}}$ and $\delta=\frac{\beta}{2\gamma}$.

Then,

$X_1=\frac{-\frac{1}{2}A+\gamma+i(m'+\delta)}{2}$, $X_2=\bar{X_1}$,

$X_3=\frac{-\frac{1}{2}A-\gamma+i(m'-\delta)}{2}$, $X_4=\bar{X_3}$

if $\gamma=0$ then $\alpha=-\alpha', \alpha'\ge 0$, and formaulae above still hold provided that $\delta$ is replaced by $\sqrt{\alpha'}$.

This solution is easily programmed as opposed to the tedious formulae by Cardano-Ferrari.

Below is a MATLAB function producing REAL roots only (if there are any) based on this method.

%returns r1,r2,r3,r4: REAL if roots are real, ZERO if complex

% isreal1, isreal2, isreal3, isreal4 - logical (or bit), 1 (true) - if root is real, 0 (false) - if root is complex

function [r1, r2, r3, r4, isreal1, isreal2, isreal3, isreal4 ] = quarticsolve_salzer(a4,a3,a2,a1,a0)

%initialisation

r1=0;

r2=0;

r3=0;

r4=0;

isreal1=0;

isreal2=0;

isreal3=0;

isreal4=0;

a=a3/a4;

b=a2/a4;

c=a1/a4;

d=a0/a4;

%First, find 1 real root of a cubic equation

%$x^3-bx^2+(ac-4d)x+d(4b-a^2)-c^2$

x1=cubsolve_1realroot(1,-b,a*c-4*d,d*(4*b-a^2)-c^2);

%this routine is a modified version of solution found there

m2=0.25*a*a-b+x1;

if(m2>0)

m=sqrt(0.25*a^2-b+x1);

n=(a*x1-2*c)/4/m;

elseif(m2==0)

m=0;

n=sqrt(0.25*x1^2-d);

else

%imaginary roots only

% r1,r2,r3,r4 are returned 0, isreal1,2,3,4 returned false (or 0)    

return;

end;

alpha=0.5*a^2-x1-b;

beta=4*n-a*m;

if(alpha+beta>=0)

%two real roots are produced

gamma=sqrt(alpha+beta);

r1=-0.25*a+0.5*m+0.5*gamma;

r2=-0.25*a+0.5*m-0.5*gamma;

isreal1=1;

isreal2=1;

end;

if(alpha-beta>=0)

%another pair of real roots produced

delta=sqrt(alpha-beta);

r3=-0.25*a-0.5*m+0.5*delta;

r4=-0.25*a-0.5*m-0.5*delta;

isreal3=1;

isreal4=1;

end;

return;

end

function [x1]=cubsolve_1realroot(a3,a2,a1,a0)

a=a2/a3; b=a1/a3; c=a0/a3;

Q=(a^2-3*b)/9; R=(2*a^3-9*a*b+27*c)/54; R2=R^2; Q3=Q^3; if (R2

A=-(abs(R)+sqrt(R2-Q3))^(1/3); if (R < 0) A=-A; %If we used A=A*sign(R) then if R=0 => sign(R)=0 => A=0 which is wrong end if (A==0) B=0; else B=Q/A; end AB=A+B; x1=AB-a/3; end