pub fn derivative<F>(f: F, x: f64, h: f64) -> f64Expand description
Numerical derivative using finite differences
§Arguments
f- Function to differentiatex- Point at which to evaluate derivativeh- Step size (default: 1.0)
§Example
use dodecet_encoder::calculus;
let f = |x: f64| x * x;
let deriv = calculus::derivative(f, 2.0, 0.01);
assert!((deriv - 4.0).abs() < 0.1); // d/dx(x²) = 2x, at x=2, = 4