 ## Numerical Integration

J. C. Daly Figure 1   The integral is the area under the curve. Figure 2   The rectangular area approximates the integral. Figure 3   The area of the trapazoid approximates the integral. Figure 4   More accuracy is achieved by representing the function by a quadratic. The area under the quadratic approximates the integral. This is Simpson's rule.
Numerical integration is necessary when an analytic function for data is unknown or when the function can not be integrated analytically.

An approximation for the integral can be found by dividing the x axis into small intervals. The integral of the function over a larger interval is the sum of the integrals of the function over each of the small intervals. Consider the function shown in Figures 1 through 4. The x axis has been divided into intervals.The interval from x = a to x = b is one of these.

Riemann Sums

If a function is approximated as a constant, the integral is given by, where The integral is approximated by a rectangular area. z can be any point in the interval. In Figure 2, z = b.

When the interval is divided into many smaller intervals the integral over the interval is the sum of the integrals over each of the smaller intervals. When each of these smaller integrals is represented by a rectangle, the sum is called the Riemann sum.

The error in representing the integral by the Riemann sum is less than, where f (1) is the maximum value of the first derivative over the interval and n is the number of divisions of the interval (a ,b).

Trapazoidal Approximation

If the function is represented as a linear function over the interval the integral is the area of a trapazoid as shown in Figure 3. Accuracy is increases by dividing the interval into smaller intervals and adding the intgrals over each of the smaller intervals. When this is done the error is less than, where f (2) is the maximum value of the second derivative over the interval and n is the number of divisions of the interval (a ,b).

Note that the error decreases inversely as the square of the number of divisions. If the number of points is doubled, the error decreases by a factor of 4.

If the function is represented by a quadratic function over the interval, the error is reduced further, Three points are required to form a quadratic function. Figure 4 shows a function represented by a quadtatic over the interval. Since the quadratic has curvature a closer approximation is achieved and the error is less.

When a function is represented by a quadratic the the approximate integral is, The right hand side of the equation is the area under the approximate quadratic function.

When the interval is divided into n intervals and the integral is approximated by the sum of the intgrals over each small interval the like the other methods, the accuracy increases. The magnitude of the error is less than, where f (4) is the maximum value of the forth derivative over the interval and n is the number of divisions of the interval (a ,b).

If the maximum values of the derivatives are known, the number of points, n, required to achieve an acceptable error can be calculated. If the derivatives are not known, it is usually possible to reduce the error to an acceptable value by using the trapazoidal method and increasing the number of points until the change in the computed value of the integral is less than the required error limit.

Wikipedia has information on numerical integration.