In mathematics, to approximate a derivative to an arbitrary order of accuracy, it is possible to use the
finite difference
A finite difference is a mathematical expression of the form . If a finite difference is divided by , one gets a difference quotient. The approximation of derivatives by finite differences plays a central role in finite difference methods for t ...
. A finite difference can be central, forward or backward.
Central finite difference
This table contains the coefficients of the central differences, for several orders of accuracy and with uniform grid spacing:
[.]
For example, the third derivative with a second-order accuracy is
:
where
represents a uniform grid spacing between each finite difference interval, and
.
For the
-th derivative with accuracy
, there are
central coefficients
. These are given by the solution of the linear equation system
:
where the only non-zero value on the right hand side is in the
-th row.
An open source implementation for calculating finite difference coefficients of arbitrary derivates and accuracy order in one dimension is available.
Forward finite difference
This table contains the coefficients of the forward differences, for several orders of accuracy and with uniform grid spacing:
[
For example, the first derivative with a third-order accuracy and the second derivative with a second-order accuracy are
:
:
while the corresponding backward approximations are given by
:
:
]
Backward finite difference
To get the coefficients of the backward approximations from those of the forward ones, give all ''odd'' derivatives listed in the table in the previous section the opposite sign, whereas for ''even'' derivatives the signs stay the same.
The following table illustrates this:
Arbitrary stencil points
For a given arbitrary stencil points of length with the order of derivatives , the finite difference coefficients can be obtained by solving the linear equations
:
where is the Kronecker delta
In mathematics, the Kronecker delta (named after Leopold Kronecker) is a function of two variables, usually just non-negative integers. The function is 1 if the variables are equal, and 0 otherwise:
\delta_ = \begin
0 &\text i \neq j, \\
1 &\ ...
, equal to one if , and zero otherwise.
Example, for