Professional Documents
Culture Documents
function f(x) over an interval [a, b] may be viewed as an estimate of ∫ f(x) dx . Recall that a Riemann sum of a function f(x) over an interval [a, b]
a
and a set
∗ ∗ ∗ ∗
S = {x , x , … , xn }, where xi−1 ≤ x ≤ xi for all i.
1 2 i
The Riemann sum corresponding to the partition P and the set S is given by n ∑ f(x ∗
i
)Δxi , where Δx i = xi − xi−1 , the length of the i th
subinterval.
i=1
The midpoint rule for estimating a definite integral uses a Riemann sum with subintervals of equal width and the midpoints, mi , of each subinterval in
place of x . Formally, we state a theorem regarding the convergence of the midpoint rule as follows.
∗
i
i=1
As we can see in Figure, if f(x) ≥ 0 over [a, b] , then ∑ f(mi )Δx corresponds to the sum of the areas of rectangles approximating the area between
i=1
the graph of f(x) and the x -axis over [a, b] . The graph shows the rectangles corresponding to M4 for a nonnegative function over a closed interval
[a, b].
Figure 2.5.1 : The midpoint rule approximates the area between the graph of f (x) and the x -axis by summing the areas of rectangles with midpoints that are points on f (x).
1−0 1
Solution: Each subinterval has length Δx = = . Therefore, the subintervals consist of
4 4
1 1 1 1 3 3
[0, ], [ , ], [ , ] , and [ , 1] .
4 4 2 2 4 4
8
,
3
8
,
5
8
,
7
8
}. Thus,
1 1 1 3 1 5 1 7 1 1 1 9 1 25 1 21 21
M4 = ⋅ f( ) + ⋅ f( ) + ⋅ f( ) + ⋅ f( ) = ⋅ + ⋅ + ⋅ + ⋅ = .
4 8 4 8 4 8 4 8 4 64 4 64 4 64 4 64 64
Since
1
2
1
∫ x dx = ,
0
3
∣1 21 ∣ 1
the error in this approximation is: ∣ − ∣ = ≈ 0.0052,
∣3 64 ∣ 192
2
x
2
on [1, 4] .
Solution: The length of y = 1
2
x
2
on [1, 4] is
−−−−−−−−−
4 2
dy
s = ∫ √1 + ( ) dx.
1
dx
4
dy −−−− −
Since = x , this integral becomes ∫ 2
√1 + x dx.
dx 1
4−1 1
If [1, 4] is divided into six subintervals, then each subinterval has length Δx = = and the midpoints of the subintervals are
6 2
−−−−−
. If we set f(x) = √1 + x ,
5 7 9 11 13 15
2
{ , , , , , }
4 4 4 4 4 4
1 5 1 7 1 9 1 11 1 13 1 15
M6 = ⋅ f( ) + ⋅ f( ) + ⋅ f( ) + ⋅ f( ) + ⋅ f( ) + ⋅ f( )
2 4 2 4 2 4 2 4 2 4 2 4
≈
1
2
(1.6008 + 2.0156 + 2.4622 + 2.9262 + 3.4004 + 3.8810) = 8.1431 units.
Exercise 2.5.1
2
1
Use the midpoint rule with n = 2 to estimate ∫ dx.
1
x
Hint
1 5 7
Δx = , m1 = , and m2 = .
2 4 4
Answer
24
35
Figure 2.5.2 : Trapezoids may be used to approximate the area under a curve, hence approximating the definite integral.
The trapezoidal rule for estimating definite integrals uses trapezoids rather than rectangles to approximate the area under a curve. To gain insight into
the final form of the rule, consider the trapezoids shown in Figure 2.5.2. We assume that the length of each subinterval is given by Δx . First, recall that
the area of a trapezoid with a height of h and bases of length b and b is given by Area = h(b + b ) . We see that the first trapezoid has a height Δx 1 2
1
2
1 2
and parallel bases of length f(x ) and f(x ). Thus, the area of the first trapezoid in Figure 2.5.2 is
0 1
1
Δx(f(x0 ) + f(x1 )).
2
Consequently,
b
1 1 1 1
∫ f(x) dx ≈ Δx(f(x0 ) + f(x1 )) + Δx(f(x1 ) + f(x2 )) + Δx(f(x2 ) + f(x3 )) + Δx(f(x3 ) + f(x4 )).
a
2 2 2 2
2
Δx and combining like terms, we have
b
Δx
∫ f(x) dx ≈ (f(x0 ) + 2 f(x1 ) + 2 f(x2 ) + 2 f(x3 ) + f(x4 )).
a
2
Set
Δx
Tn = (f(x0 ) + 2 f(x1 ) + 2 f(x2 ) + ⋯ + 2 f(xn−1 ) + f(xn )). (2.5.2)
2
Before continuing, let’s make a few observations about the trapezoidal rule. First of all, it is useful to note that
n n
1
Tn = (Ln + Rn ) where L n = ∑ f(xi−1 )Δx and R n = ∑ f(xi )Δx.
2
i=1 i=1
That is, L and R approximate the integral using the left-hand and right-hand endpoints of each subinterval, respectively. In addition, a careful
n n
examination of Figure 2.5.3 leads us to make the following observations about using the trapezoidal rules and midpoint rules to estimate the definite
integral of a nonnegative function. The trapezoidal rule tends to overestimate the value of a definite integral systematically over intervals where the
function is concave up and to underestimate the value of a definite integral systematically over intervals where the function is concave down. On the
other hand, the midpoint rule tends to average out these errors somewhat by partially overestimating and partially underestimating the value of the
definite integral over these same types of intervals. This leads us to hypothesize that, in general, the midpoint rule tends to be more accurate than the
trapezoidal rule.
Figure 2.5.3 :The trapezoidal rule tends to be less accurate than the midpoint rule.
Solution
The endpoints of the subintervals consist of elements of the set P and Δx = Thus,
1 1 3 1−0 1
= {0, , , , 1} = .
4 2 4 4 4
1
2
1 1 1 1 3
∫ x dx ≈ ⋅ (f(0) + 2 f ( ) +2f( ) +2f( ) + f(1))
4 2 4
0
2 4
1 1 1 9
= (0 + 2 ⋅ +2⋅ +2⋅ + 1)
8 16 4 16
11
=
32
Exercise 2.5.2
2
1
Use the trapezoidal rule with n = 2 to estimate ∫ dx.
1
x
Hint
1
Set Δx = . The endpoints of the subintervals are the elements of the set P = {1,
3
2
, 2} .
2
Answer
17
24
1
1
Solution: The calculated value is ∫
2
x dx = and our estimate from the example is M4 =
21
64
. Thus, the absolute error is given by
0
3
1 21 1
∣ − ∣ = ≈ 0.0052.
∣ 3 64
∣ 192
1
1
Solution: The calculated value is ∫ x
2
dx = and our estimate from the example is T4 =
11
32
. Thus, the absolute error is given by
0
3
1 11 1
∣ − ∣ = ≈ 0.0104.
∣ 3 32
∣ 96
Exercise 2.5.3
2
1
In an earlier checkpoint, we estimated ∫ dx to be 24
35
using T . The actual value of this integral is ln 2 . Using
2
24
35
≈ 0.6857 and ln 2 ≈ 0.6931,
1
x
Hint
Use the previous examples as a guide.
Answer
absolute error ≈ 0.0074, and relative error ≈ 1.1%
then the upper bounds for the error in using M and T to estimate ∫
n n f(x) dx are
a
3
M (b − a)
Error in Mn ≤ (2.5.4)
2
24n
and
3
M (b − a)
Error in Tn ≤ (2.5.5)
2
12n
We can use these bounds to determine the value of n necessary to guarantee that the error in an estimate is less than a specified value.
Solution
2 2
Thus,
2
′′ x 2
|f (x)| = 2e (1 + 2x ) ≤ 2 ⋅ e ⋅ 3 = 6e.
−
−−−
Thus, n ≥ √ 600e
24
≈ 8.24. Since n must be an integer satisfying this inequality, a choice of n = 9 would guarantee that
1
∣ 2
∣
x
∣∫ e dx − Mn ∣ < 0.01.
∣ 0 ∣
Analysis
We might have been tempted to round 8.24 down and choose n = 8 , but this would be incorrect because we must have an integer greater than or
equal to 8.24. We need to keep in mind that the error estimates provide an upper bound only for the error. The actual estimate may, in fact, be a much
better approximation than is indicated by the error bound.
Exercise 2.5.4
1
Use Equation to find an upper bound for the error in using M to estimate ∫ 4
2
x dx.
0
Hint
f
′′
(x) = 2, so M = 2.
Answer
1
192
Simpson’s Rule
With the midpoint rule, we estimated areas of regions under curves by using rectangles. In a sense, we approximated the curve with piecewise constant
functions. With the trapezoidal rule, we approximated the curve by using piecewise linear functions. What if we were, instead, to approximate a curve
using piecewise quadratic functions? With Simpson’s rule, we do just this. We partition the interval into an even number of subintervals, each of equal
x2 x2
width. Over the first pair of subintervals we approximate ∫ f(x) dx with ∫ p(x) dx , where p(x) = Ax
2
+ Bx + C is the quadratic function
x0 x0
x4
passing through (x0 , f(x0 )), (x1 , f(x1 )), and (x2 , f(x2 )) (Figure 2.5.4 ). Over the next pair of subintervals we approximate ∫ f(x) dx with the
x2
Figure 2.5.4 : With Simpson’s rule, we approximate a definite integral by integrating a piecewise quadratic function.
To understand the formula that we obtain for Simpson’s rule, we begin by deriving a formula for this approximation over the first two subintervals. As we
go through the derivation, we need to keep in mind the following relationships:
2
f(x1 ) = p(x1 ) = Ax + B x1 + C (2.5.7)
1
2
f(x2 ) = p(x2 ) = Ax + B x2 + C (2.5.8)
2
Thus,
x2 x2
∫ f(x) dx ≈ ∫ p(x) dx
x0 x0
x2
2
= ∫ (Ax + Bx + C )dx
x0
x2
A 3
B 2 ∣
= ( x + x + C x) ∣ Find the antiderivative.
3 2 ∣x
0
A B
3 3 2 2
= (x −x )+ (x − x ) + C (x2 − x0 ) Evaluate the antiderivative.
2 0 2 0
3 2
A B
2 2
= (x2 − x0 )(x + x2 x0 + x ) + (x2 − x0 )(x2 + x0 ) + C (x2 − x0 )
2 0
3 2
x2 − x0 x2 − x0
2 2
= (2A(x + x2 x0 + x ) + 3B(x2 + x0 ) + 6C ) Factor out .
2 0
6 6
Δx
2 2 2 2
= ((Ax + B x2 + C ) + (Ax + B x0 + C ) + A(x + 2x2 x0 + x ) + 2B(x2 + x0 ) + 4C ) Rearrange the terms. Note: Δx
2 0 2 0
3
Δx 2
= (f(x2 ) + f(x0 ) + A(x2 + x0 ) + 2B(x2 + x0 ) + 4C ) Factor and substitute:
3
2
f(x2 ) = Ax + B x2 + C and
2
Δx
2
= (f(x2 ) + f(x0 ) + A(2x1 ) + 2B(2x1 ) + 4C ) Substitute x2 + x0 = 2x1 .
3
x2 + x0
Note: x1 = , the mid
2
Δx
= (f(x2 ) + 4f(x1 ) + f(x0 )). Expand and substitute f(x1 ) =
3
x4
4
x
Δx
∫ f(x) dx ≈ (f(x4 ) + 4 f(x3 ) + f(x2 )).
x0
3
The pattern continues as we add pairs of subintervals to our approximation. The general rule may be stated as follows.
Simpson’s Rule
b−a
Assume that f(x) is continuous over [a, b] . Let n be a positive even integer and Δx = . Let [a, b] be divided into n subintervals, each of
n
Then,
b
Just as the trapezoidal rule is the average of the left-hand and right-hand rules for estimating definite integrals, Simpson’s rule may be obtained from the
2 1
midpoint and trapezoidal rules by using a weighted average. It can be shown that S 2n
= ( )Mn + ( )Tn .
3 3
[a, b] , then the upper bound for the error in using S to estimate ∫ n
f(x) dx is given by
a
5
M (b − a)
Error in Sn ≤ . (2.5.10)
4
180n
Use S to approximate ∫
2
3
x dx . Estimate a bound for the error in § . 2
Solution
Since [0, 1] is divided into two intervals, each subinterval has length . The endpoints of these subintervals are . If we set
1−0 1 1
Δx = = {0, , 1}
2 2 2
f(x) = x , then
3
1 1 1 1 1 1
S4 = ⋅ (f(0) + 4 f( ) + f(1)) = (0 + 4 ⋅ + 1) = .
3 2 2 6 8 4
Since f (4)
(x) = 0 and consequently M = 0, we see that
5
0(1)
Error in S 2
≤
4
= 0.
180⋅2
1
1
This bound indicates that the value obtained through Simpson’s rule is exact. A quick check will verify that, in fact, ∫ 3
x dx = .
0
4
2
x
2
over [1, 4].
Solution
4
−−−− −
The length of y =
1
2
x
2
over [1, 4] is ∫
2
√1 + x dx . If we divide [1, 4] into six subintervals, then each subinterval has length Δx =
4−1
6
=
1
2
,
1
−−−− −
and the endpoints of the subintervals are {1, 3
2
, 2,
5
2
, 3,
7
2
, 4} . Setting f(x) = √1 + x
2
,
1 1 3 5 7
S6 = ⋅ (f(1) + 4f( ) + 2f(2) + 4f( ) + 2f(3) + 4f( ) + f(4)).
3 2 2 2 2
Exercise 2.5.5
2
1
Use S to estimate ∫
2 dx.
1
x
Hint
1
S2 = ( Δx(f(x0 ) + 4f(x1 ) + f(x2 )) (2.5.12)
3
Answer
25
36
Key Concepts
We can use numerical integration to estimate the values of definite integrals when a closed form of the integral is difficult to find or when an
approximate value only of the definite integral is needed.
The most commonly used techniques for numerical integration are the midpoint rule, trapezoidal rule, and Simpson’s rule.
The midpoint rule approximates the definite integral using rectangular regions whereas the trapezoidal rule approximates the definite integral
using trapezoidal approximations.
Simpson’s rule approximates the definite integral by first approximating the original function using piecewise quadratic functions.
Key Equations
Mn = ∑ f(mi )Δx
i=1
Trapezoidal rule
Δx
Tn = (f(x0 ) + 2 f(x1 ) + 2 f(x2 ) + ⋯ + 2 f(xn−1 ) + f(xn ))
2
Simpson’s rule
Δx
Sn = (f(x0 ) + 4 f(x1 ) + 2 f(x2 ) + 4 f(x3 ) + 2 f(x4 ) + 4 f(x5 ) + ⋯ + 2 f(xn−2 ) + 4 f(xn−1 ) + f(xn ))
3
Glossary
absolute error
if B is an estimate of some quantity having an actual value of A, then the absolute error is given by |A − B|
midpoint rule
n b
numerical integration
the variety of numerical methods used to estimate the value of a definite integral, including the midpoint rule, trapezoidal rule, and Simpson’s rule
relative error
error as a percentage of the actual value, given by
A−B
relative error =∣ ∣ ⋅100%
A
Simpson’s rule
b
a rule that approximates ∫ f(x) dx using the area under a piecewise quadratic function.
a
b
Δx
Sn = (f(x0 ) + 4 f(x1 ) + 2 f(x2 ) + 4 f(x3 ) + 2 f(x4 ) + ⋯ + 2 f(xn−2 ) + 4 f(xn−1 ) + f(xn )).
3
trapezoidal rule
b
The approximation T to ∫ n
f(x) dx is given by
a
Δx
Tn = (f(x0 ) + 2 f(x1 ) + 2 f(x2 ) + ⋯ + 2 f(xn−1 ) + f(xn )).
2
Contributors
Gilbert Strang (MIT) and Edwin “Jed” Herman (Harvey Mudd) with many contributing authors. This content by OpenStax is licensed with a CC-BY-
SA-NC 4.0 license. Download for free at http://cnx.org.
Edited by Paul Seeburger (Monroe Community College). Notes added to development of area under a parabola and typos fixed in original text.