The numerical properties of the

Quadratic Equation make it unsuitable for general use in software. For example, consider the special case a=0, which a human would obviously recognize. For a computer, special code must be written. More subtly, from

Numerical Analysis, we must consider the possibility of cancellation error when b

^{2} is much greater than 4ac. In this case, the solution for one root will be very close to zero, and the other will be close to -b/a. The near-zero number will suffer accuracy problems.

To avoid the difficulty with cancellation, we may compute the roots with the following:

z = -0.5 (b + sign(b)*(b

^{2} - 4ac))

x

_{1} = z/a

x

_{2} = c/z

Source: Numerical Recipes