Skip to main content

approx_fprime

Function approx_fprime 

Source
pub fn approx_fprime(
    f: impl Fn(&[f64]) -> f64,
    x: &[f64],
    epsilon: f64,
) -> Vec<f64>
Expand description

The forward-difference gradient (f(x + hεᵢ) − f(x))/h of f at x (SciPy’s approx_fprime), with step epsilon (SciPy’s default is √ε ≈ 1.49·10⁻⁸); the step actually used is the representable (xᵢ + h) − xᵢ. Its error is about h|f''|/2 + 2ε|f|/h, smallest near the default.