Numerical Methods

Outline

Introduction

Linear
Equations

Interpolation

Numerical
Solutions

Computer
Measurement

      

Numerical Integration

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

\[ \begin{equation} I(f) = \int_{c}^{d} dx f(x). \end{equation} \]

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. \[ \begin{equation} \int_{c}^{d} dx \frac{\sin{x}}{x}. \end{equation} \]
  • 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:

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

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.

\[ \begin{equation} \int_{x_{1}}^{x_{n}} dx f(x) \approx \int_{x_{1}}^{x_{n}} dx I(x) \end{equation} \]

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)$:

\[ \begin{equation} \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) \end{equation} \] \[ \begin{equation} = \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]. \end{equation} \]

We can easily evaluate these integrals analytically and obtain

\[ \begin{equation}\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 . \end{equation} \]

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