Quadrature is the numerical approximation of definite integrals of functions evaluated at discrete gridpoints.
There are many, many quadrature formulae. We will start with the Trapezoid Rule and Simpson's Rule.
In both cases we will assume we have an evenly spaced set of gridpoints
on the interval
, with
,
, and
, where
is the gridspacing. We also assume we know the value of the function evaluated at the gridpoints, i.e. we have a vector of values
.
The Trapezoid rule approximates the definite integral of over
using piecewise linear
interpolation between each pair of datapoints.
for some where
.
For we would have
Here we have collapsed the error term into .
Simpson's Rule pproximates the definite integral of over
using piecewise quadratic
interpolation between triplets of datapoints.
for some where
, and where
is the fourth derivative of
. Simpson's rule requires that
is even, so that the total number of gridpoints,
, is odd.
For example, for and
gridpoints, we have