Two additional methods of integration by numerical approximations, which we shall describe in this section, are the Midpoint Rule and Simpson's Rule.
In the Midpoint Rule the approximation to the integral [math]\int_a^b f[/math] is a Riemann sum [math]\sum_{i=1}^{n} f(x_i^*)(x_i - x_{i-1})[/math] in which each [math]x_i^*[/math] is taken to be the midpoint of the subinterval [math][x_{i-1}, x_i][/math]. In more detail: Let [math]f[/math] be a function which is integrable over [math][a, b][/math]. For every positive integer [math]n[/math], let [math]h = \frac{b - a}{n}[/math], and let [math]\sigma_n = \{ x_0, . . ., x_n \}[/math] be the partition defined by
[[math]]
x_i = a + ih, \;\;\; i = 0, ... , n.
[[/math]]
As a result, it follows that
[[math]]
x_i - x_{i-1} = h, \;\;\; i = 1, ... , n.
[[/math]]
If we take [math]x_i^*[/math] to be the midpoint of the subinterval [math][x_{i-1}, x_i][/math], then
[[math]]
x_i^* = \frac{x_{i-1} + x_i}{2}, \;\;\; i = 1, ... , n.
[[/math]]
The Riemann sum used as the approximation to the integral in the Midpoint Rule will be denoted by [math]M_n[/math]. It is given by
[[math]]
M_n = \sum_{i=1}^n f(x_i^*)(x_i - x_{i-1}) = h \sum_{i=1}^n f \Bigl(\frac{x_{i-1}+ x_i}{2} \Bigr) .
[[/math]]
In studying the Trapezoid Rule, we found it convenient to use the abbreviation [math]y_i = f(x_i)[/math], for [math]i = 0, ... , n.[/math] By analogy, we shall here let
[[math]]
y_{i-1/2} = f \Bigl( \frac{x_{i-1} + x_i}{2} \Bigr), \;\;\; i = 1, ... , n .
[[/math]]
Then
[[math]]
M_n = h \sum_{i=1}^n y_{i-1/2} = h (y_{1/2} + y_{3/2} + \cdots + y_{n-1/2}),
[[/math]]
and we express the Midpoint Rule for numerical integration by the formula
Theorem
[[math]]
\int_a^b f \approx M_n = h (y_{1/2} + y_{3/2} + \cdots + y_{n-1/2}) .
[[/math]]
If [math]f(x) \geq 0[/math] for every [math]x[/math] in [math][a, b][/math], the Midpoint Rule approximates the integral [math]\int_a^b f[/math], which is the area under the curve, by a sum of areas of rectangles, as illustrated in Figure 6.
An alternative to approximating the integral by a Riemann sum is to use straight-line segments which are tangent to the curve [math]y = f(x)[/math] at the midpoints of the subintervals. An example is shown in Figure 7, in which
[math]\int_a^b f[/math] is approximated by the sum of the areas of the three shaded trapezoids. This method yields the so-called Tangent Formula. It turns out, however, that the Tangent Formula is the same as the Midpoint Rule. The reason can be seen by looking at Figure 8, in which the area of the shaded trapezoid with one side tangent to the curve is the ith term in the approximating sum used in the Tangent Formula. The area of this trapezoid is equal to [math]\frac{h}{2} (y' + y'')[/math], where [math]y'[/math] and [math]y''[/math] are the lengths of the bases. However, by elementary geometry the trapezoid can be seen to have the same area as the rectangle with base [math][x_{i-1}, x_i][/math] and altitude [math]y_{i-1/2}[/math] The area of the rectangle is [math]h \cdot y_{i-1/2}[/math], and so
[[math]]
\frac{h}{2} (y' + y'') = h \cdot y_{i-1/2}.
[[/math]]
(Incidentally, note that this equation is true regardless of whether [math]y'[/math], [math]y''[/math], and [math]y_{i-1/2}[/math] are positive, negative, or zero.) Since the product [math]h \cdot y_{i-1/2}[/math] is the ith term in the midpoint approximation [math]M_n[/math], we conclude that the Tangent Formula and the Midpoint Rule, although differently motivated, are in fact the same.
Example
Approximate [math]\int_{-1}^1 (x^2 + x^3) dx[/math] using the Midpoint Rule. This is the same integral which we evaluated in Section 2 by the Trapezoid Rule. To compare the two methods, we shall again take [math]n = 8[/math] and
[[math]]
h = \frac{1- (-1)}{8} = \frac{1}{4}.
[[/math]]
Since, for an arbitrary interval [math][a, b][/math], we have
[[math]]
x_i = a + ih, \;\;\; i = 0, ... ,n,
[[/math]]
it follows that
[[math]]
\begin{eqnarray*}
x_i^{*} &=& \frac{x_{i-1} + x_i}{2} = \frac{[a + (i - 1)h] + (a + ih)}{2}\\
&=& a + (i - \frac{1}{2})h
\end{eqnarray*}
[[/math]]
In addition, since [math]y_{i-1/2} = f(x_i^{*})[/math], we have a pair of useful formulas:
[[math]]
\begin{array}{rl}
x_i^{*} &= a + (i - \frac{1}{2})h \\
y_{i-1/2} &= f(a + (i - \frac{1}{2})h)
\end{array}
\} i = 1, ... , n.
[[/math]]
In the present example, [math]a = -1[/math], [math]h = \frac{1}{4}[/math], and [math]f(x) = x^2 + x^3[/math]. Hence
as an approximation to the integral [math]\int_{-1}^1 (x^2 + x^3) dx[/math]. The value obtained earlier with the Trapezoid Rule was [math]T_8 = \frac{11}{16}[/math]. Since the true value is given by
This is one half the error obtained using the Trapezoid Rule with the same value of [math]h[/math].
In any application of the Midpoint Rule, the error [math]| \int_a^b f - M_n |[/math] can be made arbitrarily small by taking [math]n[/math] sufficiently large. That is, we assert that
Theorem
[[math]]
\lim_{n \rightarrow \infty} M_n = \int_a^b f .
[[/math]]
This theorem is easier to prove than the corresponding one for the Trapezoid Rule because every approximation [math]M_n[/math] is, as it stands, a Riemann sum of [math]f[/math] relative to the partition [math]\sigma_n[/math] of [math][a, b][/math]. Since [math]|| \sigma_n || \rightarrow 0[/math] as [math]n \rightarrow \infty[/math], it is a direct corollary of the fundamental theorem on the limit of Riemann sums [(2.1), page 414] that [math]\lim_{n \rightarrow \infty} M_n = \int_a^b f[/math].
A means of estimating the error [math]| \int_a^b f - M_n |[/math] in a particular application of the Midpoint Rule is provided by the following theorem:
Theorem
If the second derivative [math]f''[/math] is continuous at every point of [math][a, b][/math], then there exists a number [math]c[/math] such that [math]a \lt c \lt b[/math] and
As with the analogous theorem for the Trapezoid Rule [(2.4), page 419], this theorem can be proved by first reducing it to the case [math]n = 1[/math]. A discussion of the error term can be found in [math]R[/math]. Courant and F. John, Introduction to Calculus and Analysis, Volume I, Interscience Publishers (Wiley), 1965, pages 486 and 487.
Theorem (3.3) can be used to obtain an upper bound on the error [math]|\int_a^b f - M_n|[/math] provided the second derivative [math]f''[/math] is bounded on the interval [math][a, b][/math]. That is, if there exists a real number [math]K[/math] such that
[[math]]
| f''(x) | \leq K, \;\;\; \mbox{for every $x$ in \ltmath\gt[a, b][[/math]]
,}
</math>
then, in particular [math]|f''(c)| \leq K[/math], and so
For the one integral we computed by both methods, the Midpoint Rule gave a better approximation than the Trapezoid Rule by a factor of 2. Comparison of Theorem (3.3) with (2.4) shows that in general this ratio can be expected.
Geometrically, the different methods of numerical integration described thus far in this and the preceding section are all based on approximating the area under a curve by a sum of areas of rectangles or trapezoids. Analytically, in each method the approximation to [math]\int_a^b f[/math] has been obtained by replacing [math]f[/math] over every subinterval by a linear function. In Simpson's Rule, however, we shall replace [math]f[/math] over each subinterval by a quadratic polynomial [math]Ax^2 + Bx + C[/math]. The corresponding area problem is the simple one of finding the area under a parabola (or a straight line, if [math]A = 0[/math]). For most integrals, Simpson's Rule gives much greater accuracy for the same value of [math]h[/math].
Let [math]f[/math] be a function which is integrable over the interval [math][a, b][/math]. The procedure differs from the others in that we consider only partitions of [math][a, b][/math] into an even number of subintervals. Thus for an arbitrary even integer [math]n \gt 0[/math], we set [math]h = \frac{b - a}{n}[/math], and let
[[math]]
\begin{eqnarray*}
x_i &=& a + ih,\\
y_i &=& f (x_i), \;\;\; \mbox{for}\; i = 0, . . ., n.
\end{eqnarray*}
[[/math]]
Since [math]n[/math] is even, there is an integral number of “double” intervals [math][x_{2i-2}, x_{2i}], i = 1, ... , \frac{n}{2}[/math] as illustrated in Figure 9, and
There exists one and only one polynomial [math]q_i(x) = A_i x^2 + B_i x + C_i[/math] of degree less than three whose graph passes through the three points [math](x_{2i-2}, y_{2i-2}), (x_{2i-1}, y_{2i-1})[/math], and [math](x_{2i}, y_{2i})[/math] (see Figure 10). Over each double interval [math][x_{2i-2}, x_{2i}][/math] we shall approximate the integral of [math]f[/math] by the integral of [math]q_i[/math]. Let us assume for the moment, and later prove, the fact that
The sum of these integrals, which we shall denote [math]S_n[/math], is the approximation to [math]\int_a^b f[/math] prescribed by Simpson's Rule. Hence
If this sum is expanded, note the pattern of the coefficient of the [math]y_i[/math]'s: If [math]i[/math] is odd, the coefficient of [math]y_i[/math] is 4. If [math]i[/math] is even, the coefficient is 2, with the exception of [math]y_0[/math] and [math]y_n[/math], each of which has coefficient 1. Thus Simpson's Rule is expressed in the formula
We now prove equation (1). The algebra is significantly simpler if we write [math]q_{i}(x)[/math] in terms of [math]x - x_{2i-1}[/math] instead of [math]x[/math] (see Figure 10). Hence we let
The integral [math]\int_{x_{2i-2}}^{x_{2i}} q_i (x) dx[/math] may be computed by substituting [math]u = x - x_{2i-1}[/math] and using the Change of Variable Theorem for Definite Integrals (see page 215). Since [math]x_{2i-2} - x_{2i-1} = - h[/math] and [math]x_{2i} - x_{2i-1} = h[/math], the result is
Substituting this result in (3) yields the desired result (1), and the derivation of Simpson's Rule is complete.
Example
Using [math]n = 4[/math], find an approximate value of [math]\int_0^1 \frac{1}{1+ x^2} dx[/math] by Simpson's Rule. We have [math]h = \frac{1 - 0}{4} = \frac{1}{4}[/math],
Hence the error [math]|\int_a^b f - S_4|[/math] is approximately 0.000006.
Just as with the other two methods of integration by numerical approximation, the error [math]| \int_a^b f - S_n |[/math] can be made arbitrarily small by taking [math]n[/math] aufficiently large. That is, we have the following theorem, which we state without proof.
Theorem
[[math]]
\lim_{n \rightarrow \infty} S_n = \int_a^b f .
[[/math]]
In addition, the next theorem can be used to estimate the error in a particular application of Simpson's Rule.
Theorem
If the fourth derivative [math]f^{(4)}[/math] is continuous at every point of [math][a, b][/math], then there exists a number [math]c[/math] such that [math]a \lt c \lt b[/math] and
For an outline of a proof, see J. M. H. Olmsted, Advanced Calculus, Appleton-Century-Crofts, 1961, page 119.
The fourth derivative of every cubic polynomial is identically zero, for if
then [math]f^{(4)} (x) = 0[/math]. It is therefore a rather surprising corollary of Theorem(3.6) that Simpson's Rule will always give the exact value of the integral when applied to any polynomial of degree less than 4.