<<

Numerical Integration

Andrew Paul California State University Northridge

______

Often times there are cases where we wish to know the definite of a but the function does not have an analytical anti­derivative. However there is a way to approximate the integral by dividing the function into small intervals and approximating the . One common method taught is a where rectangles are used to approximate a definite integral. There are some functions that such methods do not approximate the integral well and have large amount of error. Such a case is when a functions has regions with large variation as well as regions with small variation. Error would be substantial if one were to use simple evenly spaced intervals for numerical approximation. An example would be a simple Riemann sum with large intervals; this would generate large that do not represent the desired area We use what is called adaptive , where the technique tries to predict the the amount of functional variance and alter the step size accordingly. The approximation from adaptive quadrature in addition to being efficient, are also within specified tolerances of error. Not only does adaptive quadrature reduce error, it allows us to predict an error estimate without having to rely on knowledge of higher derivatives of the function. While not without error, adaptive quadrature gives us a method by which to numerically approximate the definite integral of functions and so called bad behaved functions with better accuracy than other methods. Badly behaved functions do not have derivatives that lead to easily estimated areas. Conversely the larger the number of times the function can be differentiated, the more well­behaved it is.It should also be noted that this adaptive method works just as well as its non­adaptive counterparts at estimating so called well behaved function ______

What is Numerical Integration?

In numerical , numerical integration constitutes a broad family of for calculating the numerical value of a definite integral, and by extension, the term is also sometimes used to describe the numerical solution of differential equations. The basic problem considered by numerical integration is to compute an approximate solution to a definite integral. It is different from analytical integration in two ways: first it is an approximation and will not yield an exact answer; Error analysis is a very important aspect in numerical integration. Second it does not produce an with which to determine the area given any arbitrary bounds; it only produces a numerical value representing an approximation of area.

History of Numerical Integration

The beginnings of numerical integration have its roots in antiquity. A prime example of how ancient these methods are is the Greek quadrature of the circle by means of inscribed and circumscribed regular polygons. This process led to an upper bound and lower bound for the value Pi. These methods were used widely due to the lack of formal . The method of the sum of an infinitesimal area over a finite range was unknown until the sixteenth century when Newton formalized the concepts of what we know now know as calculus. The earliest forms of numerical integration are similar to that of the Greek method of inscribing regular polygons into curved functions. This process broken down was taking a known area and overlapping it with an unknown area to approximate the area of the unknown shape. One could improve accuracy by choosing a better fitting shape. Later methods decided to improve upon estimating area under a curve decided to use more polygons but smaller in area. Such an example is the use of rectangles evenly spaced under a curve to estimate the area. Even further improvements saw the use of trapezoids instead of rectangles to better fit the curvature of the function being analyzed. Today the best methods for numerical integration are known as quadrature methods that have a very small error.

Elements of Numerical Integration

If f(x) is a smooth well­behaved function, integrated over a small number of dimensions and the limits of integration are bounded, there are many methods of approximating the integral with arbitrary precision. We consider an indefinite integral: Numerical integration methods can generally be described as combining evaluations of the integrand to get an approximation to the integral. The integrand is evaluated at a finite set of points called integration points and a weighted sum of these values is used to approximate the integral. For instance if we use rectangles as our shape:

In this example the definite integral is thus approximated using areas of rectangles. The integration points and weights depend on the specific method used and the accuracy required from the approximation. An important part of the analysis of any numerical integration method is to study the behavior of the approximation error as a function of the number of integrand evaluations. A method which yields a small error for a small number of evaluations is usually considered superior. Reducing the number of evaluations of the integrand reduces the number of arithmetic operations involved, and therefore reduces the total round­off error. Also, each evaluation takes time, and the integrand may be arbitrarily complicated. Note that if one were to take an infinite number of divisions this would approach the analytical function (derived in calculus) representing the area under the curve. We do not do this in practice as an infinite number of divisions would require a prohibitively expensive amount of computing power is rarely ever needed to be exact.

An Easy Method of Numerical Integration: Trapezoid Rule

The Trapezoid Rule calls for the approximation of area under a curve by fitting trapezoids under the curve and regularly spaced intervals. This method is very common in beginning calculus courses used as a transition into analytical integration. The method uses the outputs of the function as the two legs of the trapezoid and the specified interval is the height. The area of a trapezoid is one half the height multiplied by the sum of the two bases:

This example uses only one trapezoid to estimate the area of the entire interval: It would be more advantageous to use more trapezoids of smaller height to better fit the curvature of the graph. As we increase the number of trapezoids by increasing the number of divisions in the interval, accuracy increases. As demonstrated, going from one interval to four seems to increase the amount of area covered.

As an example consider some function on the interval [0, 2] with only one trapezoid to estimate the area. The actual integral value will be shown

f(x) x^2 x^4 1/(x+1) sqrt(1+x^2) sin(x) e^x Actual 2.667 6.400 1.099 2.958 1.416 6.389 Trapezoid 4.000 16.000 1.333 3.326 0.909 8.389 Error 50.0% 150.0% 42.6% 12.4% 35.8% 31.3%

One Trapezoid does not approximate the function f(x) very well. Let's see what happens when we use two trapezoids of height 1 to estimate the area: f(x) x^2 x^4 1/(x+1) sqrt(1+x^2) sin(x) e^x Actual 2.667 6.400 1.099 2.958 1.416 6.389 Trapezoid 3.000 9.000 1.167 3.032 1.296 6.913 Error 12.5% 40.6% 6.2% 2.5% 8.5% 8.2%

Error for more trapezoids of smaller height is less than that of only one trapezoid covering the entire interval. We can increase the accuracy even further by dividing the interval further but such accuracy is not necessary after a certain number of division.

A Better Method of Numerical Integration: Adaptive Quadrature

Quadrature Methods (in this particular example ) are better than using any regular polygon inscribed in a function to approximate area under the curve. Composite formulas such as the previously discussed trapezoid method require the use of equally spaced nodes. This is inappropriate when integrating a function on an interval that contains both regions with large functional variation and regions with small functional variation. If approximation error is to be distributed regularly along the curve, that is to minimize the error present, a smaller step size is needed for the regions with large functional variation and larger step sizes for regions with small functional variation. We shall consider one of the algorithms of Quadrature called Gaussian

Quadrature. To carry out Gaussian Quadrature we choose the points for evaluation in an optimal rather than equally­spaced way. An n­point Gaussian quadrature rule, named after Carl Friedrich Gauss, is a quadrature rule constructed to yield an exact result for of degree 2n ­ 1 or less by a suitable choice of

the points xi and weights wi for i = 1,...,n. The domain of integration for such a rule is conventionally taken as [­1, 1], so the rule is stated as

Some low­order rules for solving the integration problem are listed below.

Why Integrate Numerically rather than Analytically?

There are several reasons for carrying out numerical integration. The integral of f(x) may be known only at certain points, such as obtained by sampling. Some embedded systems and other computer applications may need numerical integration for this reason.

Another case when numerical integration is preferred over analytical is when a formula for the integral may be known, but it may be difficult or impossible to find an anti­derivative which is an elementary function. An example of such an integral is f(x) = exp(−x2), the anti derivative of which cannot be written in elementary form:

This function has many uses in the field of probability and statistics in describing data sets. This particular integral of this function represents what is known as the . Its anti­ derivative cannot be expressed in elementary function so statisticians must integrate numerically to find probabilities.

It may be possible to find an anti­derivative symbolically, but it may be easier to compute a numerical approximation than to compute the anti­derivative. That may be the case if the anti­ derivative is given as an infinite series or product, or if its evaluation requires a special function which is not available.

Multiple with numerical integration

The previous techniques discussed can be modified in a straightforward manner for use in the approximation of multiple integrals. The idea behind this is simply an extension of another dimension. We used regular polygons such as triangles and rectangles to estimate the value of area in two dimension; We use regular polygons with three dimensions, such as rectangular prisms, to estimate volume in three dimensional space.

The procedure for multiple integrals is similar to that one a single integral. Instead of approximating area the procedure will approximate a volume. Works Cited

Rubenstein, Reuven Y. Simulation and the Copyright 1981 by John Wiley and Sons, Inc.

Davis, Philip J. and Rabinowitz, Philip Methods of Numerical Integration, Second Edition

Copyright 1984 by Academic Press Inc. Orlando Fld.

Wang, Richard L.C. and Linz, Peter Exploring Numerical Methods Copyright 2003 by Jones and Barlett Publishers, Inc.

Burden, Richard L. and Faires, J. Douglas , 8th Edition Copyright 2005 by

Thomson Brooks/Cole

Online Article http://en.wikipedia.org/wiki/Numerical_integration

Online Article http://en.wikipedia.org/wiki/Gaussian_Quadrature