The number of real roots (either zero or two) is returned, and their locations are stored in x0 and x1. If no real roots are found then x0 and x1 are not modified. When two real roots are found they are stored in x0 and x1 in ascending order. The case of coincident roots is not considered special. For example @math{(x-1)^2=0} will have two roots, which happen to have exactly equal values.
The number of roots found depends on the sign of the discriminant @math{b^2 - 4 a c}. This will be subject to rounding and cancellation errors when computed in double precision, and will also be subject to errors if the coefficients of the polynomial are inexact. These errors may cause a discrete change in the number of roots. However, for polynomials with small integer coefficients the discriminant can always be computed exactly.
This function finds the complex roots of the quadratic equation,
The number of complex roots is returned (always two) and the locations of the roots are stored in z0 and z1. The roots are returned in ascending order, sorted first by their real components and then by their imaginary components.