Trapezoid rule error analysis How can I prove that the max error of the trapezoid rule for the integral $\int_{a}^{b}{f(x)\, \mathrm{d}x} $ is: $$\Delta=-\frac{1}{12n^2}f''(c)(b-a)^3 \text{for } c \in (a,b) \ ?$$
I know that to obtain that result first you have to prove that $$\exists \;c \in (a,b); \int_{a}^{b}f(x)\,dx = \frac{b - a}{2}\{f(a) + f(b)\} - \frac{1}{12}f''(c)(b-a)^3$$ But I'm stuck here, I tried using the mean value theorem but got nowhere. Anyone got any ideas?
If it helps: $\forall x_0 \in (a,b) \;\exists\;\xi_0 \in (a,b);\; f(x_0) - p(x_0) = f''(\xi_0)\frac{(x_0 - a)(x_0 - b)}{2}$, where p(x) is the linear function that interpolates f(x) in the points a and b ($p(x) = f(a) + \frac{f(b) - f(a)}{b-a}(x-a)$)
 A: Let $p = (a + b)/2$ and $2h = b - a$ so that $a = p - h, b = p + h$. We further define the functions $g(t)$ and $r(t)$ by $$g(t) = \int_{p - t}^{p + t}f(x)\,dx - t\{f(p - t) + f(p + t)\},\,\, r(t) = g(t) - \left(\frac{t}{h}\right)^{3}g(h)$$ Then we can see that $$g'(t) = -t\{f'(p + t) - f'(p - t)\},\,\, r'(t) = g'(t) - \frac{3t^{2}}{h^{3}}g(h)$$ By Mean Value theorem we can see that $$ g'(t) = -2t^{2}f''(t')$$ for some $t' \in (p - t, p + t)$. Thus we have $$r'(t) = -t^{2}\left(2f''(t') + \frac{3}{h^{3}}g(h)\right)$$ Clearly we can see that $r(0) = r(h) = 0$ so that (by Rolle's Theorem) there is some point $t_{0} \in (0, h)$ such that $r'(t_{0}) = 0$. This means that $$-t_{0}^{2}\left(2f''(t') + \frac{3}{h^{3}}g(h)\right) = 0$$ and therefore we have $$g(h) = -\frac{2h^{3}}{3}f''(t')$$ where $t' \in (p - t_{0}, p + t_{0}) \subset (p - h, p + h) = (a, b)$. We finally arrive at (by putting values of $h = (b - a)/2,\, p - h = a,\, p + h = b$ and definition of $g(t)$) $$\int_{a}^{b}f(x)\,dx = \frac{b - a}{2}\{f(a) + f(b)\} - \frac{(b - a)^{3}}{12}f''(t')$$ where $t' \in (a, b)$
Note: This is based on an exercise problem in G. H. Hardy's "A Course of Pure Mathematics". Compared to all the usual proofs given on Numerical Analysis books (primarily based on various interpolation formulas and Taylor series) I find this proof by Hardy to be the simplest one.
A: In standard numerical analysis courses, numerical integration comes after polynomial interpolation. The trapezoidal rule amounts to consider the approximation
$$
\int_a^b f(x) dx \approx \int_a^b p_1(x) dx,
$$
where $p_1(x)$ is the first degree interpolant at $x=a,b$. In this sense, the integration error is given by
$$
\Delta = \int_a^b f(x) dx -\int_a^b p_1(x) dx = \int_a^b(f(x)-p_1(x)) dx = \int_a^b \frac{f''(\xi_x)}{2!} (x-a)(x-b) dx
$$
Since $(x-a)(x-b)$ does not change sign in $[a,b]$, we can use the mean value theorem for integrals obtaining 
$$
\Delta = \frac{f''(\xi)}{2!} \int_a^b(x-a)(x-b)dx = -\frac{f''(\xi)}{12}(b-a)^3.
$$
As for the composed rule, if we are dividing $[a,b]$ in $n$ intervals of equal length,
$$
\Delta = \sum_{i=0}^{n-1}\int_{x_i}^{x_{i+1}} (f(x)-p_{1,i}(x))dx,
$$
where $p_{1,i}(x)$ is the linear interpolant of $f$ in at $x = x_i, x_{i+1}$, so using the previous result,
$$
\Delta = \sum_{i=0}^{n-1} -\frac{f''(\xi_i)}{12} \left(\frac{b-a}{n}\right)^3=-\frac{(b-a)^3}{12 n^3} n \cdot \underbrace{\frac{1}{n}\sum_{i=0}^{n-1} f''(\xi_i)}_{=f''(\xi)} = -\frac{f''(\xi)}{12 n^2} (b-a)^3.
$$
The last factor  is an average of values of $f''$, therefore comprised between the min and max of $f''$. By the mean value theorem it corresponds to the value of $f''$ in some $\xi \in [a,b]$, which yields the final result.
A: Hint: Use the Lagrange Remainder  of the Taylor Expansion:
$$f(x)\sim f(x_1) +f'(x_1)(x-x_1)+f''(x^*)\frac{(x-x_1)^2}{2!}$$
For some $x^*$ in $[x_1,x]$, and integrate the error term over $[x_1,x_2]$.
