Error of the extended rules

Using (8), we have for the midpoint rule that

\begin{eqnarray*}
M-I & = & \sum_{i=1}^N M_i - \sum_{i=1}^N I_i \\
& = & \sum_{...
... \left(\sum_{i=1}^N f''(x^{(m)}_i) h\right) + {\mathcal O}(h^4).
\end{eqnarray*}


As $h\rightarrow 0$, the term in brackets approaches a constant (namely, $\int_a^b f''(x)\,dx=f'(b)-f'(a)$). Thus, the leading order error in the midpoint rule is second order in $h$. Moreover, the term in brackets is, in fact, the midpoint rule for computing $\int_a^b
f''(x)\,dx$! Thus, we may complete the analysis and compute precisely the numerical prefactor on $h^2$,
$\displaystyle M-I$ $\textstyle =$ $\displaystyle -\frac{1}{24} h^2 \left(f'(b)-f'(a)+{\mathcal O}(h^2)\right) + {\mathcal O}(h^4)$  
  $\textstyle =$ $\displaystyle -\frac{1}{24} \left(f'(b)-f'(a)\right) h^2 + {\mathcal O}(h^4).$ (13)

The trapezoid rule therefore errs in the second order with a prefactor proportional to $f'(a)-f'(b)$! If, by coincidence or design, $f'(a)=f'(b)$, the midpoint rule becomes correct to fourth order!

Working in the same way from (11), we have for the trapezoid rule,

$\displaystyle T-I$ $\textstyle =$ $\displaystyle \sum_{i=1}^N \left(T_i-I_i\right)$  
  $\textstyle =$ $\displaystyle \sum_{i=1}^N h \left(\frac{1}{12} f''(x^{(m)}_i) h^2+
\frac{1}{480} f^{iv}(x^{(m)}_i) h^4 + {\mathcal O}(h^6)\right)$  
  $\textstyle =$ $\displaystyle \frac{1}{12} h^2 \sum_{i=1}^N f''(x^{(m)}_i) h+
\frac{1}{480} h^4 \sum_{i=1}^N f^{iv}(x^{(m)}_i) h +
{\mathcal O}(h^6)$  
  $\textstyle =$ $\displaystyle \frac{1}{12} h^2 \left( \int_a^b f''(x)\,dx - \frac{1}{24} \left(...
... \left( \int_a^b f^{iv}(x) \, dx + {\mathcal O}(h^2)\right) +
{\mathcal O}(h^6)$  
  $\textstyle =$ $\displaystyle \frac{1}{12} h^2 \left( f'(b)-f'(a) \right) -
\frac{1}{720} h^4 \left( f'''(b)-f'''(a) \right)+ {\mathcal O}(h^6),$  

where we have twice used the result (15). The trapezoid rule thus also becomes fourth-order if $f'(a)=f'(b)$, and sixth-order if also $f'''(a)=f'''(b)$.

Because the error series for both $M_i$ and $T_i$ involve only even terms with numerical prefactors times the respective derivatives of $f(x)$, we see that the full expansion for the error of the trapezoid rule has the form

\begin{displaymath}
T-I = \sum_{n \mbox{\ even}} C_n \left(f^{[n-1]}(b)-f^{[n-1]}(a)\right) h^n,
\end{displaymath}

for some set of numerical coefficients $C_n$1. Thus, if we could arrange for all of the derivatives of $f(\ldots)$ to be equal at the endpoints $a$ and $b$, then the trapezoid rule will converge faster than $h$ to any power -- exponentially! This is not so artificial as first appears: a very common case is the numerical integration of periodic functions.

Tomas Arias 2004-01-26