6.2: Numeric Integration Techniques
This process of finding the area underneath a curve is used for a lot more than finding how much dirt needs to be hauled away — in fact, it’s vital to many physics, engineering problems, and it even crops up in environmental science and biology problems. Let’s do some more examples to get a feel for how it works, and to introduce the notation for it.
Given a function \(f(x)\), the area under the curve from \(x = a\) to \(x = b\) looks something like this:
This area is denoted by mathematicians as
\(\int_a^b f(x)dx.\)
Here, the \(a\) and \(b\) indicate the left and right boundaries of the area we are interested in. The \(\int\) and the \(dx\) you can think of as just part of the notation for now, though they relate to how mathematicians write finite sums (with the integral being a sort of infinite sum). Sometimes this is called a definite integral to separate it from an indefinite integral. A definite integral is an area under a curve, and indefinite integral is an anti-derivative.
A weird quirk of definite integrals as area is that sometimes the area goes negative! This happens whenever the function drops below the \(x\)-axis.
Here are some examples.
First, if we graph this function, we see it looks something like (not to scale)
We will approximate the area in this case with five rectangles:
This is called the “right rectangle rule”, since it is the top right of the rectangles that match the height of the function.
We just need to find the areas of these rectangles, add them up, and be done. We see the width of each rectangle is \(2\), since the distance from \(a\) to \(b\) is \(10\), and there are \(5\) rectangles. The heights can be found by plugging in \(x = 6, 8, 10, 12, 14\) into the function. We see the heights are \(2.25 + 4 + 6.25 + 9 + 12.25 = 33.75\).
List of numeric integration formulas
We can write a formula for approximating with \(n\) rectangles or other shapes. Let \(\Delta x\) be the width of the shapes, and \(x_0 = a\), \(x_1\), \(x_2\), \(x_3\), \(\ldots\), \(x_{n-1}\), \(x_n = b\) be the values along the \(x\) axis. It looks like the following for \(n = 4\):
What follows are various methods for approximating the area. First, there are three rectangle-based approximations:
\(n\) left rectangle approximation = \(\Delta x( f(x_0) + f(x_1) + f(x_2) + \cdots + f(x_{n-1}))\)
\(n\) right rectangle approximation = \(\Delta x( f(x_1) + f(x_2) + f(x_3) + \cdots + f(x_{n}))\)
\(n\) midpoint rectangle approximation = \(\Delta x\left( f\left( \frac{x_0 + x_1}{2} \right) + \cdots + f\left( \frac{x_{n-1} + x_n}{2} \right) \right)\)
If we instead use trapezoids to approximate the area, which is more accurate, we get this formula
\(n\) trapezoid approximation = \(\frac{\Delta x}{2}( f(x_0) + 2 f(x_1) + 2 f(x_2) + \cdots + 2 f(x_{n-1}) + f(x_n))\)
Finally, if \(n\) is even, then we can approximate with quadratic curves, which is more accurate yet. We have
Simpson’s rule = \(\frac{\Delta x}{3}( f(x_0) + 4 f(x_1) + 2 f(x_2) + 4 f(x_3) + \cdots + 2 f(x_{n-2}) + 4 f(x_{n-1}) + f(x_n))\)
Here is an example.
If \(n = 4\), then we will need to know \(f(x_0)\), \(f(x_1)\), \(f(x_2)\), \(f(x_3)\), and \(f(x_4)\). The five points \(x_0, \ldots, x_4\) are evenly spaced on the interval from \(0\) to \(8\). To find the spacing, we take \(\Delta x = \frac{b - a}{n} = \frac{8 - 0}{4} = 2\). This makes \(\Delta x = 2\), and hence \(x_0 = 0\), \(x_1 = 2\), \(x_2 = 4\), \(x_3 = 6\), and \(x_4 = 8\). We can then compute each \(f\) value. For example, \(f(x_3) = f(6) = \frac{1}{6 + 1} = \frac{1}{7}\). The other \(f\) values are
\(f(x_0) = 1, \quad f(x_1) = \frac{1}{3}, \quad f(x_2) = \frac{1}{5}, \quad f(x_3) = \frac{1}{7}, \quad f(x_4) = \frac{1}{9}.\)
Now we just have to use the various formulas. Using rectangles, we have
\[\begin{align*} \int_0^8 \frac{1}{x+1}& \approx \Delta x( f(x_0) + f(x_1) + f(x_2) + f(x_3)) \\ & = 2\left( 1 + \frac{1}{3} + \frac{1}{5} + \frac{1}{7} \right) \\ & = 2 \left( \frac{176}{105} \right) \\ & = \frac{352}{105} \approx \boxed{3.35} \end{align*}\]
By the way, please use a calculator to help with these calculations — they are very tedious to do by hand!
Using trapezoids, we have
\[\begin{align*} \int_0^8 \frac{1}{x+1}& \approx \frac{\Delta x}{2}( f(x_0) + 2 f(x_1) + 2 f(x_2) + 2 f(x_3) + f(x_4)) \\ & = \frac{2}{2} \left( 1 + \frac{2}{3} + \frac{2}{5} + \frac{2}{7} + \frac{1}{9} \right) \\ & = 1 \left( \frac{776}{315} \right) \\ & = \frac{776}{315} \approx \boxed{2.46} \end{align*}\]
Using Simpson’s rule (which approximates with parabolas),
\[\begin{align*} \int_0^8 \frac{1}{x+1}& \approx \frac{\Delta x}{3}( f(x_0) + 4 f(x_1) + 2 f(x_2) + 4 f(x_3) + f(x_4)) \\ & = \frac{2}{3} \left( 1 + \frac{4}{3} + \frac{2}{5} + \frac{4}{7} + \frac{1}{9} \right) \\ & = \frac{2}{3} \left( \frac{1076}{315} \right) \\ & = \frac{2152}{945} \approx \boxed{2.28} \end{align*}\]
(By the way, the exact value is \(\ln(9) \approx 2.20\))