Calculate the derivative of a function
public static double FirstDerivative(this double[] x, double[] y, double x_0, double dx) { int idx; Helpers.FindIndex(x, x_0, out idx); double x_m = x[idx - 1]; double x_p = x[idx + 1]; double f_m = y[idx - 1]; double f_0 = y[idx]; double f_p = y[idx + 1]; double h = x_p - x_m; return (f_p - f_m) / h; }