Unit 6 · Topic 6.2

Approximate an integral numerically

Builds on the definite integral as signed area and the concavity of a graph. 13 minutes.

  1. Example 1Build left and right endpoint sums
  2. Example 2Build a midpoint sum
  3. Example 3Use the trapezoidal rule
  4. Example 4Determine the direction of error
  5. Example 5Interpret a numerical integral in context

Topic 6.1 found the change in an amount as the integral of its rate, the signed area between its graph and the axis. That area often cannot be found exactly, because the rate is known only from a table or its region is not made of simple shapes. To estimate \(\int_a^b f(x)\,dx\) from a few values of \(f\), cut \([a,b]\) into \(n\) subintervals at the points

\[a=x_0<x_1<x_2<\cdots<x_n=b\]

Subinterval \(i\) runs from \(x_{i-1}\) to \(x_i\), and its width is \(\cg{\Delta x_i}=x_i-x_{i-1}\). Over each subinterval, a shape whose area is easy to find replaces the region between the graph and the axis. The areas of the shapes add up to an estimate. This topic builds four such sums, shows when each is too large or too small, and says how far an estimate can be trusted.

Rectangles and trapezoids

A wavy curve f above the axis that rises, falls and rises again between a and b. Rectangles stand on four equal subintervals, and each takes its height from an orange dot on the curve, with a dashed orange line under the dot. Red marks the parts of the rectangles above the curve, and teal marks the parts of the region under the curve that they miss. A green bracket under one subinterval, from x sub i minus 1 to x sub i, marks its width delta x sub i, and an orange label above the curve names the height of its rectangle. A slider moves the sample points from the left endpoints to the right endpoints. Buttons turn the rectangles into trapezoids whose tops join the curve at both ends, and use 8 subintervals.

Figure 1Faintly shaded rectangles stand on the subintervals of \([a,b]\), and the green bracket marks the width of one of them. Each orange dot marks a height that a shape uses, with a dashed orange line under it for a rectangle. Red marks area that a shape counts above the curve, and teal marks area under the curve that it misses.

In Figure 1, a rectangle stands on each subinterval. Its height is the value of \(f\) at one point of the subinterval, called its sample point, which an orange dot marks on the curve. Its area is that height times its width. At first, every sample point is the left endpoint \(x_{i-1}\), and the sum of the areas is the left Riemann sum \(L_n\).

Move the sample point with the slider under Figure 1. At the right endpoint \(x_i\), the rectangles give the right Riemann sum \(R_n\), and at the midpoint

\[\cy{m_i}=\frac{x_{i-1}+x_i}{2}\]

they give the midpoint Riemann sum \(M_n\), which some books call the midpoint rule. A green bracket under the axis marks the width of one subinterval, and an orange label above the curve names the height of its rectangle.

The sum is too large by the red area above the curve and too small by the teal area that the rectangles miss. Use 8 subintervals with the button under Figure 1. The red and teal parts shrink, and the sum comes closer to the integral.

If the subintervals have the same width \(\cg{\Delta x}=\frac{b-a}{n}\), it is a common factor of all the terms. The left sum is then \(\Delta x\) times the sum of the heights \(f(x_0)\) through \(f(x_{n-1})\). The right sum uses \(f(x_1)\) through \(f(x_n)\), and the midpoint sum uses \(f(m_1)\) through \(f(m_n)\). Readings at unevenly spaced values of \(x\) give subintervals of different widths, so multiply each height by the width of its own subinterval.

Make trapezoids with the button under Figure 1. Each top now joins the two points of the curve above the ends of its subinterval. The area of a trapezoid is its width times the average of its two parallel sides:

\[\begin{aligned}&\frac{f(x_{i-1})+f(x_i)}{2}\,\Delta x_i\\&\quad=\frac12\big[f(x_{i-1})\,\Delta x_i+f(x_i)\,\Delta x_i\big]\end{aligned}\]

This is the average of the areas of the left and right rectangles on the subinterval. Adding over all subintervals gives the trapezoidal sum \(T_n\), which some books call the trapezoidal rule, so \(T_n\) is the average of \(L_n\) and \(R_n\). Every height except \(f(a)\) and \(f(b)\) is a side of two trapezoids, so with equal widths it counts twice.

Too large or too small

One subinterval, from x sub i minus 1 to x sub i, of a curve that is increasing and concave down, magnified. At first the shape on it is the left rectangle, and teal marks the part of the region above the rectangle that it misses. Buttons change the shape to the right rectangle, the midpoint rectangle, a trapezoid whose top is a chord, or the midpoint rectangle with its top tilted onto the tangent line at the midpoint m sub i. Red marks area that a shape counts above the curve. Two toggles make the curve decrease and make it concave up.

Figure 2One subinterval of a function that is increasing and concave down, magnified. The faintly shaded shape takes its heights at the orange dots. Red marks area that it counts above the curve, and teal marks area under the curve that it misses.

Figure 2 magnifies one subinterval of an increasing function and its left rectangle. Because \(f\) increases, it is smallest at the left endpoint, so the rectangle lies under the curve and misses the teal part. Use the right endpoint. The right rectangle reaches above the curve and counts the red part.

If \(f\) is increasing on \([a,b]\), this happens on every subinterval. A shape under the curve has less signed area than the region between the curve and the axis over the same subinterval. A shape above the curve has more. Together, these regions make up the region for the integral, so \(L_n\le\int_a^b f(x)\,dx\le R_n\). Make \(f\) decrease with the button under Figure 2. The right rectangle now lies under the curve, and the left rectangle reaches above it, so the inequalities reverse.

Whether \(T_n\) and \(M_n\) are too large or too small depends on how \(f\) bends. Make a trapezoid in Figure 2. Its top is a chord, a segment that joins two points of the graph, and the curve lies above it. The function in Figure 2 is concave down, so \(f'\) exists and is decreasing (topic 5.6). The Mean Value Theorem (topic 5.1) therefore gives a number \(c\) between the ends where \(f'(c)\) equals the slope of the chord.

The height of the curve above the chord is 0 at both ends, and its derivative is \(f'(x)-f'(c)\). Because \(f'\) is decreasing, this derivative is positive left of \(c\) and negative right of \(c\). By the Increasing/Decreasing Test (topic 5.3), the height increases from 0 and then decreases back to 0, so it is positive between the ends. The trapezoid therefore misses the teal part.

Use the midpoint. Then tilt the top onto the tangent line at \(m_i\). The top rises on one side of \(m_i\) as much as it falls on the other, so the area does not change. The midpoint rectangle therefore has the area of the trapezoid under the tangent line. A graph that is concave down lies below its tangent lines (topic 5.6), so this trapezoid counts the red part.

If \(f\) is continuous on \([a,b]\) and concave down on \((a,b)\), this happens on every subinterval. Then \(T_n\) is too small and \(M_n\) is too large. If \(f\) is concave up, \(f'\) is increasing, and the same arguments put the chord above the curve and the tangent line below it. Then \(T_n\) is too large and \(M_n\) is too small. Make \(f\) concave up with the button under Figure 2. The tilted top now lies below the curve.

The rules for \(L_n\) and \(R_n\) need \(f\) to increase or decrease on the whole interval. Those for \(T_n\) and \(M_n\) need one concavity there. The curve in Figure 1 rises and falls and bends both ways, so no rule applies to it. Each of its four sums shows both red and teal parts.

What an estimate tells you

An estimate has the units of the integral. Each term of a sum is a height times a width. If \(f\) is a rate in liters per minute and \(x\) is a time in minutes, every sum is in liters, as in topic 6.1.

A sum is not the integral, so state only the accuracy that the information supports. If \(f\) is increasing, the integral lies between \(L_n\) and \(R_n\). Every height except \(f(a)\) and \(f(b)\) appears in both sums, so with equal widths it cancels in their difference:

\[R_n-L_n=\big[f(b)-f(a)\big]\,\Delta x\]

The trapezoidal sum is the middle of this range, so it is within \(\frac12(R_n-L_n)\) of the integral. Doubling \(n\) halves the range. For a decreasing \(f\), exchange \(L_n\) and \(R_n\). Likewise, if \(f\) is concave up or concave down, the integral lies between \(M_n\) and \(T_n\). Without such information about \(f\) between readings, a sum comes with no bound on its error.

Example 1

Build left and right endpoint sums

The function \(h\) is continuous on \([0,10]\), and the table gives selected values of \(h\). Use a left Riemann sum and a right Riemann sum with the four subintervals indicated by the table to approximate \(\displaystyle\int_0^{10} h(x)\,dx\). \[\begin{array}{c|ccccc} x & 0 & 2 & 3 & 7 & 10\\ \hline h(x) & 5 & 9 & 8 & 6 & 11\end{array}\]

Solution

The table cuts \([0,10]\) into subintervals of widths 2, 1, 4 and 3, which are not equal. The left sum multiplies the height at the left end of each subinterval, \(h(0)\) through \(h(7)\), by the width of that subinterval:

\[\begin{aligned}L_4&=\cy{5}\cdot\cg{2}+\cy{9}\cdot\cg{1}+\cy{8}\cdot\cg{4}+\cy{6}\cdot\cg{3}\\&=69\end{aligned}\]

The right sum uses the heights at the right ends, \(h(2)\) through \(h(10)\), with the same widths:

\[\begin{aligned}R_4&=\cy{9}\cdot\cg{2}+\cy{8}\cdot\cg{1}+\cy{6}\cdot\cg{4}+\cy{11}\cdot\cg{3}\\&=83\end{aligned}\]

Example 2

Build a midpoint sum

Let \(g(x)=\dfrac{30}{x+2}\). Use a midpoint Riemann sum with two subintervals of equal length to approximate \(\displaystyle\int_0^4 g(x)\,dx\).

Solution

The function \(g\) is continuous on \([0,4]\), because \(x+2\) is positive there. The two subintervals are \([0,2]\) and \([2,4]\), each of width 2, and their midpoints are 1 and 3. The heights are the values of \(g\) at the midpoints:

\[\begin{aligned}M_2&=\cg{2}\,\big[\cy{g(1)}+\cy{g(3)}\big]\\&=2\,(10+6)=32\end{aligned}\]

From a table, a midpoint sum likewise needs a reading at the middle of each subinterval, not at its ends.

Example 3

Use the trapezoidal rule

A canal is 28 meters wide and has vertical walls. At a distance of \(x\) meters from one wall, the water is \(D(x)\) meters deep, where \(D\) is continuous. The table gives selected values of \(D(x)\). Use a trapezoidal sum with the four subintervals indicated by the table to approximate \(\displaystyle\int_0^{28} D(x)\,dx\). \[\begin{array}{c|ccccc} x & 0 & 8 & 11 & 16 & 28\\ \hline D(x) & 1 & 4 & 6 & 4 & 1\end{array}\]

Solution

The table cuts \([0,28]\) into subintervals of widths 8, 3, 5 and 12, which are not equal. The area of each trapezoid is the average of its two depths times its own width:

\[\begin{aligned}T_4&=\frac{\cy{1}+\cy{4}}{2}\cdot\cg{8}+\frac{\cy{4}+\cy{6}}{2}\cdot\cg{3}\\&\quad+\frac{\cy{6}+\cy{4}}{2}\cdot\cg{5}+\frac{\cy{4}+\cy{1}}{2}\cdot\cg{12}\\&=20+15+25+30=90\end{aligned}\]

The integral is the area of a cross section of the water, so it is about 90 square meters.

Example 4

Determine the direction of error

Let \(f(x)=\cos\left(x^2\right)\). The left, right, midpoint and trapezoidal sums with four subintervals of equal width approximate \(\displaystyle\int_0^1 f(x)\,dx\). Which of these four sums are overestimates? Give a reason for your answer.

Solution

The function \(f\) is continuous for every \(x\). For \(0<x\le 1\), the number \(x^2\) is positive and at most 1, which is less than \(\frac{\pi}{2}\), so \(\sin\left(x^2\right)\) and \(\cos\left(x^2\right)\) are positive. The chain rule and the product rule give

\[\begin{aligned}f'(x)&=-2x\sin\left(x^2\right)\\f''(x)&=-2\sin\left(x^2\right)-4x^2\cos\left(x^2\right)\end{aligned}\]

Both derivatives are negative for \(0<x\le 1\). Because \(f'<0\), \(f\) is decreasing on \([0,1]\), so the left sum is an overestimate and the right sum is an underestimate. Because \(f''<0\), \(f'\) is decreasing, so \(f\) is concave down on \((0,1)\). The midpoint sum is therefore an overestimate and the trapezoidal sum an underestimate.

The overestimates are the left sum and the midpoint sum.

Example 5

Interpret a numerical integral in context

Water flows into a tank at the rate of \(w(t)\) liters per minute, where \(t\) is in minutes and \(w\) is increasing. The table gives selected values of \(w(t)\). Using correct units, explain the meaning of \(\displaystyle\int_0^{40} w(t)\,dt\). Approximate it with a trapezoidal sum on the subintervals of the table, and explain how far the approximation can be from the true value. \[\begin{array}{c|ccccc} t & 0 & 10 & 20 & 30 & 40\\ \hline w(t) & 12 & 15 & 19 & 24 & 30\end{array}\]

Solution

The integral is the amount of water, in liters, that flows into the tank from \(t=0\) to \(t=40\).

Each subinterval is 10 minutes wide, so the trapezoidal sum is

\[\begin{aligned}T_4&=\tfrac{\cg{10}}{2}\big[\cy{12}+2\,(\cy{15}+\cy{19}+\cy{24})\\&\qquad+\cy{30}\big]=790\end{aligned}\]

Because \(w\) is increasing, the left sum is too small and the right sum is too large:

\[\begin{aligned}L_4&=\cg{10}\,(\cy{12}+\cy{15}+\cy{19}+\cy{24})=700\\R_4&=\cg{10}\,(\cy{15}+\cy{19}+\cy{24}+\cy{30})=880\end{aligned}\]

The amount therefore lies between 700 and 880 liters. The trapezoidal sum is the middle of this range, so it is within 90 liters of the true amount. As a check, \(R_4-L_4=10\,(30-12)=180\). About 790 liters flow in, and the readings support no closer claim.

Each example is one of the five skills of topic 6.2 in Which & Why: AP Calculus.