Skip to main content

diff_forward

Function diff_forward 

Source
pub fn diff_forward(xs: &[f64], ys: &[f64]) -> Result<Vec<f64>, String>
Expand description

Forward difference approximation of the derivative.

Given paired arrays xs and ys of length n >= 2, returns n-1 derivative estimates:

dy/dx[i] ≈ (ys[i+1] - ys[i]) / (xs[i+1] - xs[i])

This is a first-order accurate approximation.