Numerical Integration

From Sutherland_wiki
Jump to: navigation, search


Numeric integration is used in two general situations:

  • we have discrete data and want to integrate it.
  • we have an analytic function that we cannot integrate analytically and want to approximate it numerically.

There are many ways to perform numerical integration. We will consider a few here. These are all based on fitting a polynomial function to data and then using what we know about polynomials to obtain the integral.

Midpoint Rule

Schematic illustration of the midpoint rule. The integral is approximated by a rectangle with the height evaluated at (a+b)/2.

The midpoint rule approximates the integral of a function over some interval [a,b] by a constant. The best choice for the constant value in general will be the function value at the midopoint, (a+b)/2. In other words,

\int_{a}^{b} f(x) \mathrm{d}x \approx (b-a) f\left(\frac{b+a}{2}\right)

This is shown pictorially in the figure to the right.


Assume that the following flowrate measurements were taken for a river over a 5-day period.

Day 1 2 3 4 5
Flowrate (CFS) 10000 12000 15000 13500 14400

Here the units of flowrate are in cubic feet per second. To get the units consistent, let's convert this into cubic feet per day by multiplying by the number of seconds per day. Then our data becomes

Day 1 2 3 4 5
Flowrate (ft3/day) 8.64x108 1.049 1.30x109 1.17x109 1.24x109
Application of the midpoint rule to approximate the total volume of fluid over days 1-5.

We want to estimate the total volume of water that flowed through the river over this 5-day period. To do this, we could use the flowrate on day 3 (which is the midpoint of the time period) to find

\mathrm{Total \; volume} \approx (5-1) \cdot f(3) = 4 \cdot 1.04\times 10^9 = 5.18\times 10^{9} \mathrm{ft}^3

The figure to the right shows this pictorially. However, we can see that the midpoint rule significantly overestimates the total volume (e.g. the integral) since day 3 happened to be the day where the flowrate was highest.

NOTE: the midpoint rule is not always useful for application to discrete data. This is because often the data is not really available at a "midpoint." Therefore, the trapezoid rule is most often used when discrete data needs to be integrated.

Trapezoid Rule

Schematic of the trapezoid rule, where the function is approximated by a linear function.

The trapezoid rule uses a linear approximation of the function over the interval [a,b], as shown in the figure to the right. The integral of this is the area of the trapezoid,

\int_{a}^{b} \approx \frac{b-a}{2} \left[ f(a)+f(b) \right]


The trapezoid rule used to approximate the total volume over days 1-5

If we apply the trapezoidal rule to the example previously, we use the endpoints of the interval to find

\mathrm{Total \; volume} \approx \frac{5-1}{2} \left[ f(1) + f(5) \right] = 2 \cdot \left[ 8.64\times 10^{8} + 1.24\times 10^{9} \right] = 4.22\times 10^{9} \; \mathrm{ft}^3

The trapezoid rule is depicted in the figure to the right.

Simpson's 1/3 Rule

This section is a stub and needs to be expanded.
If you can provide information or finish this section you're welcome to do so and then remove this message afterwards.


Summary of Common Quadrature Formulas

Name Formula Comments
Midpoint Rule \int_{a}^{b} f(x) \mathrm{d} x \approx (b-a) f\left(\tfrac{b+a}{2}\right)
  • Requires function values at interval midpoints f\left(\tfrac{b+a}{2}\right)
  • Requires equally spaced data.
Trapezoid Rule \int_{a}^{b} f(x) \mathrm{d} x \approx \tfrac{b-a}{2} \left[ f(b)+f(a) \right]
  • Can be applied to arbitrarily spaced data.
  • Convenient for tabulated data.
Simpson's 1/3 Rule \int_a^b f(x) \mathrm d x \approx \tfrac{\Delta x}{3} \left[ f(a) +4f\left(\tfrac{a+b}{2}\right) + f(b) \right]
  • Requires three equally spaced points on the interval [a,b]
  • On the interval [a,b], we have \Delta x = \tfrac{b-a}{2} and x_i = a + i \Delta x

Composite Rules: Quadrature

This section is a stub and needs to be expanded.
If you can provide information or finish this section you're welcome to do so and then remove this message afterwards.



Matlab Tools for Quadrature