Interactive Educational Modules in
Scientific Computing

Newton-Cotes Quadrature

This module compares three of the best known examples of Newton-Cotes quadrature rules — the midpoint, trapezoid, and Simpson rules — for approximating the integral of a function of one variable over a given interval.

The user selects one of the available functions f(x) and specifies an interval of integration. The function is plotted on the specified interval along with the polynomial interpolants corresponding to each of the three quadrature rules. The correct integral of the function over the interval as well as the approximate values of the integral given by each quadrature rule are displayed below.

Even though the midpoint rule uses the function value at only one point (the midpoint) in calculating its approximation, it frequently gives a better approximation to the integral than the trapezoid rule, which uses the function values at two points (the endpoints). Integrating well-behaved functions over sufficiently small intervals, we expect the midpoint rule to be about twice as accurate as the trapezoid rule. Simpson's rule combines the midpoint and trapezoid rules to obtain an approximation that is often remarkably good. It gives the exact integral when applied to polynomials of degree three or less.

Reference: Michael T. Heath, Scientific Computing, An Introductory Survey, 2nd edition, McGraw-Hill, New York, 2002. See Section 8.3.1, especially Example 8.2 and Figure 8.2.

Developers: Evan VanderZee and Michael Heath