What Is the Approximation Formula for a Higher-Order Derivative?
At a glance
- 1. Choose a stencil
Select function values near the point where you want the derivative; the points and weights form a finite-difference stencil.
- 2. Apply the difference formula
For an nth derivative, the nth forward difference gives a basic approximation after division by the step size raised to n.
- 3. Check the error
The basic forward formula is generally first-order accurate; symmetric or wider stencils can give better accuracy.
- 4. Test the result
Compare estimates at smaller step sizes or against a known derivative to check numerical error.
A higher-order derivative can be estimated from function values near the point of interest using finite differences. The general formula depends on which points you use and how accurate you need the result to be. A simple formula works for any derivative order, while carefully chosen stencils can reduce the approximation error.
The general forward-difference formula
Let denote the th derivative, and let be a nonzero step size. The th forward difference is
Dividing by gives the basic approximation:
For example, the first few cases are
This comes from applying Taylor expansions to the function values and combining them so that lower-order terms cancel. If the function is sufficiently smooth, the forward formula has an error of order as approaches zero. Thus, halving typically reduces the leading error by about a factor of two, provided rounding error does not become dominant.
A more accurate central formula
The general forward formula is convenient, but it uses points on just one side of and is not always the most accurate choice. For the second derivative, a common symmetric stencil is
Taylor expansion about shows that its leading error is proportional to :
The notation describes terms that, under suitable smoothness assumptions, shrink at least as fast as . The central formula is therefore second-order accurate: when is halved, its leading truncation error is about one quarter as large.
Worked example: approximate a second derivative
Take and estimate using the central formula with . The exact derivative is , so .
First evaluate the function at the three stencil points:
Substitute these values:
The estimate is , compared with the exact value . In this example the error is exactly : since , the leading central-formula error is .
Choosing a step size and stencil
A smaller reduces truncation error, but it does not always improve the computed answer. When is extremely small, subtracting nearly equal function values can magnify floating-point rounding error. In practice, try a few reasonable step sizes and look for estimates that stabilize. If the function can be evaluated only at points in one direction—for example, near the boundary of its domain—a forward or backward stencil may be necessary.
For higher accuracy, use more points and choose weights that cancel additional Taylor-series terms. The weights depend on the desired derivative order, accuracy, and point locations; the basic forward formula should not be assumed to have high-order accuracy just because is large.
Common mistakes
- Using the wrong power of : For an th derivative, the finite-difference numerator is divided by , not just by .
- Mixing up stencil formulas: The forward second-difference formula uses , , and . The central second-difference formula uses , , and .
- Ignoring the error order: The basic forward formula is generally first-order accurate; the standard central second-derivative formula is second-order accurate.
- Making too small: Roundoff and cancellation can outweigh the benefit of reducing truncation error.
References
- Numerical Analysis, Richard L. Burden, J. Douglas Faires, and Annette M. Burden
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.