// Estimate a centered finite-difference slope at an interior sample of uniformly spaced data. Invalid positions or spacing return zero. pub fn central_slope(ys: vector, index: i64, spacing: f64) -> f64 { if index <= 0 || index >= len(ys)-1 || spacing <= 0.0 { return 0.0; } (at(ys,index+1)-at(ys,index-1))/(2.0*spacing) }