Skip to main content

Subsection 1.11.5 Optional — An error bound for the midpoint rule

We now try develop some understanding as to why we got the above experimental results. We start with the error generated by a single step of the midpoint rule. That is, the error introduced by the approximation

\begin{equation*} \int_{x_0}^{x_1}f(x)\,\dee{x}\approx f(\bar x_1)\De x \qquad\hbox{ where } \De x=x_1-x_0,\ \bar x_1=\tfrac{x_0+x_1}{2} \end{equation*}

To do this we are going to need to apply integration by parts in a sneaky way. Let us start by considering  13 We chose this interval so that we didn't have lots of subscripts floating around in the algebra. a subinterval \(\alpha \leq x \leq \beta\) and let's call the width of the subinterval \(2q\) so that \(\beta=\alpha+2q\text{.}\) If we were to now apply the midpoint rule to this subinterval, then we would write

\begin{align*} \int_\alpha^\beta f(x) \dee{x} & \approx 2q \cdot f(\alpha+q) = q f(\alpha+q) + q f(\beta-q) \end{align*}

since the interval has width \(2q\) and the midpoint is \(\alpha+q=\beta-q\text{.}\)

The sneaky trick we will employ is to write

\begin{align*} \int_\alpha^\beta f(x) \dee{x} &= \int_\alpha^{\alpha+q}f(x)\dee{x} + \int_{\beta-q}^\beta f(x)\dee{x} \end{align*}

and then examine each of the integrals on the right-hand side (using integration by parts) and show that they are each of the form

\begin{align*} \int_\alpha^{\alpha+q}f(x)\dee{x} & \approx q f(\alpha+q) + \text{small error term}\\ \int_{\beta-q}^\beta f(x)\dee{x} &\approx q f(\beta-q) + \text{small error term} \end{align*}

Let us apply integration by parts to \(\int_\alpha^{\alpha+q} f(x)\dee{x}\) — with \(u=f(x), \dee{v}=\dee{x}\) so \(\dee{u}=f'(x)\dee{x}\) and we will make the slightly non-standard choice of \(v=x-\alpha\text{:}\)

\begin{align*} \int_\alpha^{\alpha+q} f(x)\dee{x} &= \big[ (x-\alpha)f(x)\big]_\alpha^{\alpha+q} - \int_\alpha^{\alpha+q} (x-\alpha) f'(x) \dee{x}\\ &= q f(\alpha+q) - \int_\alpha^{\alpha+q} (x-\alpha) f'(x) \dee{x} \end{align*}

Notice that the first term on the right-hand side is the term we need, and that our non-standard choice of \(v\) allowed us to avoid introducing an \(f(\alpha)\) term.

Now integrate by parts again using \(u=f'(x), \dee{v}=(x-\alpha)\dee{x}\text{,}\) so \(\dee{u}=f''(x), v = \frac{(x-\alpha)^2}{2}\text{:}\)

\begin{align*} \int_\alpha^{\alpha+q} f(x)\dee{x} &= q f(\alpha+q) - \int_\alpha^{\alpha+q} (x-\alpha)f'(x)\dee{x}\\ &= q f(\alpha+q) - \left[ \frac{(x-\alpha)^2}{2} f'(x) \right]_\alpha^{\alpha+q} + \int_\alpha^{\alpha+q} \frac{(x-\alpha)^2}{2}f''(x)\dee{x}\\ &= q f(\alpha+q) - \frac{q^2}{2}f'(\alpha+q) + \int_\alpha^{\alpha+q} \frac{(x-\alpha)^2}{2}f''(x)\dee{x} \end{align*}

To obtain a similar expression for the other integral, we repeat the above steps and obtain:

\begin{align*} \int_{\beta-q}^\beta f(x)\dee{x} &= q f(\beta-q) + \frac{q^2}{2}f'(\beta-q) + \int_{\beta-q}^\beta \frac{(x-\beta)^2}{2}f''(x)\dee{x} \end{align*}

Now add together these two expressions

\begin{align*} \int_\alpha^{\alpha+q} f(x)\dee{x} + \int_{\beta-q}^\beta f(x)\dee{x} &= q f(\alpha+q) + q f(\beta-q) + \frac{q^2}{2}\left( f'(\beta-q)-f'(\alpha+q) \right)\\ & + \int_\alpha^{\alpha+q} \frac{(x-\alpha)^2}{2}f''(x)\dee{x} + \int_{\beta-q}^\beta \frac{(x-\beta)^2}{2}f''(x)\dee{x}\\ \end{align*}

Then since \(\alpha+q=\beta-q\) we can combine the integrals on the left-hand side and eliminate some terms from the right-hand side:

\begin{align*} \int_\alpha^\beta f(x)\dee{x} &= 2q f(\alpha+q) + \int_\alpha^{\alpha+q} \frac{(x-\alpha)^2}{2}f''(x)\dee{x} + \int_{\beta-q}^\beta \frac{(x-\beta)^2}{2}f''(x)\dee{x} \end{align*}

Rearrange this expression a little and take absolute values

\begin{align*} \left| \int_\alpha^\beta f(x)\dee{x} - 2q f(\alpha+q) \right| &\leq \left| \int_\alpha^{\alpha+q} \frac{(x-\alpha)^2}{2}f''(x)\dee{x} \right| + \left|\int_{\beta-q}^\beta \frac{(x-\beta)^2}{2}f''(x)\dee{x}\right| \end{align*}

where we have also made use of the triangle inequality  14 The triangle inequality says that for any real numbers \(x,y\) \(|x+y| \leq |x| + |y|.\). By assumption \(|f''(x)| \leq M\) on the interval \(\alpha \leq x \leq \beta\text{,}\) so

\begin{align*} \left| \int_\alpha^\beta f(x)\dee{x} - 2q f(\alpha+q) \right| & \leq M \int_\alpha^{\alpha+q} \frac{(x-\alpha)^2}{2} \dee{x} + M \int_{\beta-q}^\beta \frac{(x-\beta)^2}{2} \dee{x}\\ &= \frac{Mq^3}{3} = \frac{M(\beta-\alpha)^3}{24} \end{align*}

where we have used \(q = \frac{\beta-\alpha}{2}\) in the last step.

Thus on any interval \(x_i \leq x \leq x_{i+1}=x_i+\De x\)

\begin{align*} \left| \int_{x_i}^{x_{i+1}} f(x)\dee{x} - \De x f\left(\frac{x_i+x_{i+1}}{2}\right) \right| & \leq \frac{M}{24} ( \De x)^3 \end{align*}

Putting everything together we see that the error using the midpoint rule is bounded by

\begin{gather*} \left| \int_a^b f(x) \dee{x} - \left[ f(\bar x_1)+f(\bar x_2)+\cdots +f(\bar x_n) \right]\De x \right|\\ \leq \left| \int_{x_0}^{x_1} f(x)\dee{x} - \De x f(\bar x_1) \right| +\cdots+ \left| \int_{x_{n-1}}^{x_n} f(x)\dee{x} - \De x f(\bar x_n) \right|\\ \leq n \times \frac{M}{24} ( \De x)^3 = n \times \frac{M}{24} \left( \frac{b-a}{n}\right)^3 = \frac{M(b-a)^3}{24 n^2} \end{gather*}

as required.

A very similar analysis shows that, as was stated in Theorem 1.11.13 above,

  • the total error introduced by the trapezoidal rule is bounded by \(\ds \frac{M}{12}\frac{(b-a)^3}{n^2}\text{,}\)
  • the total error introduced by Simpson's rule is bounded by \(\ds \frac{M}{180}\frac{(b-a)^5}{n^4}\)