Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
5 Numerical Integration*
! Error bounds for certain Left, Right, Trapezoid, and Midpoint Sums
! Simpsons Rule for approximating areas under curves
! Using error bounds to calculate definite integrals to within specified degrees of accuracy
$b
But how can we possibly find this error without knowing the exact value of a f (x) dx in the
first place? It turns out that in specific situations we can get bounds on this error even without
knowing the value of the definite integral. This means that in those situations we will be able
to approximate definite integrals to whatever degree of accuracy we choose.
n
#
k=1
RIGHT(n) =
n
#
k=1
Sometimes these sums are over-approximations of the actual area, and sometimes they
are under-approximations, depending on the behavior of the function f . If f happens to be
368
monotonic on [a, b], in other words either always increasing on [a, b] or always decreasing on
[a, b], we can say more. For example, consider the monotonically decreasing function f below.
For this function, the 4-rectangle Left Sum is an over-approximation and the 4-rectangle Right
Sum is an under-approximation.
Area under f on [a, b]
LEFT(4)
RIGHT(4)
f(a)
f(a)
f(a)
f(b)
f(b)
f(b)
This is true in general; for any number n of rectangles, the area under a monotonically
increasing or decreasing graph will be between the Left Sum and the Right Sum approximations:
Left and Right Sums of Monotonic Functions
Suppose f is integrable on [a, b] and let n be a positive integer.
(a) If f is increasing on [a, b] then LEFT(n)
$b
f (x) dx RIGHT(n).
$b
(b) If f is decreasing on [a, b] then RIGHT(n) a f (x) dx LEFT(n).
a
Proof. We will prove part (b) and leave the entirely similar proof of (a) to Exercise 56. Suppose we partition [a, b] into n rectangles over subintervals of the form [xk1 , xk ]. If f is monotonically decreasing then for each k we know that f (xk1 ) f (x) f (xk ) for all x [xk1 , xk ],
and thus the area under f on [xk1 , xk ] will be less than the area of the kth Left Sum rectangle
and greater than the area of the kth Right Sum rectangle.
The fact that the actual area under a monotonic function is always sandwiched between
the Left Sum and the Right Sum can actually tell us something about the amount of error in
those Riemann sum approximations. The shaded rectangles in the figures below represent
the combined error from the Left Sum and the Right Sum. These errors join up to form a rectangle that can be stacked into a larger rectangle whose area |f (b) f (a)|x is the difference
|LEFT(n) RIGHT(n)|, regardless of the value of n:
Difference between LEFT(4) and RIGHT(4)
f(b) - f(a)
f(b)
f(b)
f(a)
f(b) - f(a)
f(a)
Theorem 4.16
Since the stack of rectangles represents the combined error from the Left and Right Sums,
we know that the error from either of these approximations must itself be less than |f (b)
f (a)|x. This argument holds for any monotonically decreasing function, and we can say
similar things when f is monotonically increasing. Therefore we have proved:
Theorem 4.17
369
n
#
f (xk1 ) + f (xk )
k=1
MID(n) =
n
#
&
%
&
%
&
%
&
%
1
2
+f x1 +x
+ . . . + f xn12+xn ) x.
f xk12+xk x, = (f x0 +x
2
2
k=1
It turns out that we can guarantee that these sums are either over-approximations or
under-approximations depending on whether the function f is concave up or concave down.
For example, consider the concave up function f shown below right. It is immediately obvious that the Trapezoid Sum approximation must be greater than the actual area under the
curve, as shown in the middle figure.
Area under f on [a, b]
TRAP(4)
MID(4)
f(b)
f(b)
f(b)
f(a)
f(a)
f(a)
What is less obvious is that the Midpoint Sum of a concave up function, as shown in the
third picture above, will always be an under-approximation of the true area. For concave
down functions the situation is reversed, with the true area sandwiched between the smaller
Trapezoid Sum and the larger Midpoint Sum, as stated in the following theorem:
Theorem 4.18
$b
f (x) dx TRAP(n).
$b
(b) If f is concave down on [a, b] then TRAP(n) a f (x) dx MID(n).
a
Proof. We will use geometric arguments to prove part (a), and leave the similar proof of
part (b) to Exercise 57. That the Trapezoid Sum is an over-approximation for concave up
370
functions is clear from our earlier middle diagram above. Specifically, upwards concavity
guarantees that the secant line from (xk1 , f (xk1 )) to (xk , f (xk )) will always be completely
above the graph of f on [xk1 , xk ].
That the Midpoint Sum is an under-approximation for concave up functions becomes
clear if we reinterpret each midpoint rectangle as a trapezoid. Given a subinterval [xk1 , xk ],
consider the midpoint trapezoid on the interval to be the trapezoid whose top is formed by
the line tangent to the graph of f at the midpoint of the subinterval. From the figure it is clear
that the midpoint trapezoid will have the same area as the midpoint rectangle whose height
is given by the height of f (x) at the midpoint of the subinterval. Now look at the figure on
the right; since f is concave up, the midpoint tangent line on each subinterval will be below
the graph. Therefore the area of each midpoint trapezoid will be less than the area under the
curve on that subinterval.
Midpoint trapezoid
f(a)
Because the true area of a consistently concave up or down function will always be between the Trapezoid Sum and the Midpoint Sum, we know that the error for either of those
sums is less than the difference in those sums. This is entirely analogous to what we saw in
Theorem 4.17. We can actually get an even better bound if we are able to restrict the behavior
of the second derivative:
Theorem 4.19
If we suppose further that f ## is bounded on [a, b], that is, that there is some positive real
number M such that |f ## (x)| M for all x [a, b], we can say that:
(c) |ETRAP(n) |
M (b a)3
12n2
(d) |EMID(n) |
M (b a)3
24n2
The proof of the second part of this theorem can be found in many numerical analysis texts.
You will explore why these bounds are reasonable in Exercise 18. In Example 2 you will use
these bounds to calculate Trapezoid and Midpoint Sums to specified degrees of accuracy.
371
Simpsons Rule
$b
So far all of our approximations of a definite integral a f (x) dx have utilized piecewiselinear approximations of f . In other words, after subdividing [a, b], we approximated each
piece of f with a line. For example, the Left Sum just represents the area under the graph of
a piecewise-linear step function that agrees with f on the left hand side of each subinterval.
The Trapezoid Sum uses a continuous piecewise-linear function whose pieces are secant lines
of the graph of f , connecting the heights of the function at the subdivision points.
One way to try to get a more accurate approximation of a definite integral is to use a
non-linear approximation instead. For example, we could approximate each piece of f with
a parabola instead of a line. The first graph below shows some function f on [a, b], and the
second graph shows how we could approximate the area under the graph of f with three
paraboloa-topped rectangles. We choose the parabola p(x) on each subinterval to be the
unique parabola that passes through the leftmost height, the midpoint height, and the rightmost height on that subinterval; see the third picture.
Rb
Approximation of a f (x) dx
with paraboloa-topped rectangles
y = f (x) on [a, b]
A closer look at
the first parabola
f(x)
p(x)
x0
x1
x2
x3
x4
x5
x6
x0
x1
x2
The example shown above was specifically chosen so that the parabolas would be easily
distinguishable from the original function. In other words, it does not show a very accurate
approximation! However, in general, approximation by parabolas can be extremely accurate;
imagine using 20 parabolas along the graph of f above, and consider how closely such an
approximation would hug the function.
So how do we calculate a particular parabola-based area approximation? One way would
be to actually find the equations of each little quadratic parabola piece, and then use definite
integral formulas for quadratics to calculate the area under each of these parabola pieces.
Doing this would in practice be quite time-consuming. The following theorem can help make
this process faster; it provides a specific formula for calculating the area under a quadratic
on an interval that uses only the values of the quadratic at the endpoints and the midpoint
of that interval. This nice theorem will allow us to bypass the step of actually finding the
equation of each parabola.
Theorem 4.20
p(x) dx =
BA
6
The proof of this convenient formula is just an application of known definite integral formulas
and a bunch of algebra, and is left to Exercise 60.
It turns out to be convenient to construct our parabolas on pairs of intervals. For example,
in the middle figure on the previous page we divided [a, b] into n = 6 subintervals and then
372
constructed three parabolas to approximate the curve y = f (x). In Exercise 61) you will show
that this process leads to the following summation formula:
Theorem 4.21
Simpsons Rule
Suppose f is integrable on [a, b] and n is a positive even integer. Let x = ba
n and
xk = a + kx.
$b
We can approximate a f (x) dx with n2 parabola-topped rectangles by using the following sum, which is known as Simpsons Rule:
SIMP(n) = (f (x0 ) + 4f (x1 ) + 2f (x2 ) + 4f (x3 ) + + 2f (xn2 ) + 4f (xn1 ) + f (xn )) ( x
3 ).
Intuitively, it makes sense that for most functions f , an approximation using pieces of
parabolas could be more accurate than an approximation of f with pieces of lines. The following theorem backs up this intuition with a bound on the error from Simpsons Rule that is
clearly better than the error bounds we found for Left, Right, Trapezoid, and Midpoint Sums:
Theorem 4.22
M (b a)5
.
180n4
The proof of Theorem 4.22 can be found in many numerical analysis texts, and we will not
concern ourselves with it here.
Notice that all of the error bounds we have discussed have a requirement that either f , or
some derivative of f , is bounded. For the Left and Right Sums we required f to be monotonic,
which implies that f is bounded. This in turn puts some kind of limit on how much the height
function f can change on [a, b]. For the Trapezoid and Midpoint Sums we required f ## to be
bounded, which puts a limit on the curviness of f on [a, b]. Notice that curvier functions will
tend to have less accurate Trapezoid Rule approximations. For Simpsons Rule we required
a bound on the fourth derivative, which also puts some limits on how wild f can be on
[a, b], and therefore limits how much error can arise by using parabolas to approximate the
function on that interval.
373
two decimal places, we will need the error to be less than 0.005.
2
It just so happens that the function f (x) = ex on the interval [0, 1.5] is exactly the function pictured in the first graph of this section. This function is monotonically decreasing on
2
[0, 1.5] because its derivative f # (x) = 2xex is always negative on this interval. Therefore
= 1.5
Theorem 4.17 applies. We have a = 0, b = 1.5, and x = 1.50
n
n , so the magnitude of the
error from using an n-rectangle Right Sum has the following bound:
2
1.3419
n .
We want to find n such that |ERHS(n) | is less than 0.005. To do this we just have to find n such
that the error bound is less than 0.005, so we need to have:
1.3419
n
< 0.005 =
1.3419
0.005
This means that n = 269 is the first positive integer for which the n-rectangle Right Sum will
be within 0.005 of the actual area under the curve.
In case youre interested, the exact value of the definite integral is approximately 0.856188,
and the Right Hand Sum approximation with 269 rectangles is approximately 0.853693; notice
that these values do indeed agree in the first two decimal places.
Example 2
Finding bounds for the error from Trapezoid and Midpoint Sums
Consider the area between the graph of f (x) = x2 2x + 2 and the x-axis on the interval
[0, 3]. Find Trapezoid and Midpoint Sum approximations for this area with n = 4, and
then use Theorem 4.19 to describe bounds on the error in both cases.
Solution. The function f (x) = x2 2x + 2 on [0, 3] just happens to be what we used as our
graphical example when discussing the Trapezoid and Midpoint Sums. We begin by dividing
the interval [0, 3] into n = 4 subintervals of width x = 34 , with subdivision points x0 = 0,
x1 = 34 , x2 = 23 , x3 = 94 , and x4 = 3. Using the equation f (x) = x2 2x + 2, the n = 4 Trapezoid
Sum approximation is
TRAP(4) = (f (0) + 2f ( 43 ) + 2f ( 32 ) + 2f ( 49 ) + f (3))(
( 34 )
)=
2
201
32
6.28125.
To find MID(4), we must first find the midpoints of the 4 subintervals; these midpoints are
21
x1 = 38 , x2 = 89 , x3 = 15
8 , and x4 = 8 . Therefore the n = 4 Midpoint Sum approximation is
21 3
MID(4) = (f ( 83 ) + f ( 98 ) + f ( 15
8 ) + f ( 8 )( 4 ) =
375
64
5.85938.
Now to figure out the accuracy of these approximations. Theorem 4.18 applies because
f # (x) = 2x 2 is positive on all of [0, 3] and thus f is concave up on that entire interval.
Therefore the actual area under f on [0, 3] is greater than MID(4) = 375
64 5.85938 and smaller
than TRAP(4) = 201
6.28125.
In
particular,
by
the
first
part
of
Theorem
4.19 this means that
32
|ETRAP(4) | and |EMID(4) | | 201
32
375
64 |
27
64
0.421875.
This means that we can expect both the n = 4 Trapezoid Sum and the n = 4 Midpoint Sum to
be within about 0.421875 of the exact area under f on [0, 3].
The second part of Theorem 4.19 has the potential to give us a much better error bound
in the sense that we should be confident in our n = 4 approximations to an even greater
degree of accuracy than what is suggested above. Lets see if this is the case in this example.
We first have to get a bound M on the second derivative that is as good as possible. The
374
second derivative of f (x) = x2 2x + 2 is f ## (x) = 2, and thus clearly |f ## (x)| 2 for all values
x [0, 3], so can take M = 2. Note that we are lucky to have an extremely good bound for f ##
in this example, since we know it is constantly 2. We can now say that
|ETRAP(4) |
and
|EMID(4) |
M (b a)3
2(3 0)3
9
=
=
0.28125
12n2
12(42 )
32
M (b a)3
2(3 0)3
9
=
=
0.140625.
2
24n
24(42 )
64
Therefore from the n = 4 Trapezoid Sum approximation, we know that the actual value
$3
9
129
210
of 0 f (x) dx is within 32
of 201
32 , i.e., between 32 4.03125 and 32 6.5625. With the
n = 4 Midpoint Sum we can guarantee even better accuracy, namely that the actual value of
$3
9
366
384
f (x) dx is within 64
of 375
64 , i.e., between 64 5.71875 and 64 = 6.
0
Example 3
x0
x2
x4
By applying Theorem 4.20 to the first double subinterval [x0 , x2 ] we see that
" x2
0
p1 (x) dx = x2 x
(p1 (x0 ) + 4p1 (x1 ) + p1 (x2 )).
6
x0
Similarly, on the second and third double subintervals [x2 , x4 ] and [x4 , x6 ] we have
" x4
2
p1 (x) dx = x4 x
(p1 (x2 ) + 4p1 (x3 ) + p1 (x4 )),
6
x2
" x6
4
p1 (x) dx = x6 x
(p1 (x4 ) + 4p1 (x5 ) + p1 (x6 )).
6
x4
By construction, the values of p1 (x) at x0 , x1 , and x2 are the same as the corresponding values
of f (x). Similarly, the values of p2 (x) and p3 (x) agree with the values of f (x) at the corresponding endpoints and midpoints. Moreover, the width of each double subinterval is 2x,
$b
2
4
0
and thus x2 x
, x4 x
, and x6 x
are all equal to x
6
6
6
3 . Therefore a f (x) dx is approximated
with Simpsons Rule by the sum
x
x
(f (x0 ) + 4f (x1 ) + f (x2 )) x
3 + (f (x2 ) + 4f (x3 ) + f (x4 )) 3 + (f (x4 ) + 4f (x5 ) + f (x6 )) 3 .
After a little algebra it follows that Simpsons Rule indeed says what is predicted by Theorem 4.21:
" b
f (x) dx (f (x0 ) + 4f (x1 ) + 2f (x2 ) + 4f (x3 ) + 2f (x4 ) + 4f (x5 ) + f (x6 )) x
3 .
a
375
Note that if we knew the the function f and the interval [a, b] then we could easily calculate
the sum above.
Exercises 4.5
Thinking Back
Monotonicity and concavity: For each function f and interval [a, b], use derivatives to determine whether or not f is
monotonic on [a, b] and whether or not f has consistent
concavity on [a, b].
! f (x) = x3 2x2 , [a, b] = [1, 3]
! f (x) = x3 2x2 , [a, b] = [0, 1]
! f (x) = sin( 2 x), [a, b] = [1, 1]
Bounding the second derivative:
f (x) = x2 (x 3).
Concepts
0. Problem Zero: Read the section and make your own
summary of the material.
1. True/False: Determine whether each of the following
statements is true or false. If a statement is true, explain why. If a statement is false, provide a counterexample.
(a)
(a)
(c)
377
Trapezoid Sum
Trapezoid Sum
n=4
n=8
n = 16
Right Sum
0.634524
0.662872
0.677766
Left Sum
Trapezoid Sum
0.759524
0.697024
0.725372
0.694122
0.709016
0.693391
Midpoint Sum
0.693147
0.693147
0.693147
Method
10. The error bounds for Right and Left Sums in Theorem 4.17 only apply to monotonic functions. Suppose f is a positive integrable function that is increasing on [a, c] and decreasing on [c, b], with a < c < b.
Rb
How could you make an estimate of a f (x) dx using
a Right or Left Sum and still get an error bound of the
error? Draw a picture to help illustrate your answer.
11. The error bounds for Trapezoid and Midpoint Sums
in Theorem 4.19 only apply to functions with consistent concavity. Suppose f is a positive integrable
function that is concave down on [a, c] and concave
up on [c, b], with a < c < b. How could you make an
Rb
estimate of a f (x) dx using a Trapezoid or Midpoint
Sum and still get an error bound of the error? Draw
a picture to help illustrate your answer.
12. Explain what we mean when we say that the Right
Hand, Left Hand, Trapezoid, and Midpoint Sum apRb
proximations for a f (x) dx involve piecewise-linear
approximations of the function f .
R2
The exact value of 1 x1 dx is ln 2 0.69314718.
Create a table showing the errors corresponding
to each of the twelve approximations. What do
you notice as n increases in each row?
(b) What do you notice about the sign of the errors
of the Right and Left Sums? What about the
signs of the errors of the Trapezoid and Midpoint Sums?
(c) How do the errors of the Right and Left Sums
compare with the errors of the Trapezoid and
Midpoint Sums for each n? How do the errors
from the Trapezoid Sums compare to the errors
from the Midpoint Sums?
(a)
n = 1000
Right Sum
1.09794591
Left Sum
1.09927925
Trapezoid Sum
1.09861258
Midpoint Sum
1.09861214
18. Suppose f is a positive, increasing, concave up function on an interval [a, b], and let c be the midpoint of
the interval. Let A be the point (a, 0), B be the point
(b, 0), C be the point (c, f (c)), D be the point (b, f (b)),
E be the point (a, f (a)), R be the point (b, f (c)), and
S be the point (a, f (c)).
(a)
378
22. In this problem we investigate two cases where
Simpsons Rule happens to approximate a definite integral exactly.
Explain why Simpsons Rule finds the exact
Rb
value of a f (x) dx if f is a quadratic function.
(Hint: Think about Theorem 4.20.)
(b) Explain why Simpsons Rule finds the exact
Rb
value of a f (x) dx if f is a cubic function. (Hint:
Think about the M in the error bound formula in
Theorem 4.22.)
(a)
Skills
Calculate each definite integral approximation in Exercises 2340, and then find an error bound for your approximation.
Z 4
23.
(x2 + x) dx, Right Sum, n = 4
0
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
1
3
1
3
39.
40.
42.
1
dx, Right Sum, within 1 decimal place
x
1
dx, Left Sum, within 1 decimal place
x
43.
44.
45.
46.
47.
48.
49.
50.
51.
1
7
2p
3
1+
x3
1+
x3
4
2
4
2
2
1
1
2p
1
7
1
3
0
2
1
2
52.
379
Applications
53. Moms casserole surprise is hot out of the oven. It
cools at a rate of T ! (t) = 15e0.5t degrees per minute.
The change in temperature T (t) over an interval is
equal to the area under the graph of T ! (t) over that
interval.
(a)
Estimate the change in temperature of the casserole during its first four minutes out of the oven,
using LEFT(4), RIGHT(4), MID(4), TRAP(4),
and SIMP(4).
(b) Give a bound on the errors involved in each approximation.
54. The table below shows the velocity in meters per second of a parachutist at various times. The distance
traveled by the parachutist over an interval of time
is equal to the area under the velocity curve on the
same interval.
t
v(t)
17
23
28
(a)
2.7
4.0
2.7
3.6
4.4
4.3
4.1
3.8
0.3
(a)
Use Simpsons Rule to estimate the total percentage change in GDP from January 1, 1993 to
December 31, 2001.
(b) If the GDP was 6, 880.0 billion dollars on January 1, 1993, what was the GDP on December
31, 2001? Use the best approximating tool available to you.
(c) Estimate a bound for the fourth derivative of r
over the time period from 1993 to 2001, and use
that information to determine an error bound
for your estimate of the total change in r.
Proofs
56. Prove part (a) of Theorem 4.16: If f is integrable
and monotonically increasing on [a, b], then for any
Rb
positive integer n we have LEFT(n) a f (x) dx
RIGHT(n).
57. Use geometric arguments to support part (b) of Theorem 4.18: If f is integrable and concave down on
[a, b], and n is any positive integer, then TRAP(n)
Rb
f (x) dx MID(n).
a
58. Prove that the Trapezoid Sum is equivalent to the average of the Left and Right Sums:
TRAP(n) =
LEFT(n) + RIGHT(n)
.
2
59. Prove that Simpsons Rule is equivalent to the following weighted average of the Trapezoid and Midpoint
Sums:
SIMP(2n) = 31 TRAP(n) + 23 MID(n).
p(x) dx =
BA
A+B
(p(A) + 4p(
) + p(B)).
6
2
(a)
380
Thinking Forward
Finding exact error: In the next chapter we will see that definite integrals can be computed by taking differences of
antiderivatives; in particular the Fundamental Theorem of
Calculus will reveal that if f is continuous on [a, b] then
Rb
f (x) dx = F (b) F (a), where F is any antiderivative
a
of f . Armed with this fact, we can check the exact error
of Riemann sum approximations for integrals of functions
that we can antidifferentiate.
! Use the antiderivative
fact above to find the exact
R4
value of 1 x1 dx. (Hint: What is an antiderivative of
1
? In other words, what is a function F whose derivative
x
is f (x) = x1 ?)
Appendix A
Answers To Odd Problems
6
4
2
1
2
4
6
17. approximately 3
19. Draw any graph where the average height
of the graph on [2, 5] is 10, and the slope
from (2, f (2)) to (5, f (5)) on your graph
is 3.
21. See the reading.
23. f is continuous on [1, 5], so the Mean
Value Theorem for Integrals applies and
says that there is some c (1, 5) for which
f (c) = c(c 6) is equal to the average value
R5
1
x(x 6) dx of the function f . You
51 1
can compute this average value; it is equal
to 23
. Therefore, there is some c (1, 5)
3
such that f (c) = 23
. We can solve the
3
to find such a value
equation f (c) = 23
3
of c. Actually there are two such values:
c 1.8453 and c 4.1547.
25. Using a Left Sum with n = 10, we have
43.333.
27. Using a Left Sum with n = 8, we have (a)
11.1973; (b) 12.2229.
29. (a) 52 ; (b) 13
2
31. (a) 43 ; (b) 109
12
33. (a) 25
;
(b)
25.2
2
35. Using a Left Sum with n = 8, we have 22.
37. 13
2
39. 38
6
41. 15
43. (f (1) + f (0.75) + f (0.5) + f (0.25) +
f (0) + f (0.25) + f (0.5) + f (0.75))( 18 )
0.990978
45. One possible approximation is (f ( 4 ) +
f ( 2 ) + + f (2))( 4 ) = 0
47. 7
49. 4
51. 1
53. c = 1
55. c = 13 ln(ln 2)
2 4
57. c = 2
1(71)3
24(12)2
= 0.0625.
Chapter 5
Section 5.1
1. T, F, F, T, F, F, F, F.
3. An antiderivative of f is just one function
whose derivative
is f , while the indefinite
R
integral f (x) dx is the family of all antiderivatives of f .
5. See Definitions 4.8 and 5.1. The definite integral is a number while the indefinite integral is a family of functions; the definite
integral concerns area while the indefinite
integral concerns antiderivatives; we calculate definite integrals using Riemann sums,
but we calculate indefinite integrals by antidifferentiating.