# How to find the zeros of a fourth degree polynomial without integer coefficient

I am currently programming a simulation for a pinball game and want to calculate the time when the ball hits a circle (if they collide at some point). For the calculation part, i'm adding the radius of the ball to the radius of the circle, so that i only have to check if the midpoint of the ball collides with the circle. Of course, the circle is displayed with it's original radius.

Now for the ball's (midpoint) trajectory i've got these two equations who define the movement of the ball on the x- and y-axis (depending on the gravitational acceleration):

$x\left(t\right) = S.x + V.x*t$

$y\left(t\right) = S.y + V.y * t - \frac{1}{2}G * t^2$

With $S$= starting point of the ball, $V$= initial velocity, $G$= gravitational acceleration and $t$= time.

To check for collision, i took these two equations and put them into the equation of a circle, namely:

$(x - M.x)^2 + (y - M.y)^2 = r^2$

With $M$ and $r$ = midpoint and radius.

And what i got is:

$((S.x + V.x * t)-M.x)^2 + ((S.y + V.y*t-\frac{1}{2}G*t^2)-M.y)^2 = r^2$

I actually multiplied out that monster of an equation completely, only to recognize that i don't know what to do with it now. I ended up with an equation that looks like this (i better not type in my whole solution):

$at^4 + bt^3 + ct^2 + dt + e = 0$

So i need to get the zeros of that polynomial and i don't know how. Obviously the coefficients could be any integer or decimal number and i haven't found a method to deal with that kind of equation yet.

Thanks for any kind of help and maybe someone can think of another way to solve that problem than getting the zeros of that 4th degree polynomial.

I'm sorry for any grammar mistakes.

Edit: I know i could just check for the distance between the circle and the ball every timestep, but that's not what i want. Because of performance issues it is way much better to calculate the time, when the first collision occurs, only once.

• – Dr. Sonnhard Graubner Oct 3 '15 at 19:22
• See my answer to « math.stackexchange.com/913350 ». I might be wrong, but I don't think your problem requires solving a quartic. – Senex Ægypti Parvi Oct 3 '15 at 19:44
• @ Dr. Sonnard - i don't really understand the steps that are made on that site. @Senex - your link doesn't work, but i also got the feeling that there has to be an easier way. – Tobaz Oct 3 '15 at 21:09
• @tobaz \\ In my haste, I omitted the word "questions/". Sorry! Try: « math.stackexchange.com/questions/913350 » . – Senex Ægypti Parvi Oct 3 '15 at 21:28
• @SenexÆgyptiParvi \\ i think i understand the point you make there, but my problem is a different one because the ball (moving circle) is not moving with a constant velocity on the y-axis, due to the gravitaional force. So the ball flys in the form of a parabola and the speed in y-direction gets smaller and smaller if it flys upwards and gets bigger and bigger if the ball falls. – Tobaz Oct 3 '15 at 21:58

In case you come back, try this easy way to solve the general quartic. Given,

$$Ax^4+Bx^3+Cx^2+Dx+E = 0$$

divide by $A$ to get the simpler,

$$x^4+ax^3+bx^2+cx+d=0$$

Then the four roots are,

$$x_{1,2} = -\frac{a}{4}+\frac{\color{red}\pm\sqrt{u}}{2}\color{blue}+\frac{1}{4}\sqrt{3a^2-8b-4u+\frac{-a^3+4ab-8c}{\color{red}\pm\sqrt{u}}}\tag1$$

$$x_{3,4} = -\frac{a}{4}+\frac{\color{red}\pm\sqrt{u}}{2}\color{blue}-\frac{1}{4}\sqrt{3a^2-8b-4u+\frac{-a^3+4ab-8c}{\color{red}\pm\sqrt{u}}}\tag2$$

where,

$$u = \frac{a^2}{4}-\frac{2b}{3} +\frac{1}{3}\left(v_1^{1/3}\zeta_3+\frac{b^2 - 3 a c + 12 d}{v_1^{1/3}\zeta_3}\right)$$

with $v_1$ any non-zero root of the quadratic,

$$v^2 + (-2 b^3 + 9 a b c - 27 c^2 - 27 a^2 d + 72 b d)v + (b^2 - 3 a c + 12 d)^3 = 0$$

and a chosen cube root of unity $\zeta_3^3 = 1$ such that $u$ is also non-zero. (Normally, use $\zeta_3=1$, but not when $a^3-4ab+8c = 0$.)

P.S. This is essentially the method used by Mathematica, though much simplified for aesthetics.