====== Quadrature ====== Quadrature is the numerical approximation of definite integrals of functions evaluated at discrete gridpoints. There are many, many quadrature formulae. We will start with the Trapezoid Rule and Simpson's Rule. In both cases we will assume we have an evenly spaced set of $N+1$ gridpoints $\{x_i, i=0,\ldots,N\}$ on the interval $[a,b]$, with $x_0 = a$, $x_n = b$, and $x_i = x_0 + i h$, where $h = (b-a)/N$ is the gridspacing. We also assume we know the value of the function evaluated at the gridpoints, i.e. we have a vector of values $\{y_i = f(x_i), i=0,\ldots,N\}$. ==== Trapezoid Rule==== The Trapezoid rule approximates the definite integral of $f(x)$ over $[a,b]$ using piecewise linear interpolation between each pair of datapoints. \begin{equation*} \int_a^b f(x) \, dx = h \left( \frac{1}{2} y_0 + \sum_{i=1}^{N-1} y_i + \frac{1}{2} y_N\right) - \frac{b-a}{12} h^2 f''(c) \end{equation*} for some $c$ where $a