The error of the midpoint rule for quadrature Wikipedia says the midpoint formula for numerical integration has error of order $h^3 f''(\xi)$. I am trying to replicate this result.
I'm guessing that I want to use Lagrange's formulation of the remainder for Taylor series. Let $x_0=\frac{a+b}{2}$ (i.e. the midpoint). 
The midpoint method says $\int_a^b f(x)dx \approx (b-a)f(\frac{a+b}{2})$, so to get the error I find $(b-a) f(\frac{a+b}{2}) - \int_a^bf(x)dx$. If I expand this using Taylor's theorem I get:
$ \begin{aligned}
error & =(b-a) f(x_0) - \int_a^bf(x_0)+\frac{f'(\xi)(x-x_0)}{2}dx \\
& =\frac{f'(\xi)}{2}\int_a^b(x-x_0)dx \\
& =\frac{f'(\xi)}{2}\int_a^b(x-\frac{a+b}{2})dx \\
& = 0
\end{aligned}$
So apparently I have just proven that it has zero error? Any hints as to what I did wrong? (I realize that since wikipedia gives it in terms of $f''$ I probably want to take the expansion one level further to match them, but I don't understand why this doesn't work.)
 A: You are right that you need one more term in your Taylor series.  If you write $f(x)=f(x_0)+(x-x_0)f'(x_0)+(x-x_0)^2f''(\xi)/2$ and plug that into the midpoint method, the term in $f''$ will survive.  What you have done essentially shows that if $f$ is linear, the method is exact.
A: I guess you are more concerned with why you cannot take the $f'(\xi)$ out in this case. The other answers in right in saying that $\xi$ depends on $x$, but I think you can show that $g(x) = f(\xi(x))$ depends on $x$ continuously, and that's not the reason why you cannot take $f'(\xi)$ outside the integral. In fact, if you want to derive the remainder for the rectangular rule, you have to do this at some point. 
The main reason why your argument does not work is because the function $x - \frac{b + a}{2}$ is neither nonpositive nor nonnegative on the interval $[a, b]$, which makes it invalid to apply the mean value theorem for integrals. That's exactly why you can apply M.V.T for integrals for the quadratic term in the Taylor series. Hope this helps!
A: Well, i don't think you need to use any specific remainder for Taylor series, $O(h^n)$ would do as well.
The rule: $\int_a^{a+h} f(x)dx \approx hf(a+h/2).$
$$\begin{equation}
\int_a^{a+h} f(x)dx = hf(a) +h^2f'(a)/2 + h^3f''(a)/6 + \dots
\tag{1}\end{equation}$$
because $\int_a^a f(x)dx = 0.$
$$\begin{equation}
hf(a+h/2) = h\Big[f(a) + \frac{h}{2}f'(a) + \frac{h^2}{2^22!} f''(a) + \dots \Big].
\tag{2}\end{equation}$$
First term that differs is near $h^3$, so error is of order $O(h^3).$ Though, of course that's not an accurate answer. You need another approach to get an accurate one.
A: Let $m$ be the midpoint of the interval. Then in divided differences and Newton interpolation in $m,m,x$ one gets a quadratic polynomial
$$
p_2(t)=f(m)+f[m,m](t-m)+f[m,m,x](t-m)^2=f(m)+f'(m)(t-m)+f[m,m,x](t-m)^2
$$
which is exact at the interpolation point $t=x$,
$$
f(x)=p_2(x)=f(m)+f'(m)(x-m)+f[m,m,x](x-m)^2.
$$
Inserting into the integral the second, linear term cancels and it remains
$$
\int_a^b f(x)\,dx = f(m)(b-a)+f[m,m,c]\int_a^b (x-m)^2\,dx,
$$
the last via the mean value theorem of integration. Then using $f[m,m,c]=\frac12f''(\eta)$ one gets the error formula
$$
f(m)(b-a)-\int_a^b f(x)\,dx=-\frac12 f''(\eta)·\frac{(b-a)^3}{12}.
$$
