How to prove the equation $\int_{a}^{b} f(x) \mathrm{d} x = \frac{b-a}{2}[f(a)+f(b)]-\frac{(b-a)^{3}}{12} f^{\prime \prime}(\eta)$? In numerical analysis, we know that the following equation is true:
$$\int_{a}^{b} f(x) \mathrm{d} x = \frac{b-a}{2}[f(a)+f(b)]-\frac{(b-a)^{3}}{12} f^{\prime \prime}(\eta), \quad \eta \in(a, b)$$
I wonder if there is any profound and concise way to prove this conclusion. It is better to use Taylor series to prove this conclusion.
 A: This is nothing but the Trapezoidal Rule with Error Formula, where $~-\frac{(b-a)^{3}}{12} f^{\prime \prime}(\eta)~$ is the error term $(a < η < b)$.
Derivation: Consider the integral $~\int^b_a f(x)~dx~.$ Divide the interval $~[a,b]~$ such that $~a=x_0,~x_1,~x_2,~\cdots,x_{n-1},~x_n=b~$ with spacing $~h~.$ For trapezoidal rule $~n=1~,$ i.e., in this case $~a=x_0,~b=x_1=x_0+h\implies h=b-a~.$
Let $~I~$ be the analytical integration and $~I_T~$ be the trapezoidal integration, then
$$I=I_T+~\text{error term} \implies \text{error term} =I-I_T~$$
Now by the first fundamental theorem of calculus,$$I=\int_a^bf(x)~dx=\int_{x_0}^{x_1}f(x)~dx=F(x_1)-F(x_0)=F(x_0+h)-F(x_0)$$where $F(x)$ is the anti-derivative of $f(x)$ i.e., $~F'(x)=f(x)~.$
Also from the trapezoidal rule, $$I_T=\int_a^bf(x)~dx=\dfrac {b-a}2\left[f(a)+f(b)\right]=\dfrac h2\left[f(x_0)+f(x_1)\right]=\dfrac h2\left[f(x_0)+f(x_0+h)\right]$$
Therefore, Error
$=\left[F(x_0+h)-F(x_0)\right]-\dfrac h2\left[f(x_0)+f(x_0+h)\right]$
$=\left\{hF'(x_0)+\dfrac{h^2}{2!}F''(x_0)+\dfrac{h^3}{3!}F'''(x_0)+\cdots\right\}-\dfrac h2\left\{2f(x_0)+hf'(x_0)++\dfrac{h^2}{2!}f''(x_0)++\dfrac{h^3}{3!}f'''(x_0)+\cdots\right\}~,~~\text{(using Taylor series expansion)}$
$=\left\{hf(x_0)+\dfrac{h^2}{2!}f'(x_0)+\dfrac{h^3}{3!}f''(x_0)+\cdots\right\}-\dfrac h2\left\{2f(x_0)+hf'(x_0)++\dfrac{h^2}{2!}f''(x_0)++\dfrac{h^3}{3!}f'''(x_0)+\cdots\right\}$
$=\left(\dfrac 13-\dfrac 12\right)\dfrac{h^3}{2}f''(x_0)+O(h^4)$
$=-\dfrac{h^3}{12}f''(x_0)~,~~\text{(neglecting the higher order)}$
$\approx-\dfrac{(b-a)^3}{12}f''(\eta), \quad \eta \in(a, b)$
Therefore $$I=\int_{a}^{b} f(x) \mathrm{d} x = \frac{b-a}{2}[f(a)+f(b)]-\frac{(b-a)^{3}}{12} f^{\prime \prime}(\eta), \quad \eta \in(a, b)$$
A: The link Trapezoid rule shows the error term is bounded but is a little unsatisfactory since it does not prove equality in this particular case.
Simplifying to the interval [0,1], If we assume $f$ is twice continuously differentiable on $[0,1]$ then, using integration by parts we can proceed thus,
\begin{aligned}
\int_0^1 f(x)~dx &= \Big[ \big(x-\tfrac{1}{2}\big) f(x) \Big]_0^1 - \int_0^1\big(x-\tfrac{1}{2}\big) f'(x) ~ dx \\
&=\frac{f(1)+f(0)}{2}-\Big[\big(\tfrac{1}{2}x^2-\tfrac{1}{2}x\big)f'(x)\Big]_0^1+\int_0^1 \big(\tfrac{1}{2}x^2-\tfrac{1}{2}x\big)f''(x)~dx \\
&= \frac{f(1)+f(0)}{2}+\int_0^1 \big(\tfrac{1}{2}x^2-\tfrac{1}{2}x\big)f''(x)~dx 
\end{aligned}
Now, $f''(x)$ is continious and therefore bounded, say $m \leqslant f’’(x) \leqslant M$.  The expression $\tfrac{1}{2}x^2-\tfrac{1}{2}x \leqslant 0 $ throughout $[0,1]$, and therefore
\begin{aligned}
M\int_0^1 \big(\tfrac{1}{2}x^2-\tfrac{1}{2}x \big)~dx \leqslant \int_0^1 \big(\tfrac{1}{2}x^2-\tfrac{1}{2}x \big)f’’(x) ~dx \leqslant m \int_0^1 \big(\tfrac{1}{2}x^2-\tfrac{1}{2}x \big)~dx.
\end{aligned}
where the inequalities can be taken as strict unless $f’’$ is constant.  This becomes,
\begin{aligned}
-\frac{M}{12} \leqslant \int_0^1 \big(\tfrac{1}{2}x^2-\tfrac{1}{2}x\big)f’’(x)~dx \leqslant -\frac{m}{12}
\end{aligned}
Moreover, being continuous, $f’’$ takes every value between $m$ and $M$ so there exists $\xi\in(0,1) ^1$ such that,
\begin{aligned}
\int_0^1 \big(\tfrac{1}{2}x^2-\tfrac{1}{2}x\big)f’’(x)~dx = -\frac{1}{12}f’’(\xi)
\end{aligned}
which completes the proof, that there exists $\xi\in(0,1)$ such that:
\begin{aligned}
\int_0^1 f(x) ~dx = \frac{f’’(0)+f’’(1)}{2} - \frac{1}{12} f''(\xi).
\end{aligned}
The result for the case $[a,b]$ can be derived through a change of variable.
Corrected to refer to $f’’$ consistently

Footnote: if $f’’$ is not constant we can choose $\xi$ in the interior of $[0,1]$ because the inequalities are then strict;  if $f’’$ is constant any point $\xi$ will serve.
