Function minimize_scalar

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

Minimise f on [lower, upper] by Brent’s method.

Stops when the bracket around the estimate is within 2 (sqrt(eps) |x| + x_tolerance / 3) of it on both sides. Relative accuracy is limited to sqrt(eps): near a smooth minimum, f is flat to second order, so f64 cannot place the minimiser more closely. The function is never evaluated at the interval ends; for a monotone f the estimate converges to within the tolerance of the lower end.

§Errors

Refuses non-finite bounds or tolerance, lower >= upper, a negative tolerance, and any non-finite value of f.