[][src]Function roots::find_roots_cubic_normalized

pub fn find_roots_cubic_normalized<F: FloatType>(
    a2: F,
    a1: F,
    a0: F
) -> Roots<F>

Solves a normalized cubic equation x^3 + a2x^2 + a1x + a0 = 0.

Trigonometric solution (arccos/cos) is implemented for three roots.

In case more than one roots are present, they are returned in the increasing order.

Examples

use roots::find_roots_cubic_normalized;

let one_root = find_roots_cubic_normalized(0f64, 0f64, 0f64);
// Returns Roots::One([0f64]) as 'x^3 = 0' has one root 0

let three_roots = find_roots_cubic_normalized(0f32, -1f32, 0f32);
// Returns Roots::Three([-1f32, -0f32, 1f32]) as 'x^3 - x = 0' has roots -1, 0, and 1