A finite difference (divided by a small increment) is an approximation of the derivative of a
The accuracy depends on the function to take the derivative of.
In general, the accuracy of central difference is the best while those of forward and backward
differences are more or less the same.
For finite difference, the higher an order of a derivative, the less accurate it gets.
For example, approximating the 5-th derivative is much less accurate than approximating the 1st
Evaluate numerically the derivative of f at point x, f'(x), with step
It could be challenging to automatically determine the step size h, esp. when
|x| is near 0.
It may, for example, require an analysis that involves f' and f''.
The user may want to experiment with different hs by calling this function.
x - the point to evaluate the derivative of f at
h - step size
f'(x), the numerical derivative of f at point x with step size
public double df(double x,
Compute the finite difference for f at x with an increment h for the
n-th order using either forward, backward, or central difference.