The main things to know here are a few formulae for approximating derivatives using finite differences:
Given a set of evenly space gridpoints , where , and a function evaluated at the gridpoints , we can approximate the first derivative of at the gridpoints several ways
One-sided finite differencing for the first derivative, rightwards
One-sided finite differencing for the first derivative, leftwards
Centered finite differencing for the first derivative
In practice you use the fraction on the right-hand-side as an approximation of the derivative, knowing that there is an or error in the approximation.
To approximate the second derivative , we use the
Centered finite differencing for the second derivative
There are many, many other finite-difference formulae, for higher-order derivatives, higher-order accuracy, and different choices of which gridpoint values enter into the formula. As a starting point, see the following
Further reading