Integration

$$ \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}$.

$$ \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*} $$$$ \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$.

$$ \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).

$$ \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

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

Trapezoidal Rule

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

Simpson’s Rule

$$ \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:
$$ \begin{equation*} I_g (f) = \int\limits_{−1}^{1} f (x) g(x) \, \mathrm{d}x, \end{equation*} $$$$ \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.

$$ \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*} $$