Solution (source code)

= Solution

Repeated <integration by parts> in
$$
\frac1{k!}\int_a^x(x-\theta)^kf^{(k+1)}(\theta)\,d\theta
$$
produces the first $k+1$ terms of the <Taylor polynomial> and leaves $f(x)$, proving the <integral remainder in Taylor theorem>
$$
R(x)=\frac1{k!}\int_a^x(x-\theta)^kf^{(k+1)}(\theta)\,d\theta.
$$
Apply the linear functional $\lambda_k$ to this identity. It annihilates the Taylor polynomial, and commuting it with integration gives the <Peano kernel theorem>
$$
\lambda_k[f]=\frac1{k!}\int_a^b\lambda_k[(x-\theta)^+_k]f^{(k+1)}(\theta)\,d\theta.
$$

For the <midpoint quadrature rule> on $[0,1]$, $e[1]=e[x]=0$, so $k=1$. Its <Peano kernel> is
$$
K(\theta)=\int_0^1(x-\theta)_+\,dx-(1/2-\theta)_+
=\begin{cases}
\theta^2/2,&0\leq\theta\leq1/2,\\
(1-\theta)^2/2,&1/2\leq\theta\leq1.
\end{cases}
$$
For $f(x)=x^2$, the formula gives
$$
e[f]=\int_0^1K(\theta)f''(\theta)\,d\theta=2\int_0^1K(\theta)\,d\theta=\frac1{12},
$$
agreeing with $\int_0^1x^2dx-(1/2)^2=1/3-1/4$.