Numerical Differentiation, Part II 1
6.2 Numerical Differentiation, Part II
1. Derive the second-order central difference approximation for the first derivative,
including error term:
f0(x0) = f(x0+h)f(x0h)
2hh2
6f000 (ξ).
Let x0h,x0and x0+hbe the interpolating points. Using the Lagrange form of
the interpolating polynomial, we find
If we now differentiate fwith respect to x, we obtain
Evaluating this expression at x=x0then yields
2. Derive equation (4).
Let x0,x0+hand x0+ 2hbe the interpolating points. Using the Lagrange form
of the interpolating polynomial, we find
2Section 6.2
If we now differentiate fwith respect to x, we obtain
f0(x) = 2x2x03h
3. Derive equation (7).
Let x0h,x0and x0+hbe the interpolating points. Using the Lagrange form of
the interpolating polynomial, we find
If we now differentiate ftwice with respect to x, we obtain
Evaluating this expression at x=x0then yields
4. (a) Derive the following difference approximation for the first derivative:
f0(x0)f(x0+ 2h)f(x0h)
3h.
Numerical Differentiation, Part II 3
(b) What is the error term associated with this formula?
(c) Numerically verify the order of approximation using f(x) = ln xand x0=
2.
(a) Let x0hand x0+ 2hbe the interpolating points. Using the Lagrange form
of the interpolating polynomial, we find
If we now differentiate fwith respect to x, we obtain
Evaluating this expression at x=x0then yields
(b) From part (a), the leading term in the error is
(c) According to parts (a) and (b), the difference approximation is first-order.
4Section 6.2
5. (a) Derive the following forward difference approximation for the second deriva-
tive:
f00 (x0)f(x0)2f(x0+h) + f(x0+ 2h)
h2.
(b) What is the error term associated with this formula?
(c) Numerically verify the order of approximation using f(x) = exand x0= 0.
(a) Let x0,x0+hand x0+ 2hbe the interpolating points. Using the Lagrange
form of the interpolating polynomial, we find
If we now differentiate ftwice with respect to x, we obtain
f00 (x) = 1
Evaluating this expression at x=x0then yields
(b) From part (a), the leading term in the error is
Numerical Differentiation, Part II 5
hf(x0)2f(x0+h) + f(x0+ 2h)
h2error
1 2.952492 1.952492
6. (a) Derive the following backward difference approximation for the second
derivative:
f00 (x0)f(x02h)2f(x0h) + f(x0)
h2.
(b) What is the error term associated with this formula?
(c) Numerically verify the order of approximation using f(x) = ln xand x0=
2.
(a) Let x02h,x0hand x0be the interpolating points. Using the Lagrange
form of the interpolating polynomial, we find
If we now differentiate ftwice with respect to x, we obtain
f00 (x) = 1
h2f(x02h)2
h2f(x0h) + 1
h2f(x0)
Evaluating this expression at x=x0then yields
6Section 6.2
(b) From part (a), the leading term in the error is
(c) According to parts (a) and (b), the difference approximation is first-order.
7. (a) Derive a formula for approximating the first derivative of an arbitrary
function at x=x0using four equally spaced points, with two (2) of those
points to the left and one (1) to the right of x=x0.
(b) What is the order of approximation for the formula obtained in part (a)?
Completely justify your response.
(a) Let x02h,x0h,x0and x0+hbe the interpolating points. Using the
Lagrange form of the interpolating polynomial, we find
If we now differentiate fwith respect to x, we obtain
f0(x) = 3(xx0)2h2
Numerical Differentiation, Part II 7
Evaluating this expression at x=x0then yields
f0(x0) = 1
6hf(x02h)1
hf(x0h) + 1
2hf(x0) + 1
3hf(x0+h)
(b) From part (a), the error term
8. (a) Derive a formula for approximating the first derivative of an arbitrary
function at x=x0by interpolating at x=x0+hand x=x0αh for
α > 0.
(b) Show, analytically, that the formula from part (a) is second-order when
α= 1, but only first-order for α6= 1.
(a) Let x0αh and x0+hbe the interpolating points for some α > 0. Using
the Lagrange form of the interpolating polynomial, we find
8Section 6.2
(b) If α6= 1, then the leading term in the error is
9. (a) Derive a formula for approximating the second derivative of an arbitrary
function at x=x0by interpolating at x=x0+h,x=x0and x=x0αh
for α > 0.
(b) Show, analytically, that the formula from part (a) is second-order when
α= 1, but only first-order for α6= 1.
(a) Let x0αh,x0and x0+hbe the interpolating points for some α > 0. Using
the Lagrange form of the interpolating polynomial, we find
Numerical Differentiation, Part II 9
If we now differentiate ftwice with respect to x, we obtain
f00 (x) = 2
h2α(1 + α)f(x0αh)2
αh2f(x0) + 2
h2α(1 + α)f(x0+h)
Evaluating this expression at x=x0then yields
f00 (x0) = 2
h2α1
1 + αf(x0αh)f(x0) + 1
1 + αf(x0+h)
The first term on the right-hand side constitutes the finite difference approxi-
mation; thus,
(b) If α6= 1, then the leading term in the error is
10. (a) Using f(x) = ln xand x0= 2, demonstrate numerically that the central
difference approximation for the second derivative given by
f00 (x0)f(x0h)2f(x0) + f(x0+h)
h2,
10 Section 6.2
(b) Repeat part (a) using f(x) = exand x0= 0.
We are attempting to verify that the central difference approximation is second
(a) Using f(x) = ln xand x0= 2, the following table confirms the second-order
nature of the difference approximation.
(b) Using f(x) = exand x0= 0, the following table confirms the second-order
nature of the difference approximation.
11. Verify that each of the following difference approximations for the first derivative
provides the exact value of the derivative, regardless of h, for the functions
f(x) = 1, f(x) = xand f(x) = x2, but not for the function f(x) = x3.
(a) f0(x0)3f(x0)+4f(x0+h)f(x0+2h)
2h
(b) f0(x0)3f(x0)4f(x0h)+f(x02h)
2h
(c) f0(x0)f(x0+h)f(x0h)
2h
(a)
f0(x0)3f(x0)+4f(x0+h)f(x0+ 2h)
(b)
Numerical Differentiation, Part II 11
f0(x0)3f(x0)4f(x0h) + f(x02h)
2h= 3x2
(c)
f0(x0)f(x0+h)f(x0h)
2h
12. Verify that the second-order central difference approximation for the second
derivative provides the exact value of the second derivative, regardless of the
value of h, for the functions f(x) = 1, f(x) = x,f(x) = x2and f(x) = x3, but
not for the function f(x) = x4.
Recall that the second-order central difference approximation for the second deriva-
f(x) = 1 012+1
13. (a) Use the formula
f0(x0)f(x0+h)f(x0)
h
12 Section 6.2
(b) Repeat part (a) for x0= 0.
(c) Explain any difference between the results from part (a) and those from
part (b).
(a) Let f(x) = 1+x+x3and x0= 1. Because the error in the approximate value
by a factor of 10, the data suggests first order convergence.
hf(x0+h)f(x0)
herror
18.000000 4.000000
(b) Now, take x0= 0. Because the error in the approximate value of the derivative
of 10, the data suggests second order convergence.
hf(x0+h)f(x0)
herror
(c) The rate of convergence in part (a) is what one would expect from the given
14. (a) Use the formula
f0(x0)f(x0)f(x0h)
h
to approximate the derivative of f(x) = sin xat x0=π, taking h=
1,0.1,0.01 and 0.001. What is the order of approximation?
(b) Repeat part (a) for x0=π/2.
(c) Explain any difference between the results from part (a) and those from
part (b).
Numerical Differentiation, Part II 13
(a) Let f(x) = sin xand x0=π. Because the error in the approximate value
hf(x0)f(x0h)
herror
(b) Now, take x0= 0. Because the error in the approximate value of the derivative
10.459697 0.459697
(c) The rate of convergence in part (b) is what one would expect from the given
formula; the rate of convergence is higher than expected in part (a). Recall
15. Consider the following formula for approximating the first derivative of an ar-
bitrary function:
f0(x0) = 2f(x03h)+9f(x02h)18f(x0h) + 11f(x0)
6h+1
4h3f(4)(ξ),
where x03h < ξ < x0.
(a) Suppose that the function values used in the above formula contain round-
off/data errors which are bounded in absolute value by and that the
absolute value of the fourth derivative is bounded by M. Derive a bound
for the approximation error associated with the above formula as a function
of ,Mand h.
(b) Suppose = 5.96 ×108(machine precision in IEEE standard single preci-
sion). Determine the value for the step size hwhich minimizes the bound
on the error when approximating the value of the derivative of f(x) = ex
at x0= 1.
(a) Suppose calculations will be made with ˜
f(x03h),˜
f(x02h),˜
f(x0h)
and ˜
f(x0), where
f(x03h) = ˜
f(x03h) + e(x03h),
f(x03h)+9˜
f(x02h)18 ˜
f(x0h) + 11 ˜
f(x0)
Assuming all roundoff errors are bounded in absolute value by and the abso-
lute value of the fourth derivative is bounded by M, we find
(b) The bound on the error will be a minimum when
16. Consider the second-order forward difference formula for approximating the first
derivative of an arbitrary function:
f0(x0) = 3f(x0)+4f(x0+h)f(x0+ 2h)
2h+1
3h2f000 (ξ),
where x0< ξ < x0+ 2h.
Numerical Differentiation, Part II 15
(a) Suppose that the function values used in the above formula contain round-
off/data errors which are bounded in absolute value by and that the
absolute value of the third derivative is bounded by M. Derive a bound for
the approximation error associated with the above formula as a function
of ,Mand h.
(b) Suppose = 1.11 ×1016 (machine precision in IEEE standard double
precision). Determine the value for the step size hwhich minimizes the
bound on the error when approximating the value of the derivative of
f(x) = ln xat x0= 2.
(a) Suppose calculations will be made with ˜
f(x0),˜
f(x0+h)and ˜
f(x0+ 2h),
where
and e(x0),e(x0+h)and e(x0+ 2h)are the respective roundoff errors. Then
Assuming all roundoff errors are bounded in absolute value by and the abso-
lute value of the third derivative is bounded by M, we find
(b) The bound on the error will be a minimum when