Skip to main content

bisect

Function bisect 

Source
pub fn bisect(
    f: &dyn Fn(f64) -> f64,
    a: f64,
    b: f64,
    tol: f64,
    max_iter: usize,
) -> Result<f64, String>
Expand description

Bisection method for scalar root finding.

Finds x in [a, b] such that |f(x)| < tol, given that f(a) and f(b) have opposite signs. Returns Err if the bracket is invalid.