Skip to main content

Section 8.4 Trapezoidal rule (\(n=1\))

In this case we are using a 2-points interpolation in \([a,b]\text{.}\) These two points must be the endpoints \(x_0=a\) and \(x_1=b\text{.}\) The interpolating polynomial will have degree 1. The Lagrange polynomials are
\begin{equation*} L_0(x) = \frac{x-x_1}{x_0-x_1},\;L_1(x) = \frac{x-x_0}{x_1-x_0} \end{equation*}
and the corresponding weights are
\begin{equation*} w_0 = \int_a^b\frac{x-a}{b-a}dx = \frac{b-a}{2} = w_1. \end{equation*}
Hence the Trapezoidal rule formula gives
\begin{equation*} Q_1(f,[a,b]) = \frac{f(a)+f(b)}{2}\left(b-a\right). \end{equation*}

Local error. From the Newton-Cotes error formula, we get that
\begin{equation*} \left|\int_a^b f(x)dx - Q_1(f,[a,b])\right|\leq \frac{(b-a)^3}{2}\displaystyle\max_{[a,b]}|f''(x)|\int_0^1s(s-1)ds=\frac{(b-a)^3}{12}\displaystyle\max_{[a,b]}|f''(x)|. \end{equation*}
As usual, this shows that this approximation can be lousy unless \(b-a\ll1\text{.}\)

Trapezoidal rule formula. We bypass as usual the error problem above by subdiving the interval as shown in the previous two sections. In this case, we get that
\begin{equation*} Q_{1,h}(f,[a,b]) = h\sum_{k=0}^{n-1} \frac{f(x_k)+f(x_{k+1})}{2} \end{equation*}
Trapezoidal rule error. From the error formula above, we get that
\begin{equation*} \left|\int_{x_k}^{x_{k+1}}f(x)dx - Q_1(f,[x_k,x_{k+1}])\right|\leq\frac{h^3}{12}\displaystyle\max_{[a,b]}|f''(x)| \end{equation*}
and therefore
\begin{equation*} \left|\int_{a}^{b}f(x)dx - Q_{1,h}(f,[a,b])\right|\leq h^2\frac{b-a}{12}\displaystyle\max_{[a,b]}|f''(x)|. \end{equation*}
Convergence Speed. The formula above shows that the truncation error of the Trapezoidal rule is \(O(h^2)\text{,}\) like for the Midpoint rule. Below we visualize this scaling law by evaluating the error in the computation of \(\int_0^2\sin(x)dx\) with \(h=10^{-j}, 1\leq j\leq7\text{.}\) As in the Midpoint case, the round-off error effects shows already at \(h=10^{-7}\) and the error achievable on this integral is about \(h=10^{-13}\text{.}\)