Calculus Of One Real Variable – By Pheng Kim Ving Chapter 11: Techniques Of Integration – Section 11.1: Approximate Numerical Integration 11.1 Approximate Numerical Integration

Go To Problems & Solutions

 1. Motivation

Suppose we wish to evaluate the definite integral:

of f. That's why we spent a considerable amount of time in the last several sections investigating the various techniques
of integration.

Now, the fundamental theorem of calculus is of no help for finding the definite integral if we can't find the corresponding
indefinite integral, or if f(x) is unknown and only its values at a finite number of points in [a, b] are determined by
experiment. In this case, we're willing to settle for a numerical approximation or estimate of the exact value of the
definite integral. This is the motivation for the development of the methods of approximate numerical integration.

 2. The Rectangular Rule

Let f be a function continuous on [a, b] and n a positive integer. See Fig. 2.1. Divide [a, b] into n sub-intervals of equal
length. In Fig. 2.1, we take n = 5 as an example. The endpoints of the sub-intervals are x0, x1, x2, ..., xn, where

 Fig. 2.1   The Rectangular Rule.

a = x0 < x1 < x2 < ... < xn = b. The 1st sub-interval is [x0, x1], the 2nd is [x1, x2], ..., the nth is [xn–1, xn]. The ith
sub-interval is [xi–1, xi], for i = 1, 2, ..., n. The length of each sub-interval is (ba)/n. Let ci be the midpoint of the ith
sub-interval [xi–1, xi]. Suppose we know the values of f at those n midpoints. Let yi = f(ci). By Section 9.2 and
Section 9.3 we can take the Riemann sum:

that is:

##### Example 2.1

Let:

a. Calculate the exact value of I using the fundamental theorem of calculus.
b. Calculate an approximate value of I using the rectangular rule with 4 sub-intervals.
c. What's the difference between the exact and approximate values?

Solution

c. The difference between the exact and approximate values is 624.80 – 604.25 = 20.55.

EOS

 3. The Trapezoidal Rule

Let f be continuous on [a, b]. See Fig. 3.1. Again divide [a, b] into n sub-intervals of equal length (ba)/n with
endpoints a = x0 < x1 < x2 < ... < xn = b. In Fig. 3.1 we take an example of n = 5. Suppose we know the values of f at

 Fig. 3.1   The Trapezoidal Rule.

these n + 1 endpoints. Let yi = f(xi), for i = 0, 1, 2, ..., n. Join the two points (x0, y0) and (x1, y1) by a line segment, then
the 2 points (x1, y1) and (x2, y2) by a line segment, and so on. Let g(x) be the equation of the graph formed by all these
line segments. The graph of g(x) is used to approximate the graph of f(x). So the definite integral:

Note that m(x1x0) = y1y0 because y1 = y0 + m(x1x0) because the equation of the line is y = y0 + m(xx0) and
the point (x1, y1) is on that line.

Similarly:

It follows that:

Approximation [3.1] is the trapezoidal rule. The pattern of the coefficients of the yi's is 1, 2, 2, ..., 2, 1.

###### Finding The Endpoints

To apply approximation [3.1] we have to find the yi's for i = 0, 1, 2, ..., n, so we have to find the (n + 1) endpoints xi's of
the sub-intervals. Since the length of each sub-interval is (ba)/n, those endpoints are:

Make sure that xn = b. If that's not the case, something is wrong, so check your calculations, starting from x0.

###### Error Bounds

 Fig. 3.2   Error Bound.

Consider the trapezoidal-rule approximation [3.1]. There's a theorem in a branch of mathematics called numerical
analysis which says that if f is twice differentiable on [a, b], then there exists c in [a, b] such that the error in
approximation [3.1] is ((ba)3/12n2) f ''(c), ie:

That is, an error bound in the approximation is M(ba)3/12n2:

This error bound is inversely proportional to the square of the number of sub-intervals n. As expected, it decreases (thus
the approximate value approaches the exact value) rapidly as n increases.

##### Example 3.1

Let:

a. Estimate the value of I utilizing the trapezoidal rule with 4 sub-intervals.

b. Find an error bound for this estimation. In Example 2.1 the exact value of I is 624.80. Determine the error. Is it within
bound?

Solution
a. The length of each sub-interval is (5 – 1)/4 = 1. The endpoints xi's of the sub-intervals and the values yi's of the
integrand at them are:

The error is 624.80 – 666 = – 41.2. Now |– 41.2| = 41.2 < 100, thus yes the error is within bound.

EOS

 4. Simpson's Rule

In the rectangular rule, we approximate the graph of f by horizontal line segments, ie, linear functions y = k, and each
line segment usually meets the graph of f a 1 point. In the trapezoidal rule, we approximate the graph of f by general line
segments, ie, linear functions y = mx + k, and each line segment usually meets the graph of f at 2 points. We can expect
to do better by approximating the graph of f by parabolic arcs, ie, quadratic functions y = Ax2 + Bx + C. Each parabolic
arc meets the graph of f at 3 points. That's the basis of Simpson's Rule.

First we'll show that given any three points P0(x0, y0), P1(x1, y1), and P2(x2, y2) in the plane such that x0 < x1 < x2 and
x1x0 = x2x1 (x1 is the midpoint of [x0, x2]), there exists a parabola going thru them and we'll calculate the definite
integral of the function represented by that parabola over [x0, x2]. See Fig. 4.1. Let h = x1x0 = x2x1 > 0. For the
sake of simplification, translate the xy coordinate system horizontally x1 units to get the XY coordinate system. In the XY
system, the coordinates of P0 are (– h, y0), those of P1 are (0, y1), and those of P2 are (h, y2). Note that the Y-coordinate
of every point in the plane is the same as its y-coordinate. Let y = AX2 + BX + C, where A, B, and C are constants, be
the equation of a parabola in the XY system. There exists a parabola that goes thru the 3 points P0(– h, y0), P1(0, y1),
and P2(h, y2) iff the system of equations:

So, since the system of equations has a solution, such a parabola does indeed exist.

For the definite integral we have:

This value of the definite integral in the XY system is the same as it is in the xy system. In Fig. 4.1, the area of the
colored region is the same quantity whether the region is considered as being in the XY system or in the xy system.

 Fig. 4.1   Parabolic Arc Thru 3 Points.

 Fig. 4.2

Now let f be continuous on [a, b]. Divide [a, b] into an even  number n of sub-intervals of equal length (ba)/n with
endpoints a = x0 < x1 < x2 < ... < xn = b. Refer to Fig. 4.2, where we take n = 6 as an example. Let yi = f(xi) for i = 0,
1, 2, ..., n. Join the 3 points (x0, y0), (x1, y1), and (x2, y2) by a parabolic arc, then the 3 points (x2, y2), (x3, y3), and (x4,
y4) by a parabolic arc, and so on. The arcs cover successive pairs of consecutive sub-intervals. That's why n must be
even. We approximate the graph of f by the graph formed by these parabolic arcs. Thus, recalling that the length of each
sub-interval is (ba)/n, the approximations of the definite integrals of f over each of these pairs of sub-intervals are:

Thus, adding them up we obtain the approximation of the definite integral of f over [x0, xn] = [a, b]:

##### Finding The Endpoints

Same as Finding The Endpoints in Part 3.

##### Error Bounds

This is similar to Error Bounds in Part 3; refer to it for more details. For Simpson's rule approximation [4.1] there's a
theorem in numerical analysis that assures that if f is 4 times differentiable on [a, b], then there exists c in [a, b] such
that the error in the approximation is:

That is:

This error bound is inversely proportional to the fourth power of the number of sub-intervals n. As expected, it decreases
(thus the approximate value approaches the exact value) very rapidly as n increases (in steps multiple of 2; remember, n
must be even).

Remark that if f (4)(x) = 0 identically on (ie, for all x in) [a, b], then we can take N = 0, thus an error bound is 0, which
means that the approximate value is exactly equal to the exact value. Thus, the Simpson's-rule approximation of any cubic
function f(x) = Ax3 + Bx2 + Cx + D, for which f (4)(x) = 0 for all real number x, using any even  number n of
sub-intervals provides the exact  value of the definite integral. This is surprising, because we approximate a polynomial of
degree 3 by one of degree 2 and using as few as 2 sub-intervals also gives the exact value of the definite integral of the
polynomial of degree 3.

###### Finding An Error Bound

Similar to Finding An Error Bound of Part 3.

##### Example 4.1

Let:

a. Approximate the value of I employing Simpson's rule with 4 sub-intervals.

b. Find an error bound for this approximation. In Example 2.1 the exact value of I is 624.80. Determine the error. Is it
within bound?

Solution

a. The length of each sub-interval is (5 – 1)/4 = 1. The endpoints xi's of the sub-intervals and the values yi's of the
integrand at them are:

Thus yes the error is within bound.
EOS

An error bound is 8/15 = 0.533333.... If we round its decimal representation, eg to 2 decimal places, we must round it up
to 0.54, not down to 0.53, because 0.54 is certain to be a bound while 0.53 isn't, since 0.53 < 0.533333... < 0.54 or
0.53 < 8/15 < 0.54. Similarly, if we round it to 1 decimal place, we must round it up to 0.6, or if we round it to 3 decimal
places, we must round it up to 0.534.

 5. Comparisons Of The Rules

We gather together here all 3 approximation rules for convenient comparison:

rectangular rule, yi = f(ci), ci's are midpoints of sub-intervals:

As for the comparison of accuracy, Examples 3.1 and 4.1 suggest that Simpson's rule generates a much smaller error
bound and thus provides a much more accurate approximation than does the trapezoidal rule. For a given value of n,
error bounds [5.3] and [5.5] show that Simpson's rule generates a much smaller error bound than does the trapezoidal
rule, which means that Simpson's rule gives a much better approximation than does the trapezoidal rule, if | f (4)(x)| isn't
too much bigger than | f ''(x)| (which implies that N isn't too much bigger than M ) and n is sufficiently large. For a
given value of n, we expect the rectangular rule and the trapezoidal rule to provide roughly the same degree of accuracy.
Since Simpson's rule is generally, though not always, better than the other 2 rules and practically requires no more work
than them for any given value of n, it's a recommended choice.

 Problems & Solutions

1. Let:

a. Calculate the exact value of I.
b. Approximate I using the rectangular rule with 5 sub-intervals. Calculate the error in the approximation.
c. Approximate I using the trapezoidal rule with 5 sub-intervals. Find an error bound for the approximation. Calculate
the error. Is it within bound?
d. Approximate I using Simpson's rule with 2 sub-intervals. Find an error bound for the approximation. Calculate the
error. Is it within bound? The approximate value is exactly equal to the exact value because the integrand is a cubic
function.

Solution

Error: 63.75 – 61.875 = 1.875.

The error is 63.75 – 67.5 = –3.75. Now |–3.75| = 3.75 < 10, thus yes the error is within bound.

d. The length of each sub-interval is (4 – (–1))/2 = 5/2. The endpoints xi's of all the sub-intervals and the values yi's of
the integrand at them are:

We have (d4/dx4) x3 = (d3/dx3) (3x2) = (d2/dx2) (6x) = (d/dx) (6) = 0. Hence an error bound is 0. The error is
63.75 – 63.75 = 0. It's within bound.

2. Let:

Estimate I using the following rules with the indicated number n of sub-intervals. Find an error bound in the estimation
in each case.

a. The trapezoidal rule, n = 10.
b. Simpson's rule, n = 4.

Solution

Thus:

b. The left endpoint of the first sub-interval is x0 = 0. The length of each sub-interval is (1 – 0)/4 = 0.25. So the
endpoints xi's of all the sub-intervals and the values yi's of f at them are:

3. A function f is unknown but experiment has determined its following values.

Solution

The best approximation is obtained when the number of all the available sub-intervals of equal length is even and all of
them are used, 8 in this case. So:

4. Prove, by using f(x) = x2 over [0, 1] to create a counter-example, that the constant 12 in the error bound formula for
the trapezoidal-rule approximation can't be improved (increased).

Note

Proof By Counter-Example. To prove that the statement “ the constant 12 in the error bound formula for the
trapezoidal-rule approximation can be improved ” is false, we find an example in which the constant 12 can't be improved.
Such an example is called a counter-example, and a proof using a counter-example is called, well, proof by
counter-example
.

Solution

Hence the size of the exact error is equal to the found error bound, which must therefore be the smallest possible error
bound. This means that the constant 12 can't be increased or improved.

5. Prove, by using f(x) = |x| over [–1, 1] to create a counter-example, that Simpson's rule isn't always better than the
rectangular and trapezoidal rules. (For the definition of a proof by counter-example see note in problem & solution 4.)

Solution

Let:

which isn't equal to the exact value.

So Simpson's rule isn't always better than the rectangular and trapezoidal rules.