dy/dx = lim_{h->0} (f(x+h) -f(x))/h
One can approximate this as
dy/dx ~= (f(x+h) -f(x))/h
According to Taylor expansion,
f(x+h) = f(x) + hf'(x) + h^2 f''(x)... (1)
f(x-h) = f(x) - hf'(x) + h^2 f''(x)... (2)
Formula 1 (1st order accurate for 1st derivative) Forward/back difference:
[f(x+h) - f(x)]/h + O(h) = f'(x)
Formula 2 (2nd order accurate for 1st derivative) Central difference,
Eq(1) - Eq(2) -->
[f(x+h) - f(x-h)]/2h + O(h^2) = f'(x)
Formula 3 (2nd order accurate for 2nd derivative) Central difference,
Eq(1) + Eq(2) -->
[f(x+h) + f(x-h) - 2 f(x)]/h^2 + O(h^2) = f''(x)
Last Modified: 10/08/00