Using (8), we have for the midpoint rule that
As
, the term in brackets approaches a constant
(namely,
). 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
! Thus, we may complete the analysis and compute precisely
the numerical prefactor on
,
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,
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
and
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
for some set of numerical coefficients
. Thus, if we could arrange for
all of the derivatives of
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.