Numerical Integration

The topic of this module is the discretization of the definite integral. How does one approximate the definite integral of a function which does not have an easily computable anti-derivative? The answer is with finite sums, which is the discrete analog of the definite integral.

Recall that one interpretation for the definite integral is area under the curve. The goal is to find a finite sum which approximates the area under the curve. There are three common techniques for making this approximation: Riemann sums, trapezoid rule, and Simpson's rule. Each gives an approximation of the integral .

Another way to think about this problem (and the practical applications) is to consider some sporadic sample points, thought of as a sequence

Corresponding to these sample points is the sequence of function values

where . The goal is to approximate the definite integral of the underlying function using these function values. Of course, in real world applications the function may not be continuous, let alone a familiar function with an easily computed anti-derivative. The method of numerical integration gives an approximation of the definite integral in this situation with imperfect information.


Consider the problem of estimating the number of people who pass through a certain busy subway station each day. One could sit in the station for the entire day and count every person, or one could get an estimate by going in periodically and counting the number of people who come in over a short time.

This gives a sampling of the rate of passengers entering the station at different times:

The definite integral of the rate of passenger arrival gives the total number of passengers using the station that day:

Riemann Sums

The most rudimentary approximation is given by Riemann sums, which should be familiar from the definition of the definite integral.

The left Riemann sum uses the left endpoint of the th subinterval as the sample point to compute the height of the the th rectangle:

Thus, the area of the th rectangle is. So the left Riemann sum is given by

The right Riemann sum uses the right endpoint of the th subinterval to compute the height of the th rectangle:

In this case, the area of the th rectangle is . So the right Riemann sum is given by

An improvement on the left and right Riemann sums, called the trapezoid rule, is given in the next section.

Trapezoid rule

The trapezoid rule uses trapezoids instead of rectangles to approximate the area above each subinterval:

Recall that the area of a trapezoid with bases (parallel segments) of length and , with height has area . The area of the th trapezoid, then, is . Thus, the trapezoid rule gives the approximation:

If the sample points are evenly spaced uniformly, then the formula for the trapezoid rule simply becomes

where is the width of each trapezoid. Note that the trapezoid rule is the average of the left and right Riemann sums.

Simpson's rule

Think about how the previous approximations interpolate the function . The Riemann sum is a piece-wise constant approximation (also called a step function). The trapezoid rule is a piece-wise linear approximation. The logical next step is to use piece-wise quadratic approximations. That is how Simpson's rule works. Another way to think of it is that Simpson's rule will compute the area under a parabola exactly (whereas Riemann sums and trapezoid rule will have errors in general).

One way that Simpson's rule differs from the above rules is that the sample points must be evenly spaced. Let be the distance between sample points. The Simpson's rule approximation is given by

Here, must be even.


This derivation is a little bit different from the one in lecture, and perhaps more elementary.

The idea of Simpson's rule is to fit a parabola to the first three points , , , and then find the area under that parabola. Then, fit a parabola to the next three points (overlapping the endpoints) , , , find the area under that parabola, and so on.

Consider the parabola determined by the points . Solving the resulting system of equations

gives the parabola which fits these points. One finds that

And so the area

by using symmetry. Plugging in the earlier values for and and simplifying gives

Carrying this out for all each triplet of points gives the approximation

as desired.


Approximate the definite integral with using (uniformly spaced) right and left Riemann sums; trapezoid rule; and Simpson's rule. Here is a table of pertinent values to make the computation easier:


Let , , , and be the respective approximations. Then

Note that the true value is

so Simpson's rule gets the answer exactly and the trapezoid rule is the next closest.

Errors bounds

With any approximation, it is good to get some idea of how far off the approximation is from the true value. Let be the error using the trapezoidal rule, and be the error from using Simpson's rule.

Using advanced calculus beyond the scope of this course, one can bound these errors as follows.

where is the maximum value of on the interval .

where is the maximum value of on the interval .


  • Using the fact that , approximate using the right Riemann sum with number of intervals.