Skip to main content

Section 8.3 Midpoint rule (\(n=0\))

This is a limit case but still interesting enough to cover it. There is a single point (since \(n+1=1\)) and, by symmetry, this point must be the mid-point of \([a,b]\text{,}\) namely
\begin{equation*} x_0 = \frac{a+b}{2}. \end{equation*}
The interpolating polynomial \(L_0(x)\) has degree 0, namely is a constant, and this constant must be 1 because we want that \(L_0(x_0)=1\text{.}\) Hence
\begin{equation*} L_0(x) = 1. \end{equation*}
The interpolating polynomial \(P_f(x)\) of any function \(f(x)\) in this case is particularly simple:
\begin{equation*} P_f(x) = f\left(\frac{a+b}{2}\right)\cdot L_0(x) = f\left(\frac{a+b}{2}\right). \end{equation*}
The weight \(w_0\) corresponding to \(L_0(x)\) is also trivial:
\begin{equation*} w_0=\int_a^b L_0(x)dx=\int_a^b 1dx=b-a \end{equation*}
Hence finally we get

\begin{equation*} Q_0(f,[a,b]) = (b-a)f\left(\frac{a+b}{2}\right). \end{equation*}

Local Error. In this limit case, we cannot use the general formula.

Set \(x_{1/2}=\frac{a+b}{2}\) and \(f_{1/2}=f(x_{1/2})\text{.}\) Then
\begin{equation*} f(x)=f_{1/2}+(x-x_{1/2})f'_{1/2}+(x-x_{1/2})^2\frac{f''_{1/2}}{2}+O((x-x_{1/2})^3) \end{equation*}
and so the error is given by
\begin{gather*} \phantom{=}\left|\displaystyle\int_a^b f(x)dx-Q_0(f,[a,b])\right|=\\ =\left|\displaystyle\int_a^b \left[f(x)-f_{1/2}\right]dx\right|=\\ =\left|\displaystyle f'_{1/2}\int_a^b(x-x_{1/2})dx + \frac{f''_{1/2}}{2}\displaystyle\int_a^b(x-x_{1/2})^2dx \right|\leq\\ \leq \frac{(b-a)^3}{24}\max_{[a,b]}|f''(x)| \end{gather*}

Midpoint rule formula. The error bound above does not say very much when \(b-a\) is large. Following the Newton-Cotes idea, we approximate \(\int_a^bf(x)dx\) by subdividing \([a,b]\) into \(N\) equal-width subintervals with endpoints
\begin{equation*} x_0=a,x_1=x_0+h,x_2=x_0+2h,\dots,x_{N-1}=x_0+(N-1)h,x_N=b, \end{equation*}
where \(h=(b-a)/N\) is the subintervals' width. Hence
\begin{equation*} \int_a^b f(x)dx = \sum_{k=0}^{N-1} \int_{x_k}^{x_{k+1}}f(x)dx. \end{equation*}

Now, applying the midpoint to each one of the integrals in the sum above we get that
\begin{equation*} \int_{x_k}^{x_{k+1}}f(x)dx \simeq hf\left(\frac{x_k+x_{k+1}}{2}\right), \end{equation*}
so that, ultimately, we get the Midpoint rule formula below:
\begin{equation*} Q_{0,h}(f,[a,b]) = h\sum_{k=0}^{N-1} f\left(\frac{x_k+x_{k+1}}{2}\right). \end{equation*}

Midpoint rule error. From the local error formula above we get that
\begin{equation*} \left|\int_{x_k}^{x_{k+1}}f(x)dx - f\left(\frac{x_k+x_{k+1}}{2}\right)\right|\leq \frac{h^3}{24}\max_{[x_k,x_{k+1}]}|f''(x)| \leq \frac{h^3}{24}\max_{[a,b]}|f''(x)| \end{equation*}

Hence, for the total error, we get the "worst case scenario" bound

\begin{equation*} \left|\int_a^b f(x)dx - Q_{0,h}(f,[a,b])\right| \leq N\cdot \frac{h^3}{24}\max_{[a,b]}|f''(x)| = Kh^2 \end{equation*}
where we set
\begin{equation*} K=\frac{b-a}{24}\max_{[a,b]}|f''(x)| \end{equation*}
and we used the fact that \(hN=b-a\text{.}\)

Visualizing numerically the convergence speed. The truncation error of the Midpoint method is therefore \(O(h^2)\text{.}\) We visualize this fact with the code below in case of \(\int_0^2\sin(x)dx\) with \(h=10^{-j}, 1\leq j\leq7\text{.}\)

Notice that, with this method, the error gets soon so small that the round-off error effects become visible at \(h=10^{-7}\text{.}\) The best accuracy achievable on this integral is of about \(10^{-13}\text{.}\)