Numerical Differentiation
For a given set, it may be important to determine the rates of change - or higher derivatives - of the information in the set. Unless you have a symbolic formula for the system in question, you will need to approximate these derivatives numerically. The following page looks at two ways to find formulas for numerical approximations to derivatives: using polynomial interpolations and using Taylor series approximations.
Polynomial Interpolation
Taylor Series
Another way to determine the numerical approximation to derivatives is based on the Taylor Series:
where \(f^{(n)}(x)\) represents the \(n\)th derivative of \(f(x)\). Imagine three discrete points next to each other on a line, one at \(x\) and the other two \(\Delta x\) away on either side.
where the Order operator \(O()\) signifies the leading order of the remaining terms.
From this, we can find approximations to various derivatives of \(f(x)\) at \(x\). Assume that the \(n\)th derivative will be some function which is a weighted sum of the three terms above:
To get the first derivative only, solve the coefficients above to zero out the terms you do not want and keep only the first derivative:
Notice that there is no way to keep the first derivative and get rid of the third derivative. This means that a three-point approximation to the first derivative will have some error, the highest order of which coming from the third derivative. It turns out that three-point second derivative approximations have their highest order error in the fourth derivative term. In any event, the solution to the above system of three equations and three unknowns is:
so that the approximation to the first derivative is:
where the \(\Delta x^2\) error comes from the combination of the \(\Delta x^3\) in front of the third derivative and the \(\Delta x^{-1}\) in the \(a\) and \(c\) terms. Proceeding in the same way to get the second derivative yields:
You can get higher order accuracy by including more points, but you increase computational complexity. You can also use two points to get an approximation, but you sacrifice accuracy. For instance, the two-point backward-facing first derivative uses \(f(x)\) and \(f(x-\Delta x)\) to get the first derivative:
This is true when \(b=-a=\frac{1}{\Delta x}\), but the approximation becomes
which is now only first order accurate. Trying to use two points for the {\it second} derivative would be catastrophic since the error term would end up being larger than the derivative term!