Numerical Integration#
Trapezoidal Rule#
Recall that the area of a trapezoid is the average length of the two sides multiplied by the width \(\Delta x\):
The trapezoidal rule approximates the integral of some function \(f(x)\) by summing the trapezoidal area of \(N-1\) slices. Each slice is made with a straight line boundary from \(x_n\) to \(x_{n+1}\)
The trapezoidal rule is the exact solution for the linear equation \(f(x) = mx\)
Simpson’s Rule#
The Simpson’s rule uses parabolic slices instead of linear slices
The Simpson’s rule is the exact solution for the 3rd degree polynomial \(f(x) = ax + bx^2 + cx^3\)
Improper Integrals#
Integrable Singularity
If from the interval \(a\) to \(b\), \(f(a) = \infty\)
Exponential Fall-off
An integral from \(a\) to \(\infty\) can be converted into an exponential integral by change of variables:
\[\begin{split} u = e^{-x} \qquad x = -\log u\\ \int_{a}^{\infty} f(x)\ \mathrm dx = \int_{0}^{e^{-a}} \frac{f(-\log u)}{u}\ du \end{split}\]