Skip to main content

derivative

Function derivative 

Source
pub fn derivative(
    f: impl Fn(f64) -> f64,
    x: f64,
    options: DerivativeOptions,
) -> Result<DerivativeResult, ErrorsJSL>
Expand description

f'(x) with an error estimate, by Ridders’ extrapolation of central differences.

Row i of the tableau starts from D(hᵢ) = (f(x + hᵢ) − f(x − hᵢ)) / 2hᵢ with hᵢ = h/cⁱ; each column j removes the next even power of h: T(i, j) = (c^{2j} T(i, j−1) − T(i−1, j−1)) / (c^{2j} − 1). The best estimate is the entry whose difference from its two parents is smallest. Extrapolation stops when the diagonal grows by more than twice the best error, the sign that rounding error dominates.