Next: 9.4
Interpolation and extrapolation Up: 9.
Numerical Methods Previous: 9.2
The Taylor series
9.3 Finite-difference derivatives
Finite-difference formulas make it possible to use arithmetic operations
to determine derivatives. They are based on the Taylor series truncated
at various orders in the expansion. The first-order expansion, of course,
just gives the form
 |
(9.3) |
or
 |
(9.4) |
where
indicates that the error in this approximation is of order
.
If an index is used to indicate consecutive values at intervals
,
so that
if fi=f(x), then
 |
(9.5) |
is called the first forward difference and
 |
(9.6) |
is the first backward difference formula for the derivative.
Similar expressions can be found for higher-order derivatives. For example,
the second derivative is
 |
(9.7) |
 |
(9.8) |
 |
(9.9) |
The corresponding backward-difference formula is
 |
(9.10) |
The preceding formulas were obtained by taking only the first term in
the Taylor series containing the desired derivative. More accurate formulas
can be obtained by retaining more terms. For example,
 |
(9.11) |
![\begin{displaymath}~~~~={{f(x+\delta)-f(x)}\over{\delta}}-{{\delta}\over{2}}\le......)}\over{\delta^2}}+{\cal O}(\delta)\right]+{\cal O}(\delta^2) \end{displaymath}](img619.gif) |
(9.12) |
or
 |
(9.13) |
Another improvement is to use central differences:
 |
(9.14) |
 |
(9.15) |
 |
(9.16) |
The centered-difference formula is more accurate than the forward or
backward-difference formulas, but still involves only two terms. Table
9 .1 lists some finite-difference formulas for derivatives.
Table 9.1: Finite-difference derivatives
The entries in this table are the coefficients of the corresponding
function value fi+j in the expression
for the derivative. For example, the second-order centered-difference expression
for f''' is
where
is the interval between consecutive values fi.
&#& # height2pt&&&&
&derivative&& fi-3&&fi-2&&fi-1&&fi&&fi+1&&fi+2&&fi+3&&fi+4&
height2pt&&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
¢ered&&&&&&&&&&&&&&&&&
&(O(
))&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
&
&&
&&&&-1&&0&&1&&&&&&&
&
&&&&&&1&&-2&&1&&&&&&&
&
&&&&-1&&2&&0&&-2&&1&&&&&
height2pt&&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
¢ered&&&&&&&&&&&&&&&&&
&(O(
))&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
&
&&&&1&&-8&&0&&8&&-1&&&&&
&
&&&&-1&&16&&-30&&16&&-1&&&&&
&
&&1&&-8&&13&&0&&-13&&8&&-1&&&
height2pt&&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
&forward&&&&&&&&&&&&&&&&&
&(O(
))&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
&
&&&&&&&&-1&&1&&&&&&&
&
&&&&&&&&1&&-2&&1&&&&&
&
&&&&&&&&-1&&3&&-3&&1&&&
height2pt&&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
&forward&&&&&&&&&&&&&&&&&
&(O(
))&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
&
&&&&&&&&-3&&4&&-1&&&&&
&
&&&&&&&&2&&-5&&4&&-1&&&
&
&&&&&&&&-5&&18&&-24&&14&&-3&
height2pt&&&&&&&&&&&&&&&&&&
height2pt&&&&&&&&&&&&&&&&&&
Finite-difference formulas are often used to evaluate derivatives of
functions when analytical expressions are not available. For example, the
procedures for nonlinear least-squares fitting often need derivatives of
the chisquare function with respect to the parameters, and these are sometimes
easier to evaluate numerically than analytically. Because the error in
the derivatives scales with the size of
,
the step used for evaluating such derivatives should be small, but not
so small that rounding errors are introduced by the digital representation
of the values in the computer.
Next: 9.4
Interpolation and extrapolation Up: 9.
Numerical Methods Previous: 9.2
The Taylor series
NCAR Advanced Study Program
http://www.asp.ucar.edu