# Quartic Equation Solution and Conditions for real roots?

Q1. How to solve a Quartic Equation. There is an online calculator available (and many more similar) that gives the precise answers and also defines the method. Does anyone know what the source of this method is?

Q2. Given a Quartic Equation

$$ax^4+bx^3+cx^2+dx+e=0\,,$$ what are the conditions for the existence of real roots of the above equation? Any reference material?

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.

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.

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

• could you please explain your method instead of giving a row code. This would be much more helpful for the next readers – Surb Sep 7 '15 at 10:34
• I voted this answer because it is just what I was looking for. There are reams of stuff about algebraic solutions to quartic equations, but none as computationally elegant as Salzer's method, which I was able to code and debug in less than an hour. So thanks, Antonm .... – Jim White Aug 30 '17 at 20:51

There is no simple search method that always works for the count or estimatica roots. In general it is a rough approximation $a$ of the root $x$ is used the bisection method. And it applies the method of$x_0=a\quad x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}$ Newton for the bestapproximation of root. That is, $\lim_{n\to \infty}x_n=root$. On more times, $|x_{10}-root|<0.01$.

Another method of counting real roots escartes beyond the rule and that is easy to see geometrically is to rank the extreme points of the equation with maximum, minimum and saddle point.

1) We know the fundamental theorem algebra that the number of roots of this equation is at most equal to four.

2)Let $x$ is a point that extreme point ($f '(x) = 0$): If $x$ is the point of minimum ($f'' (x)> 0$) and satisfies $f (x)> 0$ then the equation has two complex roots. If $x$ is the maximum point ($f'' (x) <0$) and satisfies $f (x) <0$ then the equation has two complex roots. If $x$ is the point of cell $f'' (x) = 0$ and $f (x) = 0$ then $x$ is double root of the equation. 3) You can also use the Intermediate Value Theorem ([See wikipedia][1]) to verify the existence of roots in a reiais interestimar the interval $[a, b]$. In fact, if $f(a)<0<f(b)$ ou $f(b)>0>f(a)$, then there is a x ∈ [a, b] such that f(x) = 0.

• the method that online calculator describes is not iterative and is strangely analytic. any ideas how the calculator is obtaining roots of a quartic equation directly just like solving a quadratic equation without computing any iterations? – Abhinav Mar 3 '12 at 5:32
• The method which the calculator applies is reported at 1728.org/quartic2.htm – Abhinav Mar 3 '12 at 5:34
• – MathOverview Nov 12 '12 at 19:50

MATLAB function to solve the general case quartic equation (based on the full formula from Wikipedia). Unfortunately, it does not determine which roots are real (I am working on that now).

function [r1, r2, r3, r4]=quarticsolve(a4,a3,a2,a1,a0)
%solving quartic equation

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

third=1.0/3.0;
root3=2^third;

q1=(b*b-3*a*c+12*d);
q2=2*b*b*b-9*a*b*c+27*c*c+27*a*a*d-72*b*d;
q3=-4*q1*q1*q1+q2*q2;
q4=-a*a*a+4*a*b-8*c;

s0=0.25*a*a-2*b*third;
s1=root3*q1*third/(q2+sqrt(q3))^third;
s2=((q2+sqrt(q3))/54)^third;

r1=-0.25*a-0.5*sqrt(s0+s1+s2)-0.5*sqrt(2*s0-s1-s2-0.25*q4/sqrt(s0+s1+s2));
r2=-0.25*a-0.5*sqrt(s0+s1+s2)+0.5*sqrt(2*s0-s1-s2-0.25*q4/sqrt(s0+s1+s2));
r3=-0.25*a+0.5*sqrt(s0+s1+s2)-0.5*sqrt(2*s0-s1-s2+0.25*q4/sqrt(s0+s1+s2));
r4=-0.25*a+0.5*sqrt(s0+s1+s2)+0.5*sqrt(2*s0-s1-s2+0.25*q4/sqrt(s0+s1+s2));
end

• The MathJax tutorials beckon... – daOnlyBG Sep 4 '15 at 17:08