Scientific Computing

This module illustrates the cancellation of errors in odd-order
Newton-Cotes quadrature rules for approximating the integral of a
function of one variable over a given interval. An *n*-point
Newton-Cotes quadrature rule approximates the integral of a function
*f*(*x*)*a*,
*b*]*f*(*x*)*n* equally-spaced points with a polynomial of degree
*n* − 1*f*(*x*)*n*
− 1*n* or higher, in general, because the polynomial
interpolant is then no longer identical to the integrand
*f*(*x*)*n* is odd, however,
it turns out that an *n*-point Newton-Cotes quadrature rule is
exact when *f*(*x*)*n*. This module graphically illustrates why we obtain the
exact integral in this case despite the inexactness of the
interpolant.

The user selects the (odd) degree *n* for a polynomial
*f*(*x*)*Random Polynomial*
or *Symmetric Polynomial* to generate
*f*(*x*)*Edit Polynomial* to
enter or edit the coefficients for *f*(*x*)*f*(*x*)*f*(*x*)*n*-point
Newton-Cotes quadrature rule is based on. Areas that are included in
the integral of the interpolant but not in the integral of
*f*(*x*)*f*(*x*)*n* is odd, the blue and
pink regions are equal in area and opposite in sign and hence cancel,
giving the exact integral. When the polynomial is symmetric about the
midpoint of the interval, the blue and pink regions not only have equal
areas, they are geometrically congruent.

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

**Developers:** Evan VanderZee and Michael Heath