2.11 Finite Difference Approximations of Derivatives
Suppose the derivative of a function f : →
is needed at a specific point x[0]. If an analytic expression for f ′ is unavailable, the derivative can be approximated based upon a finite difference:6
[2.131]
The scalar h should be small, but not so small that roundoff error distorts the result. Often, the value f{x[0]) is already known. If valuing f at two additional points will be computationally expensive, one valuation can be avoided by using the alternative approximation:
[2.132]
We call [2.131] a central approximation and [2.132] a forward approximation. These generalize to multiple dimensions. A partial derivative of a function f : n →
can be approximated at point x[0] with a central approximation:
[2.133]
where ei is a vector whose only nonzero component is its ith component, which equals 1. The corresponding forward approximation is
[2.134]
Exercises
Consider f : 2 →
2:
[2.135]
Value the Jacobian matrix of f at x = (1, 1) three different ways:
- analytically,
- with a central approximation,
- with a forward approximation.
In items (b) and (c), use h = .00001.