**Numerical integration** (*quadrature*) is a way to find an approximate numerical solution for a definite integral. You use this method when an analytic solution is impossible or infeasible, or when dealing with data from tables (as opposed to functions). In other words, you use it to evaluate integrals which can’t be integrated exactly. The goal of numerical quadrature is to approximate the function accurately with the minimum number of evaluations.

For a function of one independent variable (e.g. *x*), it replaces the definite integral with a summation, allowing for many “tricky” integration problems, including those with complicated boundaries over higher dimensional spaces, to be integrated. The method is also a building block for the numerical treatment of differential equations.

## How Numerical Quadrature Works

Usually, numerical quadrature uses weighted averages to approximate the integral. The general idea is that you replace the definite integral

With a weighted sum of a finite number of values from the integrand function

In general, a = x_{0} and b = x_{n}.

This leads to an approximate answer. How accurate the answer is depends on how many sample points are chosen, and how those contributions are weighted.

## Numerical Quadrature Rules

The following numerical quadrature rules are for single intervals:

The trapezoid rule averages the left- and right-hand values from Riemann sums.

Simpson’s rule is an extremely accurate approximation method (probably the most accurate from the Riemann sums options). Instead of rectangles or trapezoids, this numerical quadrature method uses a parabola. A variant is *Simpson’s 3/8ths Rule*, which uses a slightly different formula.

The Midpoint Rule uses the midpoint of the left-hand and right-hand rectangles.

**Open Newton-Cotes formulas** are useful when integrand values are given for equally spaced points. In general though, this method is less accurate than other methods (like Gaussian quadrature). The basic steps are:

- Divide a function into equal parts over an interval [a, b],
- Find polynomials that approximate the function (using a technique called
*Lagrange interpolating polynomials*).

Newton-Cotes formulas can be closed (uses all points) or open (all points except values at the endpoints). The following image shows the closed Newton-Cotes formulas. The **degree of accuracy** is the largest positive integer that gives and exact value for x^{k}, for every k-value:

## Simple Numerical Integration with Shapes

A very simple form of numerical integration involves using a **square grid **to find an area. Just superimpose a square grid under a curve, then count the number of squares. If you use relatively small squares, you can get a very good approximation for many functions. If you only need a rough approximation, and aren’t worried about getting an exact answer, this easy method might fit the bill.

Many variations on the basic method exist. For example, you could choose to count full squares only, or approximate the areas of partially filled squares, perhaps counting each partially filled square as one half of a full square.

## Riemann Sums, Midpoint, Simpson’s & Trapezoid Rules

Riemann sums (including the midpoint rule, Simpson’s rule, and trapezoid rules) are similar to the “squares” method outlined above, except that they use rectangles instead of squares.

Of this particular set of procedures, Simpson’s rule is quite accurate, and even gives the

*exact*area for any polynomial of third degree or less. For a more detailed explanation of these methods, including step-by-step examples, see the main article on Riemann sums.

## Gaussian Quadrature

**Gaussian quadrature** gives exact solutions for a polynomial of degree not higher than 2n – 1. The basic idea is that you use a Gaussian curve as the superimposing shape, instead of rectangles or a trapezoid.

## References

Abramowitz, M. and Stegun, I. A. (Eds.). “Integration.” §25.4 in Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, 9th printing. New York: Dover, pp. 885-887, 1972.

Corbit, D. “Numerical Integration: From Trapezoids to RMS: Object-Oriented Numerical Integration.” Dr. Dobb’s J., No. 252, 117-120, Oct. 1996.

Hildebrand, F. B. Introduction to Numerical Analysis. New York: McGraw-Hill, pp. 160-161, 1956.

(2013). Numerical Quadrature. Retrieved January 22, 2020 from: https://www2.math.ethz.ch/education/bachelor/lectures/fs2013/other/nm_pc/Ch07.pdf

**Need help with a homework or test question? **With Chegg Study, you can get step-by-step solutions to your questions from an expert in the field. Your first 30 minutes with a Chegg tutor is free!