Function find_root

Source
pub fn find_root<F>(
    f: F,
    lower: f64,
    upper: f64,
    x_tolerance: f64,
) -> NumericResult<Root>
where F: FnMut(f64) -> f64,
Expand description

Find a root of f in [lower, upper] by Brent’s method.

f(lower) and f(upper) must differ in sign (or one of them be zero). Iteration stops when the bracket is no wider than 4 * eps * |x| + x_tolerance, or when its ends are adjacent floats; x_tolerance = 0 therefore asks for full precision.

§Errors

Refuses non-finite bounds or tolerance, lower > upper, a negative tolerance, bracket ends of the same sign (NumericError::NoSignChange), and any non-finite value of f.