Integration

If $f \in C^{0} \left([a, b]\right)$, the quadrature error $E_{n}(f) = I(f) - I_{n}(f)$ satisfies

$$ \begin{equation*} \left| E_{n}(f) \right| \leq \int_{a}^{b} \left| f(x) - f_{n}(x) \right| \, \mathrm{d} x \leq (b-a) \left\| f - f_{n} \right\|_{\infty} \end{equation*} $$

Therefore, if for some $n$, $\left\| f - f_{n}\right\|_{\infty} < \varepsilon$ , then $\left|E_{n}(f)\right| \leq \varepsilon(b-a)$.

The approximation of the function $f_{n}$ must be easily integrable, which is the case if, for example, $f_{n} \in \mathbb{P}_{n}$.

In this respect, a natural approach consists of using $f_{n}=\Pi_{n} f$, the interpolating Lagrange polynomial of $f$ over a set of $n+1$ distinct nodes $\lbrace x_{i} \rbrace$, with $i=0, \ldots, n$. It follows that the approximation to the integral is

$$ \begin{equation*} I_{n}(f) = \sum_{i=0}^{n} f \left( x_{i} \right) \int_{a}^{b} l_{i}(x) \, \mathrm{d} x \end{equation*} $$

where $l_{i}$ is the characteristic Lagrange polynomial of degree $n$ associated with node $x_{i}$. It is called the Lagrange quadrature formula, and is a special instance of the following, generalised, quadrature formula

$$ \begin{equation*} I_{n}(f) = \sum \limits_{i=0}^{n} \alpha_{i} f\left( x_{i} \right) \end{equation*} $$

where the coefficients $\alpha_{i}$ of the linear combination are given by $\int_{a}^{b} l_{i} \left( x \right) \, \mathrm{d} x$. The above equation is a weighted sum of the values of $f$ at the points $x_{i}$, for $i=0, \ldots, n$. These points are said to be the nodes of the quadrature formula, while the $\alpha_{i} \in \mathbb{R}$ are its coefficients or weights. Both weights and nodes depend in general on $n$.

Another approximation of the function $f$ leads to the Hermite quadrature formula

$$ \begin{equation*} I_{n}(f)=\sum_{k=0}^{1} \sum_{i=0}^{n} \alpha_{i k} f^{(k)}\left(x_{i}\right) \end{equation*} $$

where the weights are now denoted by $\alpha_{i k}$. This depends on an evaluation of the function and its derivative.

Both the above are interpolatory quadrature formula, since the function $f$ has been replaced by its interpolating polynomial (Lagrange and Hermite polynomials, respectively).

Define the degree of exactness of a quadrature formula as the maximum integer $r \geq 0$ for which

$$ \begin{equation*} I_{n}(f)=I(f), \quad \forall f \in \mathbb{P}_{r} . \end{equation*} $$

Any interpolatory quadrature formula that makes use of $n+1$ distinct nodes has degree of exactness equal to at least $n$. Indeed, if $f \in \mathbb{P}_{n}$, then $\Pi_n f = f$ and thus $I_n\left( \Pi_n f \right) = I \left( \Pi_n f \right)$.

Midpoint Rule

The zero-th order approximation is given by

$$ \begin{equation*} I_0 = (b-a) f \left( \dfrac{a+b}{2} \right). \end{equation*} $$

Trapezoidal Rule

The trapezoidal rule is given by

$$ \begin{equation*} I_1 = \dfrac{b-a}{2} \left( f \left( a \right) + f \left(b\right) \right). \end{equation*} $$

Simpson’s Rule

Simpson’s rule is

$$ \begin{equation*} I_2 = \dfrac{b-a}{6} \left( f \left( a \right) + 4f\left(\dfrac{a+b}{2} \right)+ f \left(b\right) \right). \end{equation*} $$
Example:
An .ipynb notebook, detailing examples of the Midpoint rule, Trapezoidal rule, Simpson’s rule can be accessed online here. It can be downloaded from here as a python file or downloaded as a notebook from here.

Gaussian Integration

Gaussian quadrature integrates a function by a suitable choice of nodes and weights.

Theorem:

With the exact integral of $f$

$$ \begin{equation*} I_g (f) = \int\limits_{−1}^{1} f (x) g(x) \, \mathrm{d}x, \end{equation*} $$

being $f \in C^0 \left( [−1, 1] \right)$, consider quadrature rules of the type

$$ \begin{equation*} I_{n,g} (f) = \sum\limits_{i=0}^{n} \alpha_i f(x_i) \end{equation*} $$

where $\alpha_i$ are to be determined.

For a given $m > 0$, the quadrature $I_{n,g}$ has degree of exactness $d=n + m$ if and only if it is of interpolatory type and the nodal polynomial $\omega_{n+1}$ associated with the set of nodes $\lbrace x_i \rbrace$, is such that

$$ \begin{equation*} \int_{-1}^{1} \omega_{n+1}(x) p(x) g(x) \, \mathrm{d}x = 0, \quad \forall \, p \in \mathbb{P}_{m-1}. \end{equation*} $$