Numerical Differentiation
Numerical Differentiation
1
with an error bounded by M |h|/2, where M is a bound on |f 00 (x)| for x between
x0 and x0 + h. This formula is known as the forward-difference formula if
h > 0 and the backward-difference formula if h < 0.
Example 1 Values for f (x) are given in table. Use forward-difference and
backward-difference formulas to approximate f 0 (0.5), f 0 (0.6) and f 0 (0.7).
2
or
x0 = 0.6, x1 = 0.7 ⇒ h = 0.1 > 0
So we will compute f 0 (0.6) by applying the forward-difference formula
For f 0 (0.7):
x0 = 0.7, x1 = 0.6 ⇒ h = −0.1 < 0
So we will compute f 0 (0.7) by applying the backward-difference formula
f (1.8 + h) − f (1.8)
f 0 (1.8) ≈
h
ln (1.81) − ln (1.8)
≈ = 0.5540
0.01
Because f 00 (x) = −1/x2 and 1.8 < ξ < 1.81, a bound for this approximation
error is
h
|R(1.8)| = − f 00 (ξ (x))
2
0.01 1
=
2 ξ2
1 1
≤ = 1.5.10−3
200 (1.8)2
NOTE
f (1.81) − f (1.8)
|R(1.8)| = f 0 (1.8) − ≤ 1.5.10−3
0.01
0.5540 − 1.5.10−3 ≤ f 0 (1.8) ≤ 0.5540 + 1.5.10−3
0.5525 ≤ f 0 (1.8) ≤ 0.5555
and
1
f 0 (1.8) = = 0.5555
1.8
3
1.2 Three-Point Formulas
Suppose that x0 ∈ (a, b), where f ∈ C 3 [a, b], and that x1 = x0 + h, x2 = x0 + 2h
for some h 6= 0 that is sufficiently small to ensure that x1 , x2 ∈ [a, b]. We
construct the second Lagrange polynomial P2 (x) for f determined by x0 , x1
and x2 , with its error term:
h2
1 3 1
f 0 (x0 ) = − f (x0 ) + 2f (x0 + h) − f (x0 + 2h) + f 000 (ξ (x))
h 2 2 3
with an error
h2 000
f (ξ (x))
3
This formula is known as the three-point endpoint formula.
Differentiating f with respect to x and then writing x = x0 + h give
h2
f 0 (x0 + h) = P20 (x0 + h) − f 000 (ξ (x))
6
h2
1 1 1
= − f (x0 ) + f (x0 + 2h) − f 000 (ξ (x))
h 2 2 6
h2
1 1 1
f 0 (x0 ) = − f (x0 − h) + f (x0 + h) − f 000 (ξ (x))
h 2 2 6
4
where ξ (x) between x0 − h and x0 + h. Hence, for small values of h,
0 1 1 1
f (x0 ) ≈ − f (x0 − h) + f (x0 + h)
h 2 2
with an error
h2 000
−
f (ξ (x))
6
This formula is known as the three-point midpoint formula.
Example Values for f (x) are given in table. Use three-point formulas to
approximate f 0 (2).
5
From equations (3) and (4), one gets
Example Values for f (x) = xex are given in table. Use the second
derivative midpoint formula to approximate f 00 (2) and determine bounds for
the approximation error.
6
where 1.8 < ξ < 2.2. Since f (4) (x) = (4 + x)ex
2
(0.2)
|R(2)| = − (4 + ξ)eξ
12
1
≤ (4 + 2.2)e2.2 ≈ 0.1865
12.25
NOTE: The exact value of f 00 (2) is