Example 5.3.1.
Find \(\int_{0}^{1} e^{-x^2}\,dx\) using the composite trapezoid rule with \(n=10\text{.}\) Find a bound on the error.
Solution.
In this case \(h=(b-a)/n=1/10\text{.}\)
\begin{equation*}
\begin{aligned}\int_{0}^{1} e^{-x^2}\,dx\amp = \frac{1}{20}\biggl( f(0) + 2 \sum_{i=1}^{9} f(i/10) + f(1) \biggr) \\\amp \approx 0.7462107961\end{aligned}
\end{equation*}
To find a bound on the error, we use (5.3.3) and need a bound on the second derivative of \(f(x)\text{.}\) It can be shown that \(f''(x) = (4x^{2}-2)e^{-x^2}\) and this reaches a maximum (in absolute value) at \(x=0\text{,}\) so \(|f''(x)| \leq 2\text{.}\) Using (5.3.3),
\begin{equation*}
\begin{aligned}\biggl|- \frac{(b-a)h^{2}}{12}f''(\xi) \biggr| \leq \frac{1(1/10)}{12}\max_{x \in [0,1]}f''(\xi) \leq \frac{1}{120}(2) = \frac{1}{60}.\end{aligned}
\end{equation*}
Recall that this is a theoretical error bound and the actual error is about \(6 \times 10^{-4}\text{.}\)
