NA10 04 Notes
NA10 04 Notes
Chapter 4
Numerical Differentiation and Integration
f x0 C h K f x0
From calculus, the derivative of f at x0 was defined as f' x0 = lim . Certainly,
h/0 h
for small enough values of h, the derivative can be approximated by the difference quotient. Thus, our
first attempt at an approximation formula for the derivative of f at x0 is
f x0 C h K f x0 h
f' x0 z C f" x
h 2
where the last term represents the computational truncation error. Although we cannot compute this
error, we can find a bound on it by maximizing the error term on x0 , x0 C h .
If we increase the number of evaluation points, we obtain other numerical differentiation formulas, each
with their own unique error term.
The second order derivative can be derived using Taylor polynomial expansions.
SECOND DERIVATIVE MIDPOINT FORMULA:
1 h2 4
f'' x0 = 2 f x0 K h K 2 f x0 C f x0 C h K f x ; x between x0 K h and x0 C h.
h 12
Not only do we need to be cognizant of the truncation error in each of the above formulas, we must
also be aware of the round-off error that is produced by the computations (as was pointed out in
Chapter 2). Interestingly, as h decreases, truncation error also decreases, but round-off error increases.
So it is important that we find a suitably sized h that will reduce both types of error.
O h O h2 O h4 O h6
h H h =f
1
' x
0
h h h h
H2 =f H h =H C H
1 2 2 1 2 1 2
' x
0 KH h
1
h h h h h h
H4 =f H =H C H H h =H
1 4 2 2 1 4 1 4 3 2 2
' x h h
0 KH H KH h
1 2 2 2 2
C
3
h h h h h h h h
H8 =f H =H C H H =H H h =H
1 8 2 4 1 8 1 8 3 2 2 4 4 3 2
' x h 1 h h
0 KH C H H KH h
1 2 3 2 4 3 2 3
h C
15
KH
2 2
This section opens with the development of two closed quadrature formulas (rules), the Trapezoidal
rule and Simpson's rule. These formulas were derived by integrating the first and second Lagrange
interpolating polynomials respectively using distinct nodes x0 , x1 ,..., xn in the interval [a,b].
When reading the derivation in the text, remember that f xi is a constant and can therefore, be pulled
out of the integral as a coefficient ai .
Since the derivation is developed extensively in the text, we will only provide the rules here and some
additional comments.
n = 1: TRAPEZOIDAL RULE:
b
h h3
f x dx = f x0 C f x1 K f" x where x0 ! x ! x1
2 12
a
n = 2: SIMPSON'S RULE:
b=x
2
h h5 4
f x dx = f x0 C 4 f x1 C f x2 K f x where x0 ! x ! x2
3 90
a=x
0
n = 4:
b=x
4
2h
f x dx = 7 f x0 C 32 f x1 C 12 f x2 C 32 f x3 C 7 f x4
45
a=x
0
8 h7 6
K f x where x0 ! x ! x4
945
To measure the precision of a quadrature method, we simply look for the largest positive integer n such
that the formula is exact for xk, for each k = 0, 1,..., n.
x0 = 1 1 2 2
1 dx = 2 f K Cf = 1 K K1
3 3
K1
=2
x1 1 2 2 2
x dx = 0 f K Cf =K
3 3 3
K1
2
C =0
3
x2 1 2
2 2 2
x2 dx = f K Cf = K
K1
3 3 3
2
2 2 8
C =
3 3 9
Since the last function at which the integral result equals the quadrature result is x1 the precision of this
quadrature method is one.
COMMON OPEN NEWTON-COTES FORMULA: (these do not include the endpoints o [a,b]
as nodes).
n = 0: MIDPOINT RULE:
b=x
1
h3 ''
f x dx = 2 hf x0 C f x , where xK1 ! x ! x1
3
a=x
K1
n = 1:
b=x
2
3h 3 h3 ''
f x dx = f x0 C f x1 C f x , where xK1 ! x ! x2
2 4
a=x
K1
n = 2:
b=x
3
4h 14 h5 4
f x dx = 2 f x0 K f x1 C 2 f x2 C f x , where xK1 ! x ! x3
3 45
a=x
K1
n = 3:
b=x
4
5h 95 h5 4
f x dx = 11 f x0 C f x1 C f x2 C 11 f x3 C f x , where
24 144
a=x
K1
xK1 ! x ! x4
4
As an example, for an approximation to ex dx, the text compares the following:
0
• Simpson's rule on [0,4]
• Simpson's rule on each of the intervals [0,2] and [2,4]
• Simpson's rule on each of the four intervals [0,1], [1,2], [2,3], and [3,4]
What we found was as the number of subintervals increased, the accuracy in our approximation
increased as well. Thus, the procedure was generalized as follows: subdivide the interval [a, b] into n
subintervals, and apply Simpson's rule on each consecutive pair of subintervals. We also found that the
same process could be used with the Trapezoidal rule and the Midpoint rule forming Simpson's
Composite rule, Composite Trapezoidal rule, and the Composite Midpoint rule.
In each case, the error formula for the corrsponding rule can be used to find a bound on the error. An
important property shared by all composite integrations techniques is a stability with respect to round-
off error.
All computations are shown in the example so we will not go into greater detail here.
INFINITE SINGULARITY:
N
1
• Given: dx where p O 1
xp
a
• t = x , dt = KxK2 dx
K1
1
N a
f x 1
• Use the quadrature formula to approximate dx = tK2 f dt
xp t
a 0