7.1: Derivatives
( \newcommand{\kernel}{\mathrm{null}\,}\)
Suppose we have discretized a function of one variable, obtaining a set of
Let us discuss how the first and higher-order derivatives of
7.1.1 First Derivative
The most straightforward representation of the first derivative is the forward-difference formula:
This is inspired by the usual definition of the derivative of a function, and approaches the true derivative as
We can expand
Plugging this into the error formula, we find that the error decreases linearly with the spacing:
There is a better alternative, called the mid-point formula. This approximates the first derivative by sampling the points to the left and right of the desired position:
To see why this is better, let us write down the Taylor series for
Note that the two series have the same terms involving even powers of
Because the
Hence, the error of the mid-point formula scales as
It is possible to come up with better approximation formulas for the first derivative by including terms involving
7.1.2 Second Derivative
The discretization of the second derivative is easy to figure out too. We again write down the Taylor series for
When we add the two series together, the terms involving odd powers of
A minor rearrangement of the equation then gives
This is called the three-point rule for the second derivative, because it involves the value of the function at the three points