Skip to main content

bisection

Function bisection 

Source
pub fn bisection<F>(
    f: F,
    lower: f64,
    upper: f64,
    options: RootOptions,
) -> Result<f64, RootError>
where F: Fn(f64) -> f64,
Expand description

Finds a root with the bisection method on a bracketing interval.

The endpoint values must have opposite signs, unless an endpoint is already approximately zero. The interval bounds and function values must be finite. Convergence uses RootOptions::tolerance as an absolute tolerance.

ยงErrors

Returns RootError::InvalidInterval when the bounds are non-finite, reversed, or do not bracket a root; RootError::InvalidTolerance when the tolerance is not finite and positive; RootError::NonFiniteValue when a function evaluation is non-finite; and RootError::MaxIterationsReached when the iteration budget is exhausted without convergence.