Math: Solution of Quadratic Equation

Note: In Numerical Recipes in Pascal (Press, etal. , Cambridge University Press, 1989) - section 5.5, there is a better way to compute the roots of the quadratic equation.

                                                             
The normal way :  x = [-b (+/-) (b2 - 4ac).5]/2a 
If either a or c small then we get -b (+/-) b' with b' ~ b  
and this may give a numerical error.

A better way is: q = -0.5 [b +sgn(b) (b2 - 4ac) .5]
then  x1 = q/a;  x2 = c/q ;    


Main Math page
HyperGraph home page.

Last changed April 01, 1998, G. Scott Owen, owen@siggraph.org