[−][src]Function roots::find_roots_cubic
pub fn find_roots_cubic<F: FloatType>(a3: F, a2: F, a1: F, a0: F) -> Roots<F>
Solves a cubic equation a3x^3 + a2x^2 + a1*x + a0 = 0.
In case more than one roots are present, they are returned in the increasing order.
Examples
use roots::Roots; use roots::find_roots_cubic; let no_roots = find_roots_cubic(0f32, 1f32, 0f32, 1f32); // Returns Roots::No([]) as 'x^2 + 1 = 0' has no roots let one_root = find_roots_cubic(1f64, 0f64, 0f64, 0f64); // Returns Roots::One([0f64]) as 'x^3 = 0' has one root 0 let three_roots = find_roots_cubic(1f32, 0f32, -1f32, 0f32); // Returns Roots::Three([-1f32, 0f32, 1f32]) as 'x^3 - x = 0' has roots -1, 0, and 1