


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



We would like to calculate the derivative of a smooth function defined on a discrete set of grid points x 0 , x 1 ,... , 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.
From linear piecewise Lagrange interpolation we have
f (x) =
xi+1 − x xi+1 − xi
f (xi) +
x − xi xi+1 − xi
f (xi+1).
Differentiating, we find that the derivative is a constant and the same at the two ends of the interval
f ′(xi) =
fi+1 − fi hi
hi
∆fi, f ′(xi+1) =
fi+1 − fi hi
hi
∇fi+1,
where ∆ and ∇ are forward and backward difference operators. Note that the derivative is discontinuous at the end points. From quadratic piecewise Lagrange interpolation we have
f (x) =
(x − xi)(x − xi+1) (xi− 1 − xi)(xi− 1 − xi+1) f (xi− 1 ) +
(x − xi− 1 )(x − xi+1) (xi − xi− 1 )(xi − xi+1) f (xi) +
(x − xi− 1 )(x − xi) (xi+1 − xi− 1 )(xi+1 − xi)
f (xi+1).
Differentiating and evaluating the result at the midpoint of the interval we obtain
f ′(xi) = −
hi hi− 1 (hi− 1 + hi)
fi− 1 +
hi− 1
hi
fi +
hi− 1 hi (hi− 1 + hi)
fi+1.
For equally spaced intervals hi− 1 = hi = h, so
f ′(xi) =
fi+1 − fi− 1 2 h
2 h
(∆ + ∇) fi.
This is the central difference formula, and is the average of the forward and backward formulas. If we differentiate f (x) twice and evaluate the result at xi we obtain a constant in the interval xi− 1 ≤ x ≤ xi+
f ′′(xi) =
hi− 1 (hi− 1 + hi)
fi− 1 −
hi− 1 hi
fi +
hi (hi− 1 + hi)
fi+1,
which for equally spaced intervals reduces to
f ′′(xi) = fi− 1 − 2 fi + fi+ h^2
h^2
∆∇fi =
h^2
∇∆fi.
Since f ′′^ is constant, it is called a forward, central, or backward formula depending whether it is evaluated at xi− 1 , xi, or xi+1, respectively. The use of cubic splines to derive finite difference approximations has received little attention. It requires the solution of the tridiagonal system
hi− 1 6
f ′′(xi− 1 ) +
(hi− 1 + hi) 3
f ′′(xi) +
hi 6
f ′′(xi+1 ) =
f (xi+1) − f (xi) hi
f (xi) − f (xi− 1 ) hi− 1
For uniform intervals we obtain
1 6
f (^) i′′− 1 +
f (^) i′′ +
f (^) i′′+1 =
fi− 1 − 2 fi + fi+ h^2
Note that the solution of this system gives us the approximation for the second derivative, and the effect of the spline is to distribute the previous result over the central point and its neighbors with weights 1/6, 2/3, and 1/6. Once this tridiagonal system is solved, the appropriate f (^) i′′ can be used in the first derivative approximation obtained by differentiating the spline approximation for f (x) and evaluating the result at xi.
Finite difference formulas can be easily derived from Taylor series expansions. For example, to obtain an approximation for the derivative of f (x) at the point xi, we use
f (xi+1) = f (xi) + (xi+1 − xi)f ′(xi) +
(xi+1 − xi)^2 2
f ′′(xi) + · · ·.
Rearrangement leads to:
f ′(xi) =
f (xi+1) − f (xi) hi
hi 2 f ′′(xi) + · · ·.
When the grid points are uniformly spaced, the above formula can be recast in the following form
f (^) i′ =
fi+1 − fi 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,
f (^) i′ = fi − fi− 1 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:
fi+1 = fi + hf (^) i′ +
h^2 2
f (^) i′′ +
h^3 6
f (^) i′′′ + · · · (4.1)
fi− 1 = fi − hf (^) i′ +
h^2 2
f (^) i′′ −
h^3 6
f (^) i′′′ + · · ·. (4.2)
Now using the Taylor series expansion for ehD^ and e−hD^ for small values of h we obtain:
ehD^ = 1 + hD +
h^2 D^2 +
h^3 D^3 +... +
n!
hnDn^ +... ,
e−hD^ = 1 − hD +
h^2 D^2 −
h^3 D^3 +... +
(−1)n n! hnDn^ +....
Substituting these expressions to Eq. (4.4) we obtain:
fi+1 − fi− 1 2 h
h^2 D^3 +...
fi. (4.5)
Reorganizing left and right hand sides of this equation would result in Eq. (4.3).