The leading error in a numerical integral can be estimated by the difference of two quadrature rules. As a canonical example, let us estimate the error of midpoint rule using its difference from the trapezoid rule.
Error of Midpoint Rule
Define the midpoint \(m=\frac{a+b}{2}\) and step size \(h=\frac{b-a}{2}\). By Taylor expansion
$$ f(x)=f(m)+f'(m)(x-m)+\frac{1}{2}f”(m)(x-m)^2+\dots.$$
By change of variable \(y=x-m\), we see that odd power terms drop out after integration
$$ \int_a^b f'(m)(x-m) dx=f'(m)\int_{-h}^h ydy=0.$$
Thus, by comparing to the midpoint rule formula \(M(f)=f(m)(b-a)\) with
$$ I(f)=f(m)(b-a)+\frac{f”(m)}{24}(b-a)^3+\dots=M(f)+E(f)+\dots,$$
we recognize the leading order error as \(E(f)=\frac{f”(m)}{24}(b-a)^3\).
Difference between Midpoint and Trapezoid
First rewrite the trapezoid rule
$$ T(f)=\frac{f(a)+f(b)}{2}(b-a),$$
in terms of \(f(m)\) using Taylor expansion
$$ \left\{\begin{array}{l} f(a)=f(m)-f'(m)h+\frac{h^2}{2}f”(m)+\dots \\ f(b)=f(m)+f'(m)h+\frac{h^2}{2}f”(m)+\dots\end{array}\right.\\
\Rightarrow T(f)=f(m)(a-b)+\frac{f”(m)}{8}(b-a)^3+\dots.$$
Now substitute the formula for \(M(f)\) and \(E(f)\) into \(T(f)\)
$$ T(f)=M(f)+3E(f)+\dots.$$
Thus we estimate \(E(f)\approx\frac{T(f)-M(f)}{3}\).
The above estimate is only accurate if
- Step size \(h\) is small enough so the next order error is way smaller than \(E(f)\)
- Higher derivatives of the function are well-behaved (aka do not blow up)