Function rgsl::polynomials::quadratic_equations::poly_solve_quadratic [] [src]

pub fn poly_solve_quadratic(
    a: f64,
    b: f64,
    c: f64,
    x0: &mut f64,
    x1: &mut f64
) -> i32

This function finds the real roots of the quadratic equation,

a x2 + b x + c = 0

The number of real roots (either zero, one 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. If one real root is found (i.e. if a=0) then it is stored in x0. 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 (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 b2 - 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.