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.
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,
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
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
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.
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,
If we apply the trapezoidal rule to the example previously, we use the endpoints of the interval to find
The trapezoid rule is depicted in the figure to the right.
Simpson's 1/3 Rule
Summary of Common Quadrature Formulas
|Simpson's 1/3 Rule
Composite Rules: Quadrature