# 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)$)

• Guess that, if true, when ∫f(x)dx relates to f″(c), it basically says that (just for purpose, assuming that f is C^3), for any such function there exists c such that : f'''(c) =-12(b-a)^(-3)*(f(b)-f(a)) – epsilones Feb 23 '13 at 23:45
• Btw, I think that finding that c such that ∫f(x)dx=−1/12*f″(c)(b−a)^3, fails for the identity function – epsilones Feb 23 '13 at 23:54
• It doesn't fail beacause when you're dealing with linear functions, $\int{f-p} = 0$, since p = f, $\forall x \in \mathbb R$ – Pedro Amorim Feb 24 '13 at 0:16
• @PedroAmorim The expression you mentioned is not the max error, it is the actual error. The max error corresponds to setting bounds on the term $f''(c)$, for instance, $|f''(c)| \leq \|f''\|_{\infty}$. – PierreCarre Apr 30 at 17:51

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.

• This is an elegant proof for sure, if it is simpler, I really cannot say. – PierreCarre Apr 30 at 14:34
• @PierreCarre: well, the proof does not need any of the results from numerical analysis. Usually a typical calculus course covers both trapezoidal and Simpsons rule and in such courses it is preferable to provide self contained. – Paramanand Singh Apr 30 at 14:43
• @ParamanandSinght Yes the measure of "simplicity" surely depends on the type of course. In a standard numerical analysis course I prefer to use the interpolation error, as it makes use of another topic in the course. – PierreCarre Apr 30 at 14:51

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]$.

• I still can't solve it. You've got another hint? – Pedro Amorim Feb 24 '13 at 19:58
• Why the downvote? – nbubis Aug 21 '13 at 17:03
• @nbubis There should be an equal sign in your Taylor expansion, the result is exact. – PierreCarre Apr 30 at 13:52

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.