mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-10 04:31:34 -10:00
The classic solution to the quadratic equation ...
a*x*x + b*x + c = 0
is ...
-b +- sqrt(b*b - 4*ac)
x = ----------------------
2*a
This can be optimized by substituting b = 2*B.
-2*B +- sqrt((2*B)*(2*B) - 4*a*c)
x = ---------------------------------
2*a
This expands to ...
-2*B +- sqrt(4*B*B - 4*a*c)
x = ---------------------------
2*a
And simplifies to ...
-2*B +- 2*sqrt(B*B - 4*a*c)
x = ---------------------------
2*a
-B +- sqrt(B*B - a*c)
x = ---------------------
a
Signed-off-by: Peter Mitsis <[email protected]>