The following information outlined on this page are standard numerical methods for calculating accurate values for derivatives. Note that these are primarily intended with the purpose of providing high-accuracy numerical differentiation for uses with specialized derivatives such as with calculation of Jacobian and Hessian matrices.
Source: Applied Numerical Methods with MATLAB for Engineers and Scientists (by Steven C. Chapra, 4th edition)
Source: starts on pg. 121
<aside> 💡 Note that $h$ is the step size and is the length of the interval over which the approximation is calculated with. The accuracy will be better if the step size is smaller.
</aside>
Source: starts on pg. 554
The big-O notation represents the relative magnitude of the error as a function of the step-size. Say for instance, we’re using the first equation listed below and half the step size, the error will decrease by one half. If using the second formula and half the step size, the error will become one quarter.
<aside> 📢 Generally, better accuracy formulas (higher order of h) come at the expense of higher computational cost. When possible we should be using the centered difference formulas (3rd table) with the higher accuracy configurations.
</aside>
<aside> 💡 These equations above should be sufficient for our purposes but note that other methods including Richardson extrapolation are available.
</aside>
$$ \frac{\partial f}{\partial x} = \frac{f(x + \Delta x, y) - f(x - \Delta x, y)}{2\Delta x} $$
$$ \frac{\partial f}{\partial x} = \frac{f(x, y + \Delta y) - f(x, y-\Delta y)}{2\Delta y} $$
$$ \frac{\partial ^2 f}{\partial x \partial y} = \frac{\partial}{\partial x}\left(\frac{\partial f}{\partial y}\right) $$