Function roots::find_roots_quadratic
[−]
[src]
pub fn find_roots_quadratic<F: FloatType>(a2: F, a1: F, a0: F) -> Roots<F>
Solves a quadratic equation a2*x2 + a1*x + a0 = 0.
In case two roots are present, the first returned root is less than the second one.
Examples
use roots::Roots; use roots::find_roots_quadratic; let no_roots = find_roots_quadratic(1f32, 0f32, 1f32); // Returns Roots::No([]) as 'x^2 + 1 = 0' has no roots let one_root = find_roots_quadratic(1f64, 0f64, 0f64); // Returns Roots::One([0f64]) as 'x^2 = 0' has one root 0 let two_roots = find_roots_quadratic(1f32, 0f32, -1f32); // Returns Roots::Two([-1f32,1f32]) as 'x^2 - 1 = 0' has roots -1 and 1