# Error in trapezoidal rule via integral mean value theorem

During a class, I saw the following analysis of the error term in the trapezoidal rule

For $f \in C^2([a,b])$, $\int_a^b f(x) \,dx - \frac{b-a}{2}[f(a)+f(b)] = -\frac{(b-a)^3}{12}f''(\eta)$ for some $\eta \in (a,b)$

Proof

The error is $\int_a^b f(x) - p_1(x)\,dx$ where $p_1$ is the Langrange interpolant of $f$ at $a,b$. We have $f(x) - p_1(x) = (x-a)(x-b) \frac{f''(\zeta(x))}{2}$ for some $\zeta(x) \in (a,b)$ so by the integral mean value theorem $$\int_a^b f(x) \,dx - \frac{b-a}{2}[f(a)+f(b)] = \int_a^b (x-a)(x-b)\frac{f''(\zeta(x))}{2} \, dx =$$

$$f''(\eta) \int_a^b \frac{(x-a)(x-b)}{2} \,dx \text{ for some } \eta \in (a,b)$$ and then computing the integral gives the result.

The derivation I know for the error term for the Lagrange interpolant (in general) involves repeated applications of Rolle's theorem. In particular, the proof of existence of suitable $\zeta(x)$ is non-constructive so we don't know that $\zeta(x)$ is continuous, which I think is a problem for applying the integral mean value theorem since $f''\circ \zeta$ may not be continuous even though $f''$ is.

I've since seen this proof in a few different places and all of them pass over this issue without comment. Why is it that we can apply the integral mean value theorem here?

Edit: I've changed the proposition to be for $f$ twice continuously differentiable on $[a,b]$ rather than on $(a,b)$. Given this is a requirement in the IMVT I imagine this was either a typographical error either in my memory or in the original proof.

The proposition is simpler than implied because $$\frac{(x-a)(x-b)}2\le0$$ For all $x\in[a,b]$. Thus $$\frac{(x-a)(x-b)}2\max\left(f^{\prime\prime}(x)\right)\le\frac{(x-a)(x-b)}2f^{\prime\prime}(\zeta(x))\le\frac{(x-a)(x-b)}2\min\left(f^{\prime\prime}(x)\right)$$ And so \begin{align}\max\left(f^{\prime\prime}(x)\right)\int_a^b\frac{(x-a)(x-b)}2dx&\le\int_a^b\frac{(x-a)(x-b)}2f^{\prime\prime}(\zeta(x))dx\\ &\le\min\left(f^{\prime\prime}(x)\right)\int_a^b\frac{(x-a)(x-b)}2dx\end{align} Now $$\int_a^b\frac{(x-a)(x-b)}2f^{\prime\prime}(\zeta(x))dx=f^{\prime\prime}(\eta)\int_a^b\frac{(x-a)(x-b)}2dx$$ Follows from the continuity of $f^{\prime\prime}(x)$ and the intermediate value theorem.

• I am delighted to see this shorter proof! It works for functions $f \in C^2([a,b])$. This may be a bit more than we are allowed, though. OP specified $f \in C^2(a,b)$, which I (rightly or wrongly) took to mean $f$ two times differentiable in $(a,b)$. I quietly added $f \in C([a,b])$ so that the Riemann integral of $f$ would exists. I do not think that I need $f \in C^2([a,b])$ to make my proof work, but I would value an independent check. Kind regards – Carl Christian Jun 10 '16 at 22:48
• Truth be told, I had a hard time following your proof. How does proposition $1$ work if $f(x)=\sqrt{(x-a)(b-x)}$? I didn't mess around with problem cases like that in my proof, to be sure, but if the second derivative is unbounded both above and below, for example, the theorem is trivially true. If $f\notin C([a,b])$ the theorem is false. – user5713492 Jun 10 '16 at 23:16
• Thanks a lot! You just drew my attention to the fact that I also assumed that $f'$ has a limit at the boundary. It is very late in my time zone, so I will need to sleep on it. – Carl Christian Jun 10 '16 at 23:25

Consider the function $h : (a,b) \rightarrow \mathbb{R}$ given by $$h(x) = 2 \frac{f(x) - p_1(x)}{(x-a)(x-b)}.$$ It is clear, that $h \in C^2((a,b))$ and by the definition of $\xi$ we have $$\forall x \in (a,b) \: : \: f''(\xi(x)) = h(x).$$ We now make the following claims

1. $h$ can be extended continuously to the entire entire interval $[a,b]$.
2. The extended function $\bar{h}$ satifies $$\forall x \in [a,b] \: \exists\, \nu \in (a,b) \: : \: \bar{h}(x) = f''(\nu).$$
3. The extended function $\bar{h}$ satisfies $$\forall x \in [a,b] \: : \: f(x) - p_1(x) = \frac{1}{2}\bar{h}(x)(x-a)(x-b).$$

Before proving these claims show that the extended function $\bar{h}$ solves our problem. By the mean value theorem for integration we have $$\int_a^b f(x) - \int_a^b p_1(x) dx = \frac{1}{2} \int_a^b \bar{h}(x) (x-a)(x-b) dx = \frac{1}{2} \bar{h}(\eta) \int_a^b (x-a)(x-b) dx,$$ for some $\eta \in [a,b]$.

We now prove the claims made above.

1. We will now investigate the behavior of $h$ as $x$ tends to $a$ from the left. To that end, let $T(x) = f(x) - p_1(x)$ and $N(x) = (x-a)(x-b)$, so that $$h(x) = 2 \frac{T(x)}{N(x)}.$$ Then $$T(x) \rightarrow 0, \quad x \rightarrow a_+, \quad \text{and} \quad N(x) \rightarrow 0, \quad x \rightarrow a_+,$$ which is why we investigate the derivatives $T'$ and $N'$. We have $$T'(x) = f'(x) - p'_1(x) \rightarrow f'(a) - p'_1(a), \quad x \rightarrow a_+$$ and $$N'(x) = 2x - (a+b) \rightarrow a - b,\quad x \rightarrow a_+$$ It follows by l'Hospital's theorem that $$h(x) \rightarrow 2 \frac{f'(a) - p'_1(a)}{a-b}, \quad x \rightarrow a_+$$ In the same fashion we discover, that $$h(x) \rightarrow 2 \frac{f'(b) - p'_1(b)}{b-a}, \quad x \rightarrow b_-$$ This proves that $h$ can be extended continuously to the entire interval $[a,b]$.
2. By the definition of $\xi = \xi(x)$ we have $$\forall x \in [a,b] \: : f(x) - p_1(x) = \frac{1}{2} f''(\xi(x)) (x-a)(x-b).$$ This implies that $$\forall x \in (a,b) \: : \: \exists\, \nu \in [a,b] \: : \: h(x) = f''(\nu).$$ Specifically, we can use $\nu = \xi(x)$. It remains to investigate the endpoints. This requires the use of divided differences with repeated points. We have $$\frac{1}{2} \bar{h}(a) = \frac{f'(a) - p'_1(a)}{a-b} = \frac{f'(a) - \frac{f(a)-f(b)}{a-b}}{a-b} = \frac{f[a,a]-f[b,a]}{a-b} = f[b,a,a].$$ By the mean value theorem for divided differences we have $$\exists \mu \in (a,b) \: : \: f[b,a,a] = \frac{1}{2} f''(\mu).$$ It follows that $$\exists \mu \in (a,b) \: : \: h(a) = f''(\mu).$$ The same reasoning applies to the right hand end point $b$. This completes the proof of the second claim.
3. As in the previous paragraph, we have $$\forall x \in (a,b) \: : f(x) - p_1(x) = \frac{1}{2} f''(\xi(x)) (x-a)(x-b) = \frac{1}{2} h(x)(x-a)(x-b).$$ By the continuity of $f$, $p_1$, and $\bar{h}$ this identity holds at the endpoints as well. This completes the proof of the third claim.

I would like to end with a small comment.

Frequently, we use the chain rule to show that the composition $F \circ G$ of two functions $F$ and $G$ is differentiable. Here we do not care about the differentiability of either $f''$ or $\xi$, because we have an alternative representation of $f'' \circ \xi$ from which we deduce that that $f'' \circ \xi$ is differentiable for all $x \in (a,b)$. For the purpose of proving the theorem, it is irrelevant that we have exhausted the differentiability of $f$ and that we know nothing about the differentiability of $\xi$.

EDIT: After discussions with user5713492 I would like to emphasize that the above requires $f$ to be differentiable at $a$ and $b$. This is quietly used in the proof of Claim 1 above.