56 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 [latex]f(x)[/latex], the area under the curve from [latex]x = a[/latex] to [latex]x = b[/latex] looks something like this:

This area is denoted by mathematicians as

[latex]\int_a^b f(x)dx.[/latex]

Here, the [latex]a[/latex] and [latex]b[/latex] indicate the left and right boundaries of the area we are interested in. The [latex]\int[/latex] and the [latex]dx[/latex] 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 [latex]x[/latex]-axis.

Here are some examples.

Riemann Sum I

Approximate [latex]\int_4^{14} \frac{1}{16}x^2dx[/latex] using five rectangles.

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 [latex]2[/latex], since the distance from [latex]a[/latex] to [latex]b[/latex] is [latex]10[/latex], and there are [latex]5[/latex] rectangles. The heights can be found by plugging in [latex]x = 6, 8, 10, 12, 14[/latex] into the function. We see the heights are [latex]36/16 = 2.25[/latex], [latex]64/16 = 4[/latex], [latex]100/16 = 6.25[/latex], [latex]144/16 = 9[/latex], and [latex]196/16 = 12.25[/latex]. Adding these up, we see the total area is [latex]2.25 + 4 + 6.25 + 9 + 12.25 = 33.75[/latex].

List of numeric integration formulas

We can write a formula for approximating with [latex]n[/latex] rectangles or other shapes. Let [latex]\Delta x[/latex] be the width of the shapes, and [latex]x_0 = a[/latex], [latex]x_1[/latex], [latex]x_2[/latex], [latex]x_3[/latex], [latex]\ldots[/latex], [latex]x_{n-1}[/latex], [latex]x_n = b[/latex] be the values along the [latex]x[/latex] axis. It looks like the following for [latex]n = 4[/latex]:

What follows are various methods for approximating the area. First, there are three rectangle-based approximations:

[latex]n[/latex] left rectangle approximation = [latex]\Delta x( f(x_0) + f(x_1) + f(x_2) + \cdots + f(x_{n-1}))[/latex]


[latex]n[/latex] right rectangle approximation = [latex]\Delta x( f(x_1) + f(x_2) + f(x_3) + \cdots + f(x_{n}))[/latex]


[latex]n[/latex] midpoint rectangle approximation = [latex]\Delta x\left( f\left( \frac{x_0 + x_1}{2} \right) + \cdots + f\left( \frac{x_{n-1} + x_n}{2} \right) \right)[/latex]


If we instead use trapezoids to approximate the area, which is more accurate, we get this formula

[latex]n[/latex] trapezoid approximation = [latex]\frac{\Delta x}{2}( f(x_0) + 2 f(x_1) + 2 f(x_2) + \cdots + 2 f(x_{n-1}) + f(x_n))[/latex]


Finally, if [latex]n[/latex] is even, then we can approximate with quadratic curves, which is more accurate yet. We have

Simpson’s rule = [latex]\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))[/latex]


Here is an example.

Numeric integration techniques example

Use left rectangles, trapezoids, and Simpson’s rule to approximate [latex]\int_{0}^8 \frac{1}{x + 1}[/latex]. In each case use [latex]n = 4[/latex].

If [latex]n = 4[/latex], then we will need to know [latex]f(x_0)[/latex], [latex]f(x_1)[/latex], [latex]f(x_2)[/latex], [latex]f(x_3)[/latex], and [latex]f(x_4)[/latex]. The five points [latex]x_0, \ldots, x_4[/latex] are evenly spaced on the interval from [latex]0[/latex] to [latex]8[/latex]. To find the spacing, we take [latex]\Delta x = \frac{b - a}{n} = \frac{8 - 0}{4} = 2[/latex]. This makes [latex]\Delta x = 2[/latex], and hence [latex]x_0 = 0[/latex], [latex]x_1 = 2[/latex], [latex]x_2 = 4[/latex], [latex]x_3 = 6[/latex], and [latex]x_4 = 8[/latex]. We can then compute each [latex]f[/latex] value. For example, [latex]f(x_3) = f(6) = \frac{1}{6 + 1} = \frac{1}{7}[/latex]. The other [latex]f[/latex] values are

[latex]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}.[/latex]

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 [latex]\ln(9) \approx 2.20[/latex])

License

Icon for the Creative Commons Attribution 4.0 International License

Informal Calculus Copyright © by Tyler Seacrest is licensed under a Creative Commons Attribution 4.0 International License, except where otherwise noted.

Share This Book