Recursive scheme for trapezoidal rule I was supposed to derive the recursive scheme for the trapezoid rule. I know that this is the formula:
$$ T_m (f;P) = \frac{1}{2} T_{m-1}(f;P) + \cdots$$
Initialization:
$$ T_0 (f;P) = \frac{h}{2}(f(a) + f(h)) $$ 
I came across a sample solution: 
$$ T_m = C + h \sum\limits_{i=1}^{2^m -1} f(x_i) $$
$$ T_{m+1} = \frac{C}{2} + \frac{h}{2} \sum\limits_{i=1}^{2^{m+1} -1} f(x_i) $$
$$ T_m - 2T_{m+1} =  C + h \sum\limits_{i=1}^{2^m -1} f(x_i) - \frac{C}{2}2 -2h\sum\limits_{i=1}^{2^{m+1} -1} f(x_i) $$ (3)
$$ T_m - 2T_{m+1} = h \sum\limits_{i=1}^{2^m -1} f(a+(2i-1)h) $$ (4)
Firstly, I cant understand why we're calculating $$ T_m - 2T_{m+1} $$ while the original formula is different. How is this derived? Why do we write f(a+(2i-1)h?
Secondly, how is equation 3 changed to equation 4? If we subtract the h values, the Cs cancel out but shouldn't we get a -h value?
 A: You could simply put
$$
T_{m+1}=\frac12(T_m+M_m)
$$
where $M_m$ is the composite midpoint quadrature rule for the same step size. Then the two terms on the right side are both approximations of the integral, which makes it natural that you have to divide their sum by 2 to get another approximation of the integral.

More specifically, your last formula is wrong on two counts, you lost the minus sign, and the step size for the $x_i$ in $T_{m+1}$ is $\frac h2$, ... three counts, the sum over the odd-index points has to start at index $i=0$ so that $2i+1=1$ is the lowest index, ... no wait, four counts, in the formula before the point sequences are different in the first and second sum, one for step size $h$, the other for step size $\frac h2$, make the first the subsequence $x_{2i}$ of the second, ... so that in total
\begin{align}
T_m-2T_{m+1}
&=C + h \sum\limits_{i=1}^{2^m -1} f(x_{2i}) - 2\frac{C}{2} -2\frac h2\sum\limits_{i=1}^{2^{m+1} -1} f(x_i)
\\
&=-h\sum\limits_{i=0}^{2^m -1} f(x_{2i+1})
\\
&=-h\sum_{i=0}^{2^m-1}f(a+(i+\tfrac12)h)=-M_m
\end{align}
