<s>[INST] Simpson Rule special case of Gauss quadrature Prove that the Simpson Rule for integrating the function $f$ on the interval $[a,b]$: $$I_2(f)=\frac{b-a}{6}(f(a)+4f(\frac{a+b}{2})+f(b))$$ is actually the Gauss quadrature for the weight $g=1$ and $3$ nodes.
I can not get why when we have $3$ nodes in the Gauss quadrature the nodes have to be the ones from the formula above! Can anyone give me some hints on how to prove this?
 [/INST] Start from the definition of a Gauss quadrature:
$$\int_{-1}^1 f(x)\ dx \approx \sum_{i=1}^3 g_i f(x_i).$$
We perform a change of variables to change the range of integration, so
$$\int_a^b f(x)\ dx = \frac{b-a}{2}\int_{-1}^1 f\left(\frac{b-a}{2}z+\frac{b+a}{2}\right)\ dz.$$
Apply gaussian quadrature to the new integral on the right.
$$\frac{b-a}{2}\int_{-1}^1 f\left(\frac{b-a}{2}z+\frac{b+a}{2}\right)\ dz \approx \frac{b-a}{2}\sum_{i=1}^3 g_i f\left(\frac{b-a}{2}z_i+\frac{b+a}{2}\right).$$
With a three-point quadrature, our points are $x_1 = a, x_2 = \frac{a+b}{2}, x_3 = b$. These correspond to $z_1 = -1, z_2 = 0, z_3 = 1$.
Plugging these in, we find
$$\begin{align*}
\int_a^b f(x)\ dx \approx \frac{b-a}{2}& \left[g_1 f\left(\frac{b-a}{2}\cdot -1
+ \frac{a+b}{2}\right)\right. \\
&+\left.g_2 f\left(\frac{b-a}{2}\cdot 0
+ \frac{a+b}{2}\right)\right. \\
&+ \left.g_3 f\left(\frac{b-a}{2}\cdot 1
+ \frac{a+b}{2}\right)\right].
\end{align*}$$
The right-hand side simplifies to $$\frac{b-a}{2}\left[ g_1 f(a) + g_2 f\left(\frac{a+b}{2}\right) + g_3 f(b)\right].$$
Now you can see the function arguments are in the right form, and now all you have to do is compute the weights, which is straightforward since $g(x) = 1$. You can use $g_i = \int_\alpha^\beta g(x) \prod_{\substack{1 \le j \le 3 \\ j \neq i}} \frac{x-x_j}{x_i-x_j}\ dx$. But note that we've already done the change of variables to shift $[a,b]$ to $[-1,1]$ in the quadrature, so $\alpha = -1$ and $\beta = 1$. It is very straightforward to compute the integrals.
For $g_1$, we have
$$g_1 = \int_{-1}^1 \frac{x-0}{-1-0}\cdot \frac{x-1}{-1 - 1}\ dx = \frac12\left[\left.\frac{x^3}{3}\right|_{-1}^1 - \left.\frac{x^2}{2}\right|_{-1}^1\right] = \frac12\left[\frac13+\frac13-\left(\frac12-\frac12\right)\right] = \frac13.$$
You should find that $g_2$ and $g_3$ are similar. The result follows.
</s>