maths.free › Calculus › 3. Techniques of Integration › Numerical Integration
Numerical Integration
Approximate the value of a definite integral by using the midpoint and trapezoidal rules.
The Midpoint Rule
Earlier in this text we defined the definite integral of a function over an interval as the limit of Riemann sums. In general, any Riemann sum of a function \(f(x)\) over an interval \([a,b]\) may be viewed as an estimate of \({\int }_{a}^{b}f(x)dx.\) Recall that a Riemann sum of a function \(f(x)\) over an interval \([a,b]\) is obtained by selecting a partition
\[P=\{{x}_{0},{x}_{1},{x}_{2}\text{,\ldots },{x}_{n}\},\ \text{where}\ a={x}_{0}<{x}_{1}<{x}_{2}<\cdots <{x}_{n}=b\]and a set
\[S=\{{x}_{1}^{*},{x}_{2}^{*}\text{,\ldots },{x}_{n}^{*}\},\ \text{where}\ {x}_{i-1}\le {x}_{i}^{*}\le {x}_{i}\ \text{for all}\ i.\]The Riemann sum corresponding to the partition \(P\) and the set \(S\) is given by \(\sum _{i=1}^{n}f({x}_{i}^{*})\text{\Delta }{x}_{i},\) where \(\text{\Delta }{x}_{i}={x}_{i}-{x}_{i-1},\) the length of the ith subinterval.
The midpoint rule for estimating a definite integral uses a Riemann sum with subintervals of equal width and the midpoints, \({m}_{i},\) of each subinterval in place of \({x}_{i}^{*}.\) Formally, we state a theorem regarding the convergence of the midpoint rule as follows.
As we can see in , if \(f(x)\ge 0\) over \([a,b],\) then \(\sum _{i=1}^{n}f({m}_{i})\text{\Delta }x\) corresponds to the sum of the areas of rectangles approximating the area between the graph of \(f(x)\) and the x-axis over \([a,b].\) The graph shows the rectangles corresponding to \({M}_{4}\) for a nonnegative function over a closed interval \([a,b].\)
Example
Try it.
Use \({M}_{6}\) to estimate the length of the curve \(y=\frac{1}{2}{x}^{2}\) on \([1,4].\)
Solution
The length of \(y=\frac{1}{2}{x}^{2}\) on \([1,4]\) is
\[{\int }_{1}^{4}\sqrt{1+{(\frac{dy}{dx})}^{2}}\ dx.\]Since \(\frac{dy}{dx}=x,\) this integral becomes \({\int }_{1}^{4}\sqrt{1+{x}^{2}}\ dx.\)
If \([1,4]\) is divided into six subintervals, then each subinterval has length \(\text{\Delta }x=\frac{4-1}{6}=\frac{1}{2}\) and the midpoints of the subintervals are \(\{\frac{5}{4},\frac{7}{4},\frac{9}{4},\frac{11}{4},\frac{13}{4},\frac{15}{4}\}.\) If we set \(f(x)=\sqrt{1+{x}^{2}},\)
\[\begin{array}{ll}{M}_{6} & =\frac{1}{2}f(\frac{5}{4})+\frac{1}{2}f(\frac{7}{4})+\frac{1}{2}f(\frac{9}{4})+\frac{1}{2}f(\frac{11}{4})+\frac{1}{2}f(\frac{13}{4})+\frac{1}{2}f(\frac{15}{4}) \\ & \approx \frac{1}{2}(1.6008+2.0156+2.4622+2.9262+3.4004+3.8810)=8.1431.\end{array}\]Condensed — the full section is in OpenStax Calculus Volume 2.
The Trapezoidal Rule
We can also approximate the value of a definite integral by using trapezoids rather than rectangles. In , the area beneath the curve is approximated by trapezoids rather than by rectangles.
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 . We assume that the length of each subinterval is given by \(\text{\Delta }x.\) First, recall that the area of a trapezoid with a height of h and bases of length \({b}_{1}\) and \({b}_{2}\) is given by \(\text{Area}=\frac{1}{2}h({b}_{1}+{b}_{2}).\) We see that the first trapezoid has a height \(\text{\Delta }x\) and parallel bases of length \(f({x}_{0})\) and \(f({x}_{1}).\) Thus, the area of the first trapezoid in is
\[\frac{1}{2}\text{\Delta }x(f({x}_{0})+f({x}_{1})).\]The areas of the remaining three trapezoids are
\[\frac{1}{2}\text{\Delta }x(f({x}_{1})+f({x}_{2})),\frac{1}{2}\text{\Delta }x(f({x}_{2})+f({x}_{3})),\text{and}\ \frac{1}{2}\text{\Delta }x(f({x}_{3})+f({x}_{4})).\]Consequently,
\[{\int }_{a}^{b}f(x)dx\approx \frac{1}{2}\text{\Delta }x(f({x}_{0})+f({x}_{1}))+\frac{1}{2}\text{\Delta }x(f({x}_{1})+f({x}_{2}))+\frac{1}{2}\text{\Delta }x(f({x}_{2})+f({x}_{3}))+\frac{1}{2}\text{\Delta }x(f({x}_{3})+f({x}_{4})).\]After taking out a common factor of \(\frac{1}{2}\text{\Delta }x\) and combining like terms, we have
\[{\int }_{a}^{b}f(x)dx\approx \frac{1}{2}\text{\Delta }x(f({x}_{0})+2f({x}_{1})+2f({x}_{2})+2f({x}_{3})+f({x}_{4})).\]Generalizing, we formally state the following rule.
Before continuing, let’s make a few observations about the trapezoidal rule. First of all, it is useful to note that
\[{T}_{n}=\frac{1}{2}({L}_{n}+{R}_{n})\ \text{where}\ {L}_{n}=\sum _{i=1}^{n}f({x}_{i-1})\text{\Delta }x\ \text{and}\ {R}_{n}=\sum _{i=1}^{n}f({x}_{i})\text{\Delta }x.\]Condensed — the full section is in OpenStax Calculus Volume 2.
Absolute and Relative Error
An important aspect of using these numerical approximation rules consists of calculating the error in using them for estimating the value of a definite integral. We first need to define absolute error and relative error.
Example
Try it.
Calculate the absolute and relative error in the estimate of \({\int }_{0}^{1}{x}^{2}dx\) using the midpoint rule, found in .
Solution
The calculated value is \({\int }_{0}^{1}{x}^{2}dx=\frac{1}{3}\) and our estimate from the example is \({M}_{4}=\frac{21}{64}.\) Thus, the absolute error is given by \(|(\frac{1}{3})-(\frac{21}{64})|=\frac{1}{192}\approx 0.0052.\) The relative error is
\[\frac{1\text{/}192}{1\text{/}3}=\frac{1}{64}\approx 0.015625\approx 1.6\text{\%}.\]Example
Try it.
Calculate the absolute and relative error in the estimate of \({\int }_{0}^{1}{x}^{2}dx\) using the trapezoidal rule, found in .
Solution
The calculated value is \({\int }_{0}^{1}{x}^{2}dx=\frac{1}{3}\) and our estimate from the example is \({T}_{4}=\frac{11}{32}.\) Thus, the absolute error is given by \(|\frac{1}{3}-\frac{11}{32}|=\frac{1}{96}\approx 0.0104.\) The relative error is given by
\[\frac{1\text{/}96}{1\text{/}3}=0.03125\approx 3.1\text{\%}.\]In the two previous examples, we were able to compare our estimate of an integral with the actual value of the integral; however, we do not typically have this luxury. In general, if we are approximating an integral, we are doing so because we cannot compute the exact value of the integral itself easily. Therefore, it is often helpful to be able to determine an upper bound for the error in an approximation of an integral. The following theorem provides error bounds for the midpoint and trapezoidal rules. The theorem is stated without proof.
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.
Condensed — the full section is in OpenStax Calculus Volume 2.
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 width. Over the first pair of subintervals we approximate \({\int }_{{x}_{0}}^{{x}_{2}}f(x)dx\) with \({\int }_{{x}_{0}}^{{x}_{2}}p(x)dx,\) where \(p(x)=A{x}^{2}+Bx+C\) is the quadratic function passing through \(({x}_{0},f({x}_{0})),\) \(({x}_{1},f({x}_{1})),\) and \(({x}_{2},f({x}_{2}))\) (). Over the next pair of subintervals we approximate \({\int }_{{x}_{2}}^{{x}_{4}}f(x)dx\) with the integral of another quadratic function passing through \(({x}_{2},f({x}_{2})),\) \(({x}_{3},f({x}_{3})),\) and \(({x}_{4},f({x}_{4})).\) This process is continued with each successive pair of subintervals.
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:
\[\begin{array}{l}f({x}_{0})=p({x}_{0})=A{x}_{0}{}^{2}+B{x}_{0}+C \\ f({x}_{1})=p({x}_{1})=A{x}_{1}{}^{2}+B{x}_{1}+C \\ f({x}_{2})=p({x}_{2})=A{x}_{2}{}^{2}+B{x}_{2}+C\end{array}\]\({x}_{2}-{x}_{0}=2\text{\Delta }x,\) where \(\text{\Delta }x\) is the length of a subinterval.
\[{x}_{2}+{x}_{0}=2{x}_{1},\ \text{since}\ {x}_{1}=\frac{({x}_{2}+{x}_{0})}{2}.\]Thus,
If we approximate \({\int }_{{x}_{2}}^{{x}_{4}}f(x)dx\) using the same method, we see that we have
\[{\int }_{{x}_{2}}^{{x}_{4}}f(x)dx\approx \frac{\text{\Delta }x}{3}(f({x}_{4})+4f({x}_{3})+f({x}_{2})).\]Combining these two approximations, we get
\[{\int }_{{x}_{2}}^{{x}_{4}}f(x)dx=\frac{\text{\Delta }x}{3}(f({x}_{0})+4f({x}_{1})+2f({x}_{2})+4f({x}_{3})+f({x}_{4})).\]The pattern continues as we add pairs of subintervals to our approximation. The general rule may be stated as follows.
Condensed — the full section is in OpenStax Calculus Volume 2.
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
| Midpoint rule | \({M}_{n}=\sum _{i=1}^{n}f({m}_{i})\text{\Delta }x\) |
| Trapezoidal rule | \({T}_{n}=\frac{1}{2}\text{\Delta }x(f({x}_{0})+2f({x}_{1})+2f({x}_{2})+\cdots +2f({x}_{n-1})+f({x}_{n}))\) |
| Simpson’s rule | \({S}_{n}=\frac{\text{\Delta }x}{3}(f({x}_{0})+4f({x}_{1})+2f({x}_{2})+4f({x}_{3})+2f({x}_{4})+4f({x}_{5})+\cdots +2f({x}_{n-2})+4f({x}_{n-1})+f({x}_{n}))\) |
| Error bound for midpoint rule | \(\text{Error in}\ {M}_{n}\le \frac{M{(b-a)}^{3}}{24{n}^{2}}\) |
| Error bound for trapezoidal rule | \(\text{Error in}\ {T}_{n}\le \frac{M{(b-a)}^{3}}{12{n}^{2}}\) |
| Error bound for Simpson’s rule | \(\text{Error in}\ {S}_{n}\le \frac{M{(b-a)}^{5}}{180{n}^{4}}\) |
Numerical Integration
Approximate the following integrals using either the midpoint rule, trapezoidal rule, or Simpson’s rule as indicated. (Round answers to three decimal places.)
Approximate the integral to three decimal places using the indicated rule.
Introduction
When we first explored finding the net signed area bounded by a curve, we developed the concept of a Riemann sum as a helpful estimation tool and a key step in the definition of the definite integral. Recall that the left, right, and middle Riemann sums of a function \(f\) on an interval \([a,b]\) are given by \[\begin{aligned}L_n = f(x_0) \Delta x + f(x_1) \Delta x + \cdots + f(x_{n-1}) \Delta x \amp= \sum_{i = 0}^{n-1} f(x_i) \Delta x, \\ R_n = f(x_1) \Delta x + f(x_2) \Delta x + \cdots + f(x_{n}) \Delta x \amp= \sum_{i = 1}^{n} f(x_i) \Delta x, \\ M_n = f(\overline{x}_1) \Delta x + f(\overline{x}_2) \Delta x + \cdots + f(\overline{x}_{n}) \Delta x \amp= \sum_{i = 1}^{n} f(\overline{x}_i) \Delta x\end{aligned}\], where \(x_0 = a\), \(x_i = a + i\Delta x\), \(x_n = b\), and \(\Delta x = \frac{b-a}{n}\). For the middle sum, we defined \(\overline{x}_{i} = (x_{i-1} + x_i)/2\).
A Riemann sum is a sum of (possibly signed) areas of rectangles. The value of \(n\) determines the number of rectangles, and our choice of left endpoints, right endpoints, or midpoints determines the heights of the rectangles. We can see the similarities and differences among these three options in Figure, where we consider the function \(f(x) = \frac{1}{20}(x-4)^3 + 7\) on the interval \([1,8]\), and use 5 rectangles for each of the Riemann sums.
While it is a good exercise to compute a few Riemann sums by hand, just to ensure that we understand how they work and how varying the function, the number of subintervals, and the choice of endpoints or midpoints affects the result, using computing technology is the best way to determine \(L_n\), \(R_n\), and \(M_n\). Any computer algebra system will offer this capability; as we saw in Preview Activity, a straightforward option that is freely available online is this interactive. Note that we can adjust the formula for \(f(x)\), the window of \(x\)- and \(y\)-values of interest, the number of subintervals, and the type of Riemann sum. (See Preview Activity for any needed reminders on how the interactive works.)
In this section we explore several different alternatives for estimating definite integrals. Our main goal is to develop formulas to estimate definite integrals accurately without using a large numbers of rectangles.
Exploration
Exploration
The Trapezoid Rule
So far, we have used the simplest possible quadrilaterals (that is, rectangles) to estimate areas. It is natural, however, to wonder if other familiar shapes might serve us even better.
An alternative to \(L_n\), \(R_n\), and \(M_n\) is called the Trapezoid Rule. Rather than using a rectangle to estimate the (signed) area bounded by \(y = f(x)\) on a small interval, we use a trapezoid. For example, in Figure, we estimate the area under the curve using three subintervals and the trapezoids that result from connecting the corresponding points on the curve with straight lines.
The biggest difference between the Trapezoid Rule and a Riemann sum is that on each subinterval, the Trapezoid Rule uses two function values, rather than one, to estimate the (signed) area bounded by the curve. For instance, to compute \(D_1\), the area of the trapezoid on \([x_0, x_1]\), we observe that the left base has length \(f(x_0)\), while the right base has length \(f(x_1)\). The height of the trapezoid is \(x_1 - x_0 = \Delta x = \frac{b-a}{3}\). The area of a trapezoid is the average of the bases times the height, so we have \[\begin{aligned}\end{aligned}\].
Using similar computations for \(D_2\) and \(D_3\), we find that \(T_3\), the trapezoidal approximation to \(\int_a^b f(x) \, dx\) is given by \[\begin{aligned}T_3 \amp= D_1 + D_2 + D_3 \\ \amp= \frac{1}{2}(f(x_0) + f(x_1)) \cdot \Delta x + \frac{1}{2}(f(x_1) + f(x_2)) \cdot \Delta x + \frac{1}{2}(f(x_2) + f(x_3)) \cdot \Delta x\end{aligned}\].
Because both left and right endpoints are being used, we recognize within the trapezoidal approximation the use of both left and right Riemann sums. Rearranging the expression for \(T_3\) by removing factors of \(\frac{1}{2}\) and \(\Delta x\), grouping the left endpoint and right endpoint evaluations of \(f\), we see that \[\begin{aligned}\end{aligned}\].
We now observe that two familiar sums have arisen. The left Riemann sum \(L_3\) is \(L_3 = f(x_0) \Delta x + f(x_1) \Delta x + f(x_2) \Delta x\), and the right Riemann sum is \(R_3 = f(x_1) \Delta x + f(x_2) \Delta x + f(x_3) \Delta x\). Substituting \(L_3\) and \(R_3\) for the corresponding expressions in Equation, it follows that \(T_3 = \frac{1}{2} \left[ L_3 + R_3 \right]\). We have thus seen a very important result: using trapezoids to estimate the (signed) area bounded by a curve is the same as averaging the estimates generated by using left and right endpoints.
Condensed — the full section is in Boelkins, Active Calculus.
Comparing the Midpoint and Trapezoid Rules
We know from the definition of the definite integral that if we let \(n\) be large enough, we can make any of the approximations \(L_n\), \(R_n\), and \(M_n\) as close as we'd like (in theory) to the exact value of \(\int_a^b f(x) \, dx\). Thus, it may be natural to wonder why we ever use any rule other than \(L_n\) or \(R_n\) (with a sufficiently large \(n\) value) to estimate a definite integral. One of the primary reasons is that as \(n \to \infty\), \(\Delta x = \frac{b-a}{n} \to 0\), and thus in a Riemann sum calculation with a large \(n\) value, we end up multiplying by a number that is very close to zero. Doing so often generates roundoff error, because representing numbers close to zero accurately is a persistent challenge for computers.
Hence, we explore ways to estimate definite integrals to high levels of precision, but without using extremely large values of \(n\). Paying close attention to patterns in errors, such as those observed in Activity, is one way to begin to see some alternate approaches.
To begin, we compare the errors in the Midpoint and Trapezoid rules. First, consider a function that is concave up on a given interval, and picture approximating the area bounded on that interval by both the Midpoint and Trapezoid rules using a single subinterval, as shown in Figure.
As seen at left in Figure, it is evident that whenever the function is concave up on an interval, the Trapezoid Rule with one subinterval, \(T_1\), will overestimate the exact value of the definite integral on that interval. From a careful analysis of the line that bounds the top of the rectangle for the Midpoint Rule (shown in magenta), we see that if we rotate this line segment until it is tangent to the curve at the midpoint of the interval (as shown at right in Figure), the resulting trapezoid has the same area as \(M_1\), and this value is less than the exact value of the definite integral. Thus, when the function is concave up on the interval, \(M_1\) underestimates the integral's true value.
These observations extend easily to the situation where the function's concavity remains consistent but we use larger values of \(n\) in the Midpoint and Trapezoid Rules. Hence, whenever \(f\) is concave up on \([a,b]\), \(T_n\) will overestimate the value of \(\int_a^b f(x) \, dx\), while \(M_n\) will underestimate \(\int_a^b f(x) \, dx\). The reverse observations are true in the situation where \(f\) is concave down.
Condensed — the full section is in Boelkins, Active Calculus.
Simpson's Rule
When we first developed the Trapezoid Rule, we observed that it is an average of the Left and Right Riemann sums: \[\begin{aligned}\end{aligned}\].
If a function is always increasing or always decreasing on the interval \([a,b]\), one of \(L_n\) and \(R_n\) will over-estimate the true value of \(\int_a^b f(x) \, dx\), while the other will under-estimate the integral. Thus, the errors that result from \(L_n\) and \(R_n\) will have opposite signs; so averaging \(L_n\) and \(R_n\) eliminates a considerable amount of the error present in the respective approximations. In a similar way, it makes sense to think about averaging \(M_n\) and \(T_n\) in order to generate a still more accurate approximation.
We've just observed that \(M_n\) is typically about twice as accurate as \(T_n\). So we use the weighted average \[\begin{aligned}\end{aligned}\].
The rule for \(S_{2n}\) giving by Equation is usually known as Simpson's Rule. Thomas Simpson was an 18th century mathematician; his idea was to extend the Trapezoid rule, but rather than using straight lines to build trapezoids, to use quadratic functions to build regions whose area was bounded by parabolas (whose areas he could find exactly). Simpson's Rule is often developed from the more sophisticated perspective of using interpolation by quadratic functions. Note that we use \(S_{2n}\) rather that \(S_n\) since the \(n\) points the Midpoint Rule uses are different from the \(n\) points the Trapezoid Rule uses, and thus Simpson's Rule is using \(2n\) points at which to evaluate the function. We build upon the results in Table to see the approximations generated by Simpson's Rule. In particular, in Table, we include all of the results in Table, but include additional results for \(S_8 = \frac{2M_4 + T_4}{3}\) and \(S_{16} = \frac{2M_8 + T_8}{3}\).
| Rule | \(\int_0^1 (1-x^2) \,dx = 0.\overline{6}\) | error | \(\int_1^2 \frac{1}{x^2} \, dx = 0.5\) | error |
| \(T_4\) | \(0.65625\) | \(-0.0104166667\) | \(0.5089937642\) | \(0.0089937642\) |
| \(M_4\) | \(0.671875\) | \(0.0052083333\) | \(0.4955479365\) | \(-0.0044520635\) |
| \(S_8\) | \(0.6666666667\) | \(0\) | \(0.5000298792\) | \(0.0000298792\) |
| \(T_8\) | \(0.6640625\) | \(-0.0026041667\) | \(0.5022708502\) | \(0.0022708502\) |
| \(M_8\) | \(0.66796875\) | \(0.0013020833\) | \(0.4988674899\) | \(-0.0011325101\) |
| \(S_{16}\) | \(0.6666666667\) | \(0\) | \(0.5000019434\) | \(0.0000019434\) |
Condensed — the full section is in Boelkins, Active Calculus.
Overall observations regarding L_n, R_n, T_n, M_n, and S_{2n}.
As we conclude our discussion of numerical approximation of definite integrals, it is important to summarize general trends in how the various rules over- or under-estimate the true value of a definite integral, and by how much. To revisit some past observations and see some new ones, we consider the following activity.
The results seen in Activity generalize nicely. For instance, if \(f\) is decreasing on \([a,b]\), \(L_n\) will over-estimate the exact value of \(\int_a^b f(x) \,dx\), and if \(f\) is concave down on \([a,b]\), \(M_n\) will over-estimate the exact value of the integral. An excellent exercise is to write a collection of scenarios of possible function behavior, and then categorize whether each of \(L_n\), \(R_n\), \(T_n\), and \(M_n\) is an over- or under-estimate.
Finally, we make two important notes about Simpson's Rule. When T.Simpson first developed this rule, his idea was to replace the function \(f\) on a given interval with a quadratic function that shared three values with the function \(f\). In so doing, he guaranteed that this new approximation rule would be exact for the definite integral of any quadratic polynomial. In one of the pleasant surprises of numerical analysis, it turns out that even though it was designed to be exact for quadratic polynomials, Simpson's Rule is exact for any cubic polynomial: that is, if we are interested in an integral such as \(\int_2^5 (5x^3 - 2x^2 + 7x - 4)\, dx\), \(S_{2n}\) will always be exact, regardless of the value of \(n\). This is just one more piece of evidence that shows how effective Simpson's Rule is as an approximation tool for estimating definite integrals. One reason that Simpson's Rule is so effective is that \(S_{2n}\) benefits from using \(2n+1\) points of data. Because it combines \(M_n\), which uses \(n\) midpoints, and \(T_n\), which uses the \(n+1\) endpoints of the chosen subintervals, \(S_{2n}\) takes advantage of the maximum amount of information we have when we know function values at the endpoints and midpoints of \(n\) subintervals.
Summary
For a definite integral such as \(\int_0^1 e^{-x^2} \, dx\) when we cannot use the First Fundamental Theorem of Calculus because the integrand lacks an elementary algebraic antiderivative, we can estimate the integral's value by using a sequence of Riemann sum approximations. Typically, we start by computing \(L_n\), \(R_n\), and \(M_n\) for one or more chosen values of \(n\).
The Trapezoid Rule, which estimates \(\int_a^b f(x) \, dx\) by using trapezoids, rather than rectangles, can also be viewed as the average of Left and Right Riemann sums. That is, \(T_n = \frac{1}{2}(L_n + R_n)\).
The Midpoint Rule is typically twice as accurate as the Trapezoid Rule, and the signs of the respective errors of these rules are opposites. Hence, by taking the weighted average \(S_{2n} = \frac{2M_n + T_n}{3}\), we can build a much more accurate approximation to \(\int_a^b f(x) \, dx\) by using approximations we have already computed. The rule for \(S_{2n}\) is known as Simpson's Rule, which can also be developed by approximating a given continuous function with pieces of quadratic polynomials.
Practice (40)
Try each one on paper first. Reveal the answer to check; verified ones can be opened in the solver for every step.
-
Use the midpoint rule to estimate \({\int }_{0}^{1}{x}^{2}dx\) using four subintervals. Compare the result with the actual value of this integral.
Αποκάλυψέ την.
Each subinterval has length \(\text{\Delta }x=\frac{1-0}{4}=\frac{1}{4}.\) Therefore, the subintervals consist of
\[[0,\frac{1}{4}],[\frac{1}{4},\frac{1}{2}],[\frac{1}{2},\frac{3}{4}],\ \text{and}\ [\frac{3}{4},1].\]The midpoints of these subintervals are \(\{\frac{1}{8},\frac{3}{8},\frac{5}{8},\frac{7}{8}\}.\) Thus,
\[{M}_{4}=\frac{1}{4}f(\frac{1}{8})+\frac{1}{4}f(\frac{3}{8})+\frac{1}{4}f(\frac{5}{8})+\frac{1}{4}f(\frac{7}{8})=\frac{1}{4}\cdot \frac{1}{64}+\frac{1}{4}\cdot \frac{9}{64}+\frac{1}{4}\cdot \frac{25}{64}+\frac{1}{4}\cdot \frac{49}{64}=\frac{21}{64}.\]Since
\[{\int }_{0}^{1}{x}^{2}dx=\frac{1}{3}\ \text{and}\ |\frac{1}{3}-\frac{21}{64}|=\frac{1}{192}\approx 0.0052,\]we see that the midpoint rule produces an estimate that is somewhat close to the actual value of the definite integral.
-
Use \({M}_{6}\) to estimate the length of the curve \(y=\frac{1}{2}{x}^{2}\) on \([1,4].\)
Αποκάλυψέ την.
The length of \(y=\frac{1}{2}{x}^{2}\) on \([1,4]\) is
\[{\int }_{1}^{4}\sqrt{1+{(\frac{dy}{dx})}^{2}}\ dx.\]Since \(\frac{dy}{dx}=x,\) this integral becomes \({\int }_{1}^{4}\sqrt{1+{x}^{2}}\ dx.\)
If \([1,4]\) is divided into six subintervals, then each subinterval has length \(\text{\Delta }x=\frac{4-1}{6}=\frac{1}{2}\) and the midpoints of the subintervals are \(\{\frac{5}{4},\frac{7}{4},\frac{9}{4},\frac{11}{4},\frac{13}{4},\frac{15}{4}\}.\) If we set \(f(x)=\sqrt{1+{x}^{2}},\)
\[\begin{array}{ll}{M}_{6} & =\frac{1}{2}f(\frac{5}{4})+\frac{1}{2}f(\frac{7}{4})+\frac{1}{2}f(\frac{9}{4})+\frac{1}{2}f(\frac{11}{4})+\frac{1}{2}f(\frac{13}{4})+\frac{1}{2}f(\frac{15}{4}) \\ & \approx \frac{1}{2}(1.6008+2.0156+2.4622+2.9262+3.4004+3.8810)=8.1431.\end{array}\] -
Use the midpoint rule with \(n=2\) to estimate \({\int }_{1}^{2}\frac{1}{x}dx.\)
Αποκάλυψέ την.
\(\frac{24}{35}\)
-
Use the trapezoidal rule to estimate \({\int }_{0}^{1}{x}^{2}dx\) using four subintervals.
Αποκάλυψέ την.
The endpoints of the subintervals consist of elements of the set \(P=\{0,\frac{1}{4},\frac{1}{2},\frac{3}{4},1\}\) and \(\text{\Delta }x=\frac{1-0}{4}=\frac{1}{4}.\) Thus,
\[\begin{array}{ll}{\int }_{0}^{1}{x}^{2}dx & \approx \frac{1}{2}\cdot \frac{1}{4}(f(0)+2f(\frac{1}{4})+2f(\frac{1}{2})+2f(\frac{3}{4})+f(1)) \\ & =\frac{1}{8}(0+2\cdot \frac{1}{16}+2\cdot \frac{1}{4}+2\cdot \frac{9}{16}+1) \\ & =\frac{11}{32}.\end{array}\] -
Use the trapezoidal rule with \(n=2\) to estimate \({\int }_{1}^{2}\frac{1}{x}dx.\)
Αποκάλυψέ την.
\(\frac{17}{24}\)
-
Calculate the absolute and relative error in the estimate of \({\int }_{0}^{1}{x}^{2}dx\) using the midpoint rule, found in .
Αποκάλυψέ την.
The calculated value is \({\int }_{0}^{1}{x}^{2}dx=\frac{1}{3}\) and our estimate from the example is \({M}_{4}=\frac{21}{64}.\) Thus, the absolute error is given by \(|(\frac{1}{3})-(\frac{21}{64})|=\frac{1}{192}\approx 0.0052.\) The relative error is
\[\frac{1\text{/}192}{1\text{/}3}=\frac{1}{64}\approx 0.015625\approx 1.6\text{\%}.\] -
Calculate the absolute and relative error in the estimate of \({\int }_{0}^{1}{x}^{2}dx\) using the trapezoidal rule, found in .
Αποκάλυψέ την.
The calculated value is \({\int }_{0}^{1}{x}^{2}dx=\frac{1}{3}\) and our estimate from the example is \({T}_{4}=\frac{11}{32}.\) Thus, the absolute error is given by \(|\frac{1}{3}-\frac{11}{32}|=\frac{1}{96}\approx 0.0104.\) The relative error is given by
\[\frac{1\text{/}96}{1\text{/}3}=0.03125\approx 3.1\text{\%}.\] -
In an earlier checkpoint, we estimated \({\int }_{1}^{2}\frac{1}{x}dx\) to be \(\frac{24}{35}\) using \({T}_{2}.\) The actual value of this integral is \(\text{ln}\ 2.\) Using \(\frac{24}{35}\approx 0.6857\) and \(\text{ln}\ 2\approx 0.6931,\) calculate the absolute error and the relative error.
Αποκάλυψέ την.
0.0074, 1.1%
-
What value of \(n\) should be used to guarantee that an estimate of \({\int }_{0}^{1}{e}^{{x}^{2}}dx\) is accurate to within 0.01 if we use the midpoint rule?
Αποκάλυψέ την.
We begin by determining the value of \(M,\) the maximum value of \(|{f}^{″}(x)|\) over \([0,1]\) for \(f(x)={e}^{{x}^{2}}.\) Since \({f}^{'}(x)=2x{e}^{{x}^{2}},\) we have
\[{f}^{\text{″}}(x)=2{e}^{{x}^{2}}+4{x}^{2}{e}^{{x}^{2}}.\]Thus,
\[|{f}^{″}(x)|=2{e}^{{x}^{2}}(1+2{x}^{2})\le 2\cdot e\cdot 3=6e.\]From the error-bound , we have
\[\text{Error in}\ {M}_{n}\le \frac{M{(b-a)}^{3}}{24{n}^{2}}\le \frac{6e{(1-0)}^{3}}{24{n}^{2}}=\frac{6e}{24{n}^{2}}.\]Now we solve the following inequality for \(n\text{:}\)
\[\frac{6e}{24{n}^{2}}\le 0.01.\]Thus, \(n\ge \sqrt{\frac{600e}{24}}\approx 8.24.\) Since \(n\) must be an integer satisfying this inequality, a choice of \(n=9\) would guarantee that \(|{\int }_{0}^{1}{e}^{{x}^{2}}dx-{M}_{n}|<0.01.\)
-
Use to find an upper bound for the error in using \({M}_{4}\) to estimate \({\int }_{0}^{1}{x}^{2}dx.\)
Αποκάλυψέ την.
\(\frac{1}{192}\)
-
Use \({S}_{2}\) to approximate \({\int }_{0}^{1}{x}^{3}dx.\) Estimate a bound for the error in \({S}_{2}.\)
Αποκάλυψέ την.
Since \([0,1]\) is divided into two intervals, each subinterval has length \(\text{\Delta }x=\frac{1-0}{2}=\frac{1}{2}.\) The endpoints of these subintervals are \(\{0,\frac{1}{2},1\}.\) If we set \(f(x)={x}^{3},\) then
\({S}_{4}=\frac{1}{3}\cdot \frac{1}{2}(f(0)+4f(\frac{1}{2})+f(1))=\frac{1}{6}(0+4\cdot \frac{1}{8}+1)=\frac{1}{4}.\) Since \({f}^{(4)}(x)=0\) and consequently \(M=0,\) we see that
\[\text{Error in}\ {S}_{2}\le \frac{0{(1)}^{5}}{180⋅{2}^{4}}=0.\]This bound indicates that the value obtained through Simpson’s rule is exact. A quick check will verify that, in fact, \({\int }_{0}^{1}{x}^{3}dx=\frac{1}{4}.\)
-
Use \({S}_{6}\) to estimate the length of the curve \(y=\frac{1}{2}{x}^{2}\) over \([1,4].\)
Αποκάλυψέ την.
The length of \(y=\frac{1}{2}{x}^{2}\) over \([1,4]\) is \({\int }_{1}^{4}\sqrt{1+{x}^{2}}\ dx.\) If we divide \([1,4]\) into six subintervals, then each subinterval has length \(\text{\Delta }x=\frac{4-1}{6}=\frac{1}{2},\) and the endpoints of the subintervals are \(\{1,\frac{3}{2},2,\frac{5}{2},3,\frac{7}{2},4\}.\) Setting \(f(x)=\sqrt{1+{x}^{2}},\)
\[{S}_{6}=\frac{1}{3}\cdot \frac{1}{2}(f(1)+4f(\frac{3}{2})+2f(2)+4f(\frac{5}{2})+2f(3)+4f(\frac{7}{2})+f(4)).\]After substituting, we have
\[\begin{array}{ll}{S}_{6} & =\frac{1}{6}(1.4142+4\cdot 1.80278+2\cdot 2.23607+4\cdot 2.69258+2\cdot 3.16228+4\cdot 3.64005+4.12311) \\ & \approx 8.14594.\end{array}\] -
Use \({S}_{2}\) to estimate \({\int }_{1}^{2}\frac{1}{x}dx.\)
Αποκάλυψέ την.
\(\frac{25}{36}\)
-
\({\int }_{1}^{2}\frac{dx}{x};\) trapezoidal rule; \(n=5\)
Αποκάλυψέ την.
0.696
-
\({\int }_{0}^{3}\sqrt{4+{x}^{3}}\ dx;\) trapezoidal rule; \(n=6\)
-
\({\int }_{0}^{3}\sqrt{4+{x}^{3}}\ dx;\) trapezoidal rule; \(n=3\)
Αποκάλυψέ την.
9.484
-
\({\int }_{0}^{12}{x}^{2}dx;\) midpoint rule; \(n=6\)
-
\({\int }_{0}^{1}{\text{sin}}^{2}(\pi x)dx;\) midpoint rule; \(n=3\)
Αποκάλυψέ την.
0.5000
-
Use the midpoint rule with eight subdivisions to estimate \({\int }_{2}^{4}{x}^{2}dx.\)
-
Use the trapezoidal rule with four subdivisions to estimate \({\int }_{2}^{4}{x}^{2}dx.\)
Αποκάλυψέ την.
\({T}_{4}=18.75\)
-
Find the exact value of \({\int }_{2}^{4}{x}^{2}dx.\) Find the error of approximation between the exact value and the value calculated using the trapezoidal rule with four subdivisions. Draw a graph to illustrate.
-
\({\int }_{0}^{1}{\text{sin}}^{2}(\pi x)dx;\) trapezoidal rule; \(n=6\)
Αποκάλυψέ την.
0.500
-
\({\int }_{0}^{3}\frac{1}{1+{x}^{3}}dx;\) trapezoidal rule; \(n=6\)
-
\({\int }_{0}^{3}\frac{1}{1+{x}^{3}}dx;\) trapezoidal rule; \(n=3\)
Αποκάλυψέ την.
1.129
-
\({\int }_{0}^{0.8}{e}^{\text{-}{x}^{2}}dx;\) trapezoidal rule; \(n=4\)
-
\({\int }_{0}^{0.8}{e}^{\text{-}{x}^{2}}dx;\) Simpson’s rule; \(n=4\)
Αποκάλυψέ την.
0.6577
-
\({\int }_{0}^{0.4}\text{sin}({x}^{2})dx;\) trapezoidal rule; \(n=4\)
-
\({\int }_{0}^{0.4}\text{sin}({x}^{2})dx;\) Simpson’s rule; \(n=4\)
Αποκάλυψέ την.
0.0213
-
\({\int }_{0.1}^{0.5}\frac{\text{cos}\ x}{x}dx;\) trapezoidal rule; \(n=4\)
-
\({\int }_{0.1}^{0.5}\frac{\text{cos}\ x}{x}dx;\) Simpson’s rule; \(n=4\)
Αποκάλυψέ την.
1.5629
-
Evaluate \({\int }_{0}^{1}\frac{dx}{1+{x}^{2}}\) exactly and show that the result is \(\pi \text{/}4.\) Then, find the approximate value of the integral using the trapezoidal rule with \(n=4\) subdivisions. Use the result to approximate the value of \(\pi .\)
-
Approximate \({\int }_{2}^{4}\frac{1}{\text{ln}\ x}dx\) using the midpoint rule with four subdivisions to four decimal places.
Αποκάλυψέ την.
1.9133
-
Approximate \({\int }_{2}^{4}\frac{1}{\text{ln}\ x}dx\) using the trapezoidal rule with eight subdivisions to four decimal places.
-
Use the trapezoidal rule with four subdivisions to estimate \({\int }_{0}^{0.8}{x}^{3}dx\) to four decimal places.
Αποκάλυψέ την.
\(\text{T(4)}=0.1088\)
-
Use the trapezoidal rule with four subdivisions to estimate \({\int }_{0}^{0.8}{x}^{3}dx.\) Compare this value with the exact value and find the error estimate.
-
Using Simpson’s rule with four subdivisions, find \({\int }_{0}^{\pi \text{/}2}\text{cos}(x)dx.\)
Αποκάλυψέ την.
1.0
-
Show that the exact value of \({\int }_{0}^{1}x{e}^{\text{-}x}dx=1-\frac{2}{e}.\) Find the absolute error if you approximate the integral using the midpoint rule with 16 subdivisions.
-
Given \({\int }_{0}^{1}x{e}^{\text{-}x}dx=1-\frac{2}{e},\) use the trapezoidal rule with 16 subdivisions to approximate the integral and find the absolute error.
Αποκάλυψέ την.
Approximate error is 0.000325.
-
Find an upper bound for the error in estimating \({\int }_{0}^{3}(5x+4)dx\) using the trapezoidal rule with six steps.
-
Find an upper bound for the error in estimating \({\int }_{4}^{5}\frac{1}{{(x-1)}^{2}}dx\) using the trapezoidal rule with seven subdivisions.
Αποκάλυψέ την.
\(\frac{1}{7938}\)
Symbols used here
Add a_k for k = 1 up to n.
Antiderivative (indefinite) or signed area from a to b (definite).
The non-negative number whose square (n-th power) is x.
Not a number: "grows without bound" in limits and intervals.
Ratio of a circle's circumference to its diameter, 3.14159…
Instantaneous rate of change; slope of the graph.
i² = −1.
Equal to the precision shown, not exactly.
Inequalities that allow equality; < and > exclude it.
Least upper bound, greatest lower bound.
2.71828…, the base whose exponential is its own derivative.
Ratios of sides in a right triangle; coordinates on the unit circle.
The exponent b must be raised to for x; ln uses base e.
The value f(x) approaches as x approaches a.
Prime notation for derivatives with respect to x (or t).
Constants of integration fixed by initial conditions.
How to: Numerical Integration
- Approximate the value of a definite integral by using the midpoint and trapezoidal rules.
- Determine the absolute and relative error in using a numerical integration technique.
- Estimate the absolute and relative error using an error-bound formula.
- Recognize when the midpoint and trapezoidal rules over- or underestimate the true value of an integral.
- Use Simpson’s rule to approximate the value of a definite integral to a given accuracy.
- 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.
Questions people ask
What is a derivative in one sentence?
The slope of the graph at a point — the rate at which the output is changing there. Speed is the derivative of position.
What is an integral in one sentence?
The accumulated total of a rate — the area under the curve. Distance travelled is the integral of speed.
Why are derivatives and integrals opposites?
That is the fundamental theorem of calculus: accumulating a rate and then measuring how fast the accumulation grows gets you back the rate. Integration undoes differentiation up to a constant.
When do I use substitution and when integration by parts?
Substitution when part of the integrand is the derivative of another part (u and du both present). Parts when the integrand is a product of two unrelated kinds of function — a polynomial times an exponential, log or trig function.
Δοκίμασε μόνος σου.
Parts of this page are adapted from Boelkins, Active Calculus (CC BY-SA 4.0), OpenStax Calculus Volume 2 (CC BY-NC-SA 4.0). Condensed and re-explained here; errors are ours.
Περισσότερα σε Calculus
LimitsDerivativesIntegralsDefinite integralsTaylor seriesSeries and sumsMaxima and minimaThe chain ruleImplicit differentiationRelated rates and optimisationIntegration techniques: substitution, parts, partial fractionsApplications of integration: area, volume, arc lengthInfinite series and convergence tests