Difference between revisions of "Numerical Integration"
m (→Summary of Common Quadrature Formulas) |
m (fix a link) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Introduction == | == Introduction == | ||
+ | |||
+ | 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 == | == Midpoint Rule == | ||
+ | |||
+ | [[Image:MidpointRule.png|thumb|150px|right|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, | ||
+ | :<math>\int_{a}^{b} f(x) \mathrm{d}x \approx (b-a) f\left(\frac{b+a}{2}\right) </math> | ||
+ | This is shown pictorially in the figure to the right. | ||
+ | |||
=== Example === | === Example === | ||
+ | Assume that the following flowrate measurements were taken for a river over a 5-day period. | ||
+ | :{| border="1" cellpadding="3" cellspacing="0" style="text-align:center" | ||
+ | |- | ||
+ | ! 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 | ||
+ | :{| border="1" cellpadding="3" cellspacing="0" style="text-align:center" | ||
+ | ! Day | ||
+ | | 1 || 2 || 3 || 4 || 5 | ||
+ | |- | ||
+ | ! Flowrate (ft<sup>3</sup>/day) | ||
+ | | 8.64x10<sup>8</sup> || 1.04<sup>9</sup> || 1.30x10<sup>9</sup> || 1.17x10<sup>9</sup> || 1.24x10<sup>9</sup> | ||
+ | |} | ||
+ | |||
+ | [[Image:MidpointExample1.png|thumb|250px|right|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 | ||
+ | :<math>\mathrm{Total \; volume} \approx (5-1) \cdot f(3) = 4 \cdot 1.04\times 10^9 = 5.18\times 10^{9} \mathrm{ft}^3 </math> | ||
+ | |||
+ | 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 [[Numerical Integration#Trapezoid Rule|trapezoid rule]] is | ||
+ | most often used when discrete data needs to be integrated. | ||
== Trapezoid Rule == | == Trapezoid Rule == | ||
+ | |||
+ | [[Image:TrapezoidRule.png|thumb|150px|right|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, | ||
+ | :<math>\int_{a}^{b} \approx \frac{b-a}{2} \left[ f(a)+f(b) \right] </math> | ||
+ | |||
=== Example === | === Example === | ||
+ | [[Image:TrapezoidExample1.png|thumb|250px|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 | ||
+ | :<math>\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 </math> | ||
− | + | The trapezoid rule is depicted in the figure to the right. | |
== Simpson's 1/3 Rule == | == Simpson's 1/3 Rule == | ||
+ | {{Stub|section}} | ||
=== Example === | === Example === | ||
Line 53: | Line 118: | ||
== Composite Rules: Quadrature == | == Composite Rules: Quadrature == | ||
+ | {{Stub|section}} | ||
=== Algorithm === | === Algorithm === |
Latest revision as of 11:11, 23 August 2010
Contents
Introduction
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
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.
Example
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.
Trapezoid Rule
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,
Example
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
|
Example
Summary of Common Quadrature Formulas
Name | Formula | Comments |
---|---|---|
Midpoint Rule |
| |
Trapezoid Rule |
| |
Simpson's 1/3 Rule |
|
Composite Rules: Quadrature
|