Vous êtes sur la page 1sur 3

EMEM 440: Numerical Methods

20031

Numerical Integration
As was the case for differentiation, numerical methods are pursued for integration when we are presented either with functions for which we do not know the analytical result, or when we are dealing with discrete data sets. It so happens that it is much more likely to have an unknown integral than an unknown derivative, and indeed many very useful functions can only be integrated numerically (such as the Gaussian probability distribution function, elliptic integrals, the error function erf(x), etc.). The simplest numerical integration techniques borrow from the graphical concept of integration; that it represents the area under a curve. To be more precise, the integral of a function f(x) between the limits x = a and x = b represents the area between the curve and the x-axis over the stated domain. We emphasize between, because where the curve falls below the axis the area is negative. Therefore the simplest approach is to graph the function on a scaled grid or quadrille paper and count the number of spaces occupied. A smaller grid results in a more precise answer, exactly as we would expect (and entirely analogous to the concept of convergence in derivative approximations and ODEs). A very similar method is to split the curve into a number of strips or segments, each of which has an area equal to the width times the height, where the height is the actual function value at the center. Again, more precise results are obtained as more segments are used. Both of these approaches were used before the advent of computers and numerical computations as we now know them, since they were implemented by making hardcopy graphs and actual measurements. Indeed we often still conceive of such graphical notions to understand numerical integration techniques as implemented on the computer. The foregoing graphical methods are obviously limited in their precision because they are limited in their ability to represent curvatures in a function. Therefore more accurate methods must somehow account for the actual shape of the curve. The Newton-Cotes Integration Formulas do so by approximating an integral I as:
I =

f ( x )d x

f
a

( x )d x

(1)

Where fm(x) is an m-th order polynomial approximation to the actual function f(x). Polynomial functions are easily integrated, and can capture a fair amount of curvature, especially as the order m increases. The most common versions are the Trapezoidal Rule, which uses a first-order approximation (straight line segments); Simpsons 1/3 Rule, which uses a second-order approximation (parabolic segments), and Simpsons 3/8 Rule, which uses a third-order approximation (cubic segments). Consider the Trapezoidal Rule first, which approximates the integral I between x = [a,b] as shown in Figure 1. The shaded portion is the approximate area, and has the shape of a trapezoid (hence the name). The area of the trapezoid, and thus the approximate integral value, is easily determined as:

John D. Wellin

80312965.doc Page 1 of 3

1/5/2012

EMEM 440: Numerical Methods

20031

1 I 2 ( b a )[ f ( a ) + f ( b ) ]

(2)

The error of the approximate integral is the rest of the area between the curve and the axis which is not covered by the shaded portion. We obviously dont know what this error is in general, else we would know the exact integral to begin with. However it can be shown, by a theoretical analysis of interpolation, that the true error Etrue is:

Etr u e = 112 ( b a ) 3 f ( )

(3)

Where is some point in the interval x = [a,b]. The only practical information we can gain here is that the error is proportional to the interval width (b-a). Since this overall width is set by whatever problem we are considering, the only way to decrease the error overall is to split the total interval into a collection of smaller pieces. This is often referred to as a multiple application of the integration scheme. To do this we need only to generate a number of fiducial function values at a collection of points in between x = [a,b]. Lets assume that we will split the overall interval into n segments of equal size, thereby generating a set of discrete x values xi, from i = 0 (which corresponds to x = a), to i = n (which corresponds to x = b). We then apply the single trapezoidal rule (2) piece-by-piece to the individual segments, and add up the results:
n 1 I h f ( x0 ) + 2 f ( xi ) + f ( xn 2 i =1

(4)

Where h is the width of each segment, given by (b- a)/n. By (3), the error in each segment is proportional to h3. Since we add up n of these errors in calculating the total integral approximation to I, and since n is inversely proportional to h, the true error in the multiple application (4) is O(h2), or equivalently O(n -2). This is of lower order in h than that for the single application (3), but the segment width is ideally much smaller in (4) so it is still a better approximation. Thus we re-write the Trapezoidal Rule with error estimate as:
n 1 I Trap = h f ( x0 ) + 2 f ( xi ) + f ( xn ) + O( h 2 ) 2 i =1

(5)

Simpsons 1/3 Rule results when a second-order interpolating polynomial (a parabola) is used to approximate the function f(x), which requires three points to determine uniquely. Therefore the rule must be applied to two segments at a time. Lets assume once again that we have divided the overall interval into n equal segments, numbered from x0 to xn. Consider the first two segments as an example, which are delineated by the points x0, x1,
John D. Wellin 80312965.doc Page 2 of 3 1/5/2012

EMEM 440: Numerical Methods

20031

and x2. Note that we must be careful to select only even numbers for n with Simpsons 1/3 Rule. Interpolating a parabola between these three points and integrating, we get the following area for the first two segments, with error term:

I = h [ f ( x0 ) + 4 f ( x1 ) + f ( x2 ) ] 3

1 90

h5 f

(4)

( )

(6)

Where f (4)( ) indicates the fourth derivative of f(x) evaluated somewhere within the two segments. Again, it is the fact that the error is proportional to h5 that is of most practical interest. Applying the same idea to all pairs of segments and adding, we get the following for Simpsons 1/3 Rule overall:
I Simp
1/ 3

n 1 n 2 = h f ( x0 ) + 4 f ( xi ) + 2 f ( x j ) + f ( x n 3 i =1,3 ,5 j =2 ,4 ,6

) + O( h 4 )

(7)

Finally, Simpsons 3/8 Rule results when a third-order interpolating polynomial is used to approximate the function f(x), which requires four points to determine uniquely. Therefore the rule must be applied to three segments at a time. Lets assume once again that we have divided the overall interval into n equal segments, numbered from x0 to xn. Consider the first three segments as an example, which are delineated by the points x0, x1, x2, and x3. Interpolating between these four points and integrating, we get the following area for the first three segments, with error term:

I Simp 3 / 8 = 3h [ f ( x0 ) + 3 f ( x1 ) + 3 f ( x2 ) + f ( x3 ) ] 8

3 80

h5 f

(4)

( )

(8)

The error term is of the same order as that for Simpsons 1/3 Rule (6), but actually has a larger coefficient. Yet because more segments are used in each application of the 3/8 rule, it is still slightly more accurate overall, since fewer of these error terms are added together in arriving at the overall integral. Therefore the 3/8 rule is slightly better than the 1/3 rule, but not enough to generally warrant the additional work (we can no longer simply separate odd indices of x from even, as (7) does). It appears that Simpsons 3/8 Rule is rarely used except to fill in at the beginning or end of an application of Simpsons 1/3 Rule when an odd number of intervals exist, for whatever reason. Hence we will not explicitly note a multiple application version of (8) here.

A final note to all of these methods:


We have assumed throughout most of the derivations and discussions here that equal segment widths applied. When dealing with a given function f(x), we are free to select the segment divisions any way we choose, and so the choice of equal widths is a convenient one. However when dealing with discrete data points, we may not have the luxury of equal widths. In that case we could proceed with the Trapezoidal Rule with little modification, save only that we compute the result by integrating one segment at a timethe multiple application rule in (5) would not apply since h would not be uniform. None of the relationships for the Simpsons Rules would apply as written here.

John D. Wellin

80312965.doc Page 3 of 3

1/5/2012

Vous aimerez peut-être aussi