Professional Documents
Culture Documents
Differentiation
Differentiation
Numerical Differentiation
We would like to calculate the derivative of a smooth function defined on a discrete set of grid points
x0 , x1 , . . . , xN . Assume that the data are the exact values of the function at the data points, and we need
the derivative only at the data points. We will look into the construction of numerical approximations of
the derivative called finite differences. There are two approaches to such constructions: using interpolation
formulas, or Taylor series approximations.
19
20 CHAPTER 4. NUMERICAL DIFFERENTIATION
(xi+1 − xi )2 ′′
f (xi+1 ) = f (xi ) + (xi+1 − xi )f ′ (xi ) + f (xi ) + · · · .
2
Rearrangement leads to:
f (xi+1 ) − f (xi ) hi ′′
f ′ (xi ) = − f (xi ) + · · · .
hi 2
When the grid points are uniformly spaced, the above formula can be recast in the following form
fi+1 − fi
fi′ = + O(h).
h
This formula is referred to as the first order forward difference. The exponent of h in O(h) is the order of
accuracy of the method. With a first order scheme, if we refine the mesh size by a factor of 2, the error
(called the truncation error) is reduced by approximately a factor of 2. Similarly,
fi − fi−1
fi′ = + O(h)
h
is called the first order backward difference formula. Higher order (more accurate) schemes can be derived
by Taylor series of the function f at different points about the point xi . For example, the widely used
central difference formula can be obtained from subtraction of the two Taylor series expansions:
h2 ′′ h3 ′′′
fi+1 = fi + hfi′ + f + fi + · · · (4.1)
2 i 6
h2 ′′ h3 ′′′
fi−1 = fi − hfi′ + f − fi + · · · . (4.2)
2 i 6
4.3. DIFFERENCE OPERATORS 21
where h is the difference interval. For linking the difference operators with the differential operator we
consider Taylor’s formula
1 2 ′′
f (x + h) = f (x) + hf ′ (x) + h f (x) + · · · .
2!
In operator notations we can write
1 2
Ef (x) = 1 + hD + (hD) + · · · f (x) .
2!
The series in brackets is the expression for the exponential and hence we have (formally)
E = ehD .
This relation is very important, since it can be used by symbolic programs such as Maple or Mathe-
matica to analyze the accuracy of finite difference schemes. For example, consider the finite difference
operator defined by Eq. (4.3). Applying the shift operator to fi we can write fi+1 = Efi = ehD fi and
fi−1 = E −1 fi = e−hD fi . Now, substituting these expressions into central difference approximation for
the derivative we obtain:
fi+1 − fi−1 ehD fi + e−hD fi ehD + e−hD
= = fi . (4.4)
2h 2h 2h
22 CHAPTER 4. NUMERICAL DIFFERENTIATION
Now using the Taylor series expansion for ehD and e−hD for small values of h we obtain:
1 1 3 3 1
ehD = 1 + hD + h2 D2 + h D + . . . + hn D n + . . . ,
2 6 n!
1 1 3 3 (−1)n n n
e−hD = 1 − hD + h2 D2 − h D + ... + h D + ....
2 6 n!
Substituting these expressions to Eq. (4.4) we obtain:
fi+1 − fi−1 1
= D + h2 D 3 + . . . f i . (4.5)
2h 6
Reorganizing left and right hand sides of this equation would result in Eq. (4.3).