Simpson's Rule in Numerical Integration I have a problem in proving that the simple Simpson’s rule  $$\int_a^b f(x) dx \approx \frac{(b − a)}6[ f (a) + 4 f \left(\frac{a + b}{2}\right) + f (b)]$$ 
is exact for all cubic polynomials.
I am a little bit confused about using the change of variable $$x = a + t (b − a)$$ for a general interval [a, b].
 A: If the change of variables bothers you, you don't really need it: it just makes some of the formulas somewhat simpler, because it means you can take $a=0$.
If $f(x) = c_0 + c_1 x + c_2 x^2 + c_3 x^3$, 
$$ \eqalign{\int_a^b f(x)\; dx &= \left. c_0 x + c_1 \frac{x^2}{2} + c_2 \frac{x^3}{3} + c_3 \frac{x^4}{4} \right|_{a}^b  \cr &= c_0 (b-a) + c_1 \frac{b^2-a^2}{2} + c_2 \frac{b^3 - a^3}{3} + c_3 \frac{b^4 - a^4}{4}}$$
$$ \eqalign{\frac{b-a}{6} &\left(f(a) + 4 f\left(\frac{a+b}{2}\right) + f(b)\right)\cr
&= \frac{b-a}{6}\left(6 c_0 + c_1 \left(a + 4\left(\frac{a+b}{2}\right)+b\right) + c_2 \left(a^2 + 4\left(\frac{a+b}{2}\right)^2+b^2\right) + c_3   \left(a^3 + 4\left(\frac{a+b}{2}\right)^3+b^3\right)  \right)}$$
Expand this all out and see that this is the same expression you got for
the integral.
A: The change of variable allows to replace the range $[a,b]$ by $[0,1]$, to simplify the notation. Then setting
$$g(t):=f(a+t(b-a)),$$
we have
$$\int_a^b f(x)\,dx=(b − a)\int_0^1 g(t)\,dt \approx (b − a)\frac16\left[ g(0) + 4 g \left(\frac12\right) + g(1)\right].$$

Now we can show that the relation holds exactly for all powers of $x$ up to third:
$$\int_0^1 dt=1=\frac16\left[ 1 + 4 \cdot 1+ 1\right],$$
$$\int_0^1 t\,dt=\frac12=\frac16\left[ 0+ 4\cdot  \frac12+ 1\right],$$
$$\int_0^1 t^2dt=\frac13=\frac16\left[ 0+ 4\cdot  \frac14+ 1\right],$$
$$\int_0^1 t^3dt=\frac14=\frac16\left[ 0+ 4\cdot  \frac18+ 1\right].$$
By linearity, it holds for all cubic polynomials.

By the same approach, it doesn't hold for $x^4$:
$$\int_0^1 t^4dt=\frac15\ne\frac16\left[ 0+ 4\cdot  \frac1{16}+ 1\right]$$
A: Here is an alternative approach:
The functions $I_1(f) = \int_a^b f(x) dx $ and 
$I_2(f) = \frac{(b − a)}6[ f (a) + 4 f \left(\frac{a + b}{2}\right) + f (b)]$ are linear,
so to check equality is is sufficient to check on a suitable basis.
A possible basis for $\mathbb{P}_3$ would be $b_k(x) = (x-a)^k$, with $k=0,1,2,3$. It is straightforward to check that
$I_1(b_0) = I_2(b_0)$ and for $k=1,2,3$ we have
$I_1(b_k) = (b-a)^{k+1} {1 \over k+1}$,
$I_2(b_k) = (b-a)^{k+1} {2^k+4 \over 3 \cdot 2^{k+1}}$, and these
are equal for $k=2,3,4$.
Addendum:
Something that used to bother me was that Simpson's rule was exact for cubics, but only used 3 points of $f$ to compute the integral. The
explanation is straightforward.
Let $z(x) = (x-a)(x-{a+b\over 2})(x-b)$ and note that $\int_a^b z(x)dx = 0$, and $z(a) = z({a+b \over 2}) = z(b)=0$, hence we always
have $\int_a^b f(x) dx = \int_a^b (f(x)+t z(x)) dx$ for any $t$,
and $f(x)+t z(x) = f(x)$ for $x \in \{a,{a+b\over 2}, b\}$. In
particular, we can pick $t$ such that $f+tz$ has degree 2 which is
completely defined by its behaviour at the points $a,{a+b\over 2}, b$.
A: Well, if you insist in a change of variable, I'd propose $x=\frac{a+b}{2}+\frac{b-a}{2}\,t$. With $g(t)=f\left(\frac{a+b}{2}+\frac{b-a}{2}\,t\right)$, you get
$$
   \int^b_af(x)\,dx=\frac{b-a}{2}\,\int^1_{-1}g(t)\,dt,
$$
while Simpson's rule for function $g$ becomes
$$\frac{1-(-1)}{6}\left[g(-1)+4\,g(0)+g(1)\right]=\frac{1}{3}\left[g(-1)+4\,g(0)+g(1)\right].$$
The advantage is: both the integral and Simpson's rule have value zero for odd powers of $t$ due to symmetry, meaning $g(0)=0$ and $g(-1)=-g(1)$, so you only have to check that they coincide for $g(t)=1$ and $g(t)=t^2$ (the odd power $g(t)=t^3$ you get for free). And that's very simple.
