Numerical Methods

## Numerical Integration

In this chapter we treat the numerical evaluation of definite integrals,

$$$I(f) = \int_{c}^{d} dx f(x).$$$

Numerical methods are used when

• the integrand is known only point wise (e.g. tabulated). In this case it is recommended to fit an interpolation curve through the sampling points and to integrate it piecewise.
• the integrand is known in functional form, but the integral is not analytically integrable, e.g. $$$\int_{c}^{d} dx \frac{\sin{x}}{x}.$$$
• the integral is in principle analytically integrable but the analytic evaluation requires a disproportional amount of calculation time.

In the second and third case usually one employs quadrature formulas. They will be discussed in detail from chapter 6.2. onwards.

### Numerical integration of point wise integrands

Let us assume we know the function $f(x)$ to be integrated only on $n$ sampling points:

$$$[x_{i} \mid f(x_{i})] \qquad \mbox{for} \qquad i=1,\ldots,n.$$$

To simplify the problem we assume that the first and last sampling point $x_{1}$ and $x_{n}$ represent the integration limits. In this case we can replace $f(x)$ with the corresponding interpolation curve.

$$$\int_{x_{1}}^{x_{n}} dx f(x) \approx \int_{x_{1}}^{x_{n}} dx I(x)$$$

For a linear interpolation, the integral is the sum of the areas of trapezoids. The integration routine that sums the areas of these trapezoids is called the trapezoidal rule and is quite simple.

For a cubic spline, $I(x)$:

$$$\int_{x_{1}}^{x_{n}} dx f(x) \approx \int_{x_{1}}^{x_{n}} dx I(x) = \sum_{i=1}^{n-1} \int_{x_{i}}^{x_{i+1}} dx P^{i}(x)$$$ $$$= \sum_{i=1}^{n-1} \int_{x_{i}}^{x_{i+1}} dx \left[ a_{i} + b_{i}(x-x_{i})+c_{i}(x-x_{i})^{2}+d_{i}(x-x_{i})^{3} \right].$$$

We can easily evaluate these integrals analytically and obtain

$$$\label{qua1} \int_{x_{1}}^{x_{n}} dx f(x) \approx \sum_{i=1}^{n-1} \left[ a_{i}(x_{i+1}-x_{i}) +\frac{b_{i}}{2}(x_{i+1}-x_{i})^{2} + \frac{c_{i}}{3} (x_{i+1}-x_{i})^{3} + \frac{d_{i}}{4} (x_{i+1}-x_{i})^{4} \right] \quad .$$$

Using a cubic spline as the interpolation function results in Simpson's rule.