We consider the truncation error in the trapezoidal rule applied to a 'neat' function \(f(x)\) on the interval \([a,b]\). But first we call attention to the following auxiliary theorem which will turn out to be very useful:

For a twice differentiable function \(f\) on an interval \([a,b]\) with \(f(a)=f(b)=0\) we have \[\int_a^b(x-a)(b-x)f''(x)\,\dd x=-2\int_a^b f(x)\,\dd x\]

The proof boils down to integrating twice: \[\begin{aligned}\int_a^b(x-a)(b-x)f''(x)\,\dd x &= \bigl[(x-a)(b-x)f'(x)\bigr]_a^b-\int_a^b(a+b-2x)f'(x)\,\dd x\\ \\ &=\int_a^b(2x-a-b)f'(x)\,\dd x\\ \\ &=\bigl[(2x-a-b)f(x)\bigr]_a^b-\int_a^b 2f(x)\,\dd x\\ \\ &= -2\int_a^b f(x)\,\dd x\end{aligned}\]

We now formulate the estimation of the truncation error in the trapezoidal rule.

Suppose \(M\) is the maximum of \(|f''|\) on \([a,b]\). Then we have for the result \(T\) of the trapezoidal rule: \[\left|\int_a^bf(x)\,\dd x - T\right|\le \tfrac{1}{12}M(b-a)h^2\] In other words: the truncation error is quadratic in the mesh size \(h\).

The tags of the partition are \(x_k=a+kh\) for \(k=0,1,\ldots n\) with \(h=\frac{b-a}{n}\) and the trapezoidal rule is given by \[T=\frac{h}{2}\bigl(f(a)+f(b)\bigr)+h\sum_{k=1}^{n-1} f(a+kh)\] Firt we consider the sub-interval \([x_{k-1},x_{k}]\) for \(k=1,\ldots n\) and estimate the contribution to the truncation error on each sub-interval. We introduce the function \[g(x)=f(x)-f(x_{k-1})-\frac{\bigl(f(x_{k})-f(x_{k-1})\bigr)\bigl(x-x_{k-1}\bigr)}{h}\] The function \(g\) is the deviation of \(f\) on the interval \([x_{k-1},x_{k}]\) with the linear function between the points \(\bigl(x_{k-1},f(x_{k-1})\bigr)\) and \(\bigl(x_{k},f(x_{k})\bigr)\). Then \(\displaystyle \int_{x_{k-1}}^{x_k}g(x)\,\dd x\) is equal to the contribution of this sub-interval to the truncation error of the trapezoidal rule. Because the function \(g\) is twice differentiable, and by definition is \(g(x_{k-1})=g(x_{k})=0\), the lemma is applicable: \[\int_{x_{k-1}}^{x_k}g(x)\,\dd x=-\frac{1}{2}\int_{x_{k-1}}^{x_k} (x-x_{k-1})(x_{k}-x)g''(x)\,\dd x\] By definition, \(g''(x)=f''(x)\) is valid and therefore: \[\begin{aligned}\left|\int_{x_{k-1}}^{x_k}g(x)\,\dd x\right| &\le \frac{1}{2}\int_{x_{k-1}}^{x_k} (x-x_{k-1})(x_{k}-x)|f''(x)|\,\dd x \\ \\ &\le \frac{M}{2} \int_{x_{k-1}}^{x_k} (x-x_{k-1})(x_k-x)\,\dd x \\ \\ &=\frac{M}{2}\int_{x_{k-1}}^{x_k} (-x^2+(x_{k-1}+x_k)x-x_{k-1}x_{k})\,\dd x\\ \\ &= \frac{M}{12}(x_{k}-x_{k-1})^3\\ \\ &= \frac{M}{12}h^3\end{aligned}\] Then we have for the truncation error of the trapezoidal rule we have\[\left|\int_a^bf(x)\,\dd x - T\right|\le\sum_{k=1}^n \tfrac{1}{12}Mh^3=\tfrac{1}{12}Mh^3n=\tfrac{1}{12}M(b-a)h^2\]