Numerical Integration: Some Riemann sums

Theory Truncation error in Riemann sums

We consider the truncation error in the left Riemann sum (for the right Riemann sum the derivation is analogous and the result is the same) and the midpoint Riemann sum of a 'neat' function \(f(x)\) on the interval \([a,b]\). We assume \(n\) tags that are \(\displaystyle h=\frac{b-a}{n}\) apart. We write the Riemann sum with the letter \(R\). The analysis will show that the midpoint Riemann sum is a better numerical integration method than the left point or right point Riemann sum.

Truncation error of the left Riemann sum Suppose \(M\) is the maximum of \(|f'|\) on \([a,b]\). Then we have for the left Riemann sum \(R\) : \[\left|\int_a^bf(x)\,\dd x - R\right|\le \tfrac{1}{2}M(b-a)h\] In other words: the truncation error is linear in the mesh size \(h\)

The tags are \(s_k=a+(k-1)h\) for \(k=1,\ldots n\) and the left Riemann sum is given by \[R=\sum_{k=1}^{n}f(a+(k-1)h)\cdot h= \bigl( f(a)+f(a+h)+\cdots f(b-h)\bigr)\cdot h\] We \(s_{n+1}=b\). We first consider the sub-interval \([s_{k},s_{k+1}]\) and note that it follows from Taylor's theorem that \[f(x)=f(s_{k})+f'(\xi_x)(x-s_{k})\] \(x\) and that \(\xi_x\) in this interval ( \(\xi\) depends on \(x\), but this does not really matter). Therefore: \[\left|\int_{s_{k}}^{s_{k+1}}\bigl(f(x)-f(s_{k})\bigr)\,\dd x\right|\le M\cdot \int_{s_{k}}^{s_{k+1}} (x-s_{k})\,\dd x=M\cdot \tfrac{1}{2}h^2\] so that \[\left|\int_{s_{k}}^{s_{k+1}}f(x)\,\dd x - f(s_{k})h\right|\le \tfrac{1}{2}M h^2\] But then: \[\begin{aligned}\left|\int_a^b f(x)\,\dd x - R\right|&=\left|\sum_{k=1}^{n}\int_{s_{k}}^{s_{k+1}}f(x)\,\dd x-\sum_{k=1}^{n}f(s_{k})h\right|\\ \\ &=\left|\sum_{k=1}^{n}\left(\int_{s_{k}}^{s_{k+1}}f(x)\,\dd x-f(s_{k})h\right)\right|\\ \\ &\le \sum_{k=1}^{n}\left|\int_{s_{k}}^{s_{k+1}}f(x)\,\dd x - f(s_{k})h\right|\\ \\ &\le \sum_{k=1}^{n}\tfrac{1}{2}M h^2 = \tfrac{1}{2}M h^2 n=\tfrac{1}{2}M(b-a)h\end{aligned}\]

Truncation error of the right Riemann sum Suppose \(M\) is the maximum of \(|f'|\) on \([a,b]\). Then we have for the right Riemann sum \(R\): \[\left|\int_a^bf(x)\,\dd x - R\right|\le \tfrac{1}{2}M(b-a)h\] In other words: the truncation error is linear in the mesh size \(h\)

Trunctation error of the midpoint Riemann sum Suppose \(M\) is the maximum of \(|f''|\) on \([a,b]\). Then we have for the midpoint Riemann sum \(R\): \[\left|\int_a^bf(x)\,\dd x - R\right|\le \tfrac{1}{24}M(b-a)h^2\] In other words: the truncation error is quadratic in the mesh size \(h\).

The scattering points are \(s_k=a+(k-\tfrac{1}{2})h\) for \(k=1,\ldots n\) and the midpoint Riemann sum is given by \[R=\sum_{k=1}^{n}f(a+(k-\tfrac{1}{2}h)\cdot h= \bigl( f(a+\tfrac{1}{2}h)+f(a+\tfrac{3}{2}h)+\cdots f(b-\tfrac{1}{2}\,h)\bigr)\cdot h\] The points of the distribution are \(x_k=a+k\cdot h\) for \(k=0,1,\ldots n\). We first consider the subinterval \([x_{k-1},x_{k}]\) for \(k=1,\ldots n\) and note that it follows from Taylor's theorem that \[f(x)=f(s_{k})+f'(s_{k})(x-s_{k})+\tfrac{1}{2}f''(\xi_x)(x-s_{k-1})^2\] for \(x\) and \(\xi_x\) in this subinterval ( \(\xi_x\) depends on \(x\), but this does not really matter). Then: \[\begin{aligned}\left|\int_{x_{k-1}}^{x_{k}}\bigl(f(x)-f(s_{k})\bigr)\,\dd x\right|&= \left|\int_{x_{k-1}}^{x_{k}} f'(s_k)(x-s_{k})\,\dd x+\int_{x_{k-1}}^{x_{k}}\tfrac{1}{2}f''(\xi_x) (x-s_{k})^2\,\dd x\right|\\ \\ &\le\tfrac{1}{2}M\cdot \tfrac{1}{3}\cdot2\cdot (\tfrac{1}{2}h)^3=\tfrac{1}{24}Mh^3\end{aligned}\] This result is obtained if you realise that the first integral is equal to \(0\) because \(s_k\) is exactly in the middle between \(x_{k-1}\) and \(x_k\) and that the second integral can be estimated. So: \[\left|\int_{x_{k-1}}^{x_{k}}f(x)\,\dd x - f(s_{k})h\right|\le \tfrac{1}{24}Mh^3\] But then: \[\begin{aligned}\left|\int_a^b f(x)\,\dd x - R\right|&=\left|\sum_{k=1}^{n}\int_{x_{k-1}}^{x_{k}}f(x)\,\dd x-\sum_{k=1}^{n}f(s_{k})h\right|\\ \\ &=\left|\sum_{k=1}^{n}\left(\int_{x_{k-1}}^{x_{k}}f(x)\,\dd x-f(s_{k})h\right)\right|\\ \\ &\le \sum_{k=1}^{n}\left|\int_{x_{k-1}}^{x_{k}}f(x)\,\dd x - f(s_{k})h\right|\\ \\ &\le \sum_{k=1}^{n}\tfrac{1}{24}\,M\cdot h^3 = \tfrac{1}{24}M\cdot h^3 n=\tfrac{1}{24}M(b-a)h^2\end{aligned}\]

About us ⋅ Help ⋅ Privacy ⋅ Terms and conditions
Copyright © 2023 SOWISO