Let $f\in C^2[a,b]$. An approximation of the integral over $[a,b]$ is given by $$I[f]:=\int_a^bf(x)\text{ dx}\approx \frac{b-a}{n}\sum_{i=1}^nf\left(a+\frac{i}{n}(b-a)\right)=:M_n[f]$$
I've spent a hard time trying to understand why it holds $$|I[f]-M_n[f]|\le \frac{(b-a)^3}{24n^2}\max_{x\in [a,b]}|f''(x)|$$ I would be deeply grateful if someone could explain this to me.
edit: rectangle rule shouldn't be (2i-1) or obviously 2n-1 would not exist
Without loss of generality, we consider an interval symmetric with respect to zero $[-t,t]$.
We look for a bound of $$\left|\int_{-t}^t f(x)\,dx-f(0)\cdot 2t \right|$$ Let $$I(t)=\int_{-t}^t f(x)\,dx $$ Taylor's theorem says that $$I(t)=I(0)+I'(0)t+I''(0)\frac {t^2}{2!}+I'''(c)\frac {t^3}{3!}$$ where $0<|c|<t$ .
Now $$\begin {align}I'(t)&=f(t)+f(-t) \\ I''(t)&=f'(t)-f'(-t) \\ I'''(t)&=f''(t)+f''(-t) \end {align} $$ and so $$I(t)=2f(0)t+(f''(c)+f''(-c))\frac {t^3}{3!}$$Then $$|I(t)-2f(0)t|\le 2\max |f''|\frac {t^3}{3!}$$ Choose $\,t=(b-a)/2n\,$ and see the above comment to conclude.