# Calculate an integral with Riemann sum

We know that Riemann sum gives us the following formula for a function $f\in C^1$:

$$\lim_{n\to \infty}\frac 1n\sum_{k=0}^n f\left(\frac kn\right)=\int_0^1f.$$

I am looking for an example where the exact calculation of $\int f$ would be interesting with a Riemann sum.

We usually use integrals to calculate a Riemann sum, but I am interesting in the other direction.

Edit.

I actually found an example of my own today. You can compute

$$I(\rho)=\int_0^\pi \log(1-2\rho \cos \theta+\rho^2)\mathrm d \theta$$

using Riemann sums.

• I suppose you mean an exact calculation? Otherwise the Riemann sum is useful in applied Maths to get an approximation of an integral we cannot compute – Edouard L. Oct 27 '16 at 9:21
• @EdouardL. You are right, that is what I meant. I edited to specify my request. – E. Joseph Oct 27 '16 at 9:23
• Really a side comment, but for some functions the integral equals the Riemann sum for finite $n$, for the example $\cos(x)$ over $[0,2\pi]$. This class has been studied to some extent I believe. – lcv Jan 12 '17 at 15:47

Here is an example ...

For each $z\in\mathbb{C}$ with $\vert z\vert\neq 1$, consider :

$$F(z)=\int_0^{2\pi}\ln\left|z-e^{it}\right|\,dt$$

It is possible to get an explicit form for $F(z)$, using Riemann sums.

For each integer $n\ge1$, consider :

$$S_n=\frac{2\pi}{n}\sum_{k=0}^{n-1}\ln\left|z-e^{2ik\pi/n}\right|$$which is the $n-$th Riemann sum attached to the previous integral (and a uniform subdivision of $[0,2\pi]$ with constant step $\frac{2\pi}{n}$).

Now :$$S_n=\frac{2\pi}{n}\ln\left|\prod_{k=0}^{n-1}\left(z-e^{2ik\pi/n}\right)\right|=\frac{2\pi}{n}\ln\left|z^n-1\right|$$and you can easily show that :$$F(z)=\left\{\matrix{2\pi\ln\left|z\right|& \mathrm{ if}\left|z\right|>1\cr0 & \mathrm{otherwise}}\right.$$

When definite integrals are amenable to exact valuation, it is typically the case that the more expedient approach involves an anti-derivative rather than the limit of a Riemann sum. Often computation of the limit may be straightforward or even trivial, but somewhat tedious, as is the case for integrals of $f: x \mapsto x$ or $f: x \mapsto x^2$.

On the other hand, integrals with simple integrands and easily recognized anti-derivatives such as $f: x\mapsto x^{-2}$ are more challenging with regard to the limit of Riemann sum -- and in that sense the Riemann sum may be "interesting."

To make this more explicit, consider computing the integral

$$\int_a^b x^{-2} \, dx = \lim_{n \to \infty}S_n$$

where

$$S_n =\frac{b-a}{n}\sum_{k=1}^n \left(a + \frac{b-a}{n}k\right)^{-2}.$$

We have

$$\frac{b-a}{n}\sum_{k=1}^n \left(a + \frac{b-a}{n}k\right)^{-1}\left(a + \frac{b-a}{n}(k+1)\right)^{-1} \leqslant S_n \\ \leqslant \frac{b-a}{n}\sum_{k=1}^n \left(a + \frac{b-a}{n}k\right)^{-1}\left(a + \frac{b-a}{n}(k-1)\right)^{-1},$$

and decomposing into partial fractions,

$$\sum_{k=1}^n \left\{\left(a + \frac{b-a}{n}k\right)^{-1}-\left(a + \frac{b-a}{n}(k+1)\right)^{-1}\right\} \leqslant S_n \\\leqslant \sum_{k=1}^n \left\{\left(a + \frac{b-a}{n}(k-1)\right)^{-1}-\left(a + \frac{b-a}{n}k\right)^{-1}\right\}.$$

Since the sums are telescoping, we have

$$\left(a + \frac{b-a}{n}\right)^{-1}-\left(a + \frac{b-a}{n}(n+1)\right)^{-1} \leqslant S_n \leqslant a^{-1} - b^{-1}.$$

By the squeeze theorem, we get the value of the integral as

$$\lim_{n \to \infty}S_n = a^{-1} - b^{-1}.$$

An example where I found the Riemann sum an interesting and, perhaps, most expedient approach is:

Bronstein Integral 21.42

Not a direct answer to your question but I find the following representation of the Riemann sum interesting. Even though it is trivial, these representations show that the sequence of primes or the sequence of composites behave somewhat in a similar same way as the sequence of natural numbers in terms of their asymptotic growth rates. (Too long for a comment hence posting as an answer)

Let $p_n$ be the $n$-th prime number and $c_n$ be the $n$-th composite number; then,

$$\lim_{n \to \infty} \frac{1}{n} \sum_{r=1}^{n} f\bigg(\frac{p_r}{p_n}\bigg) = \int_{0}^{1}f(x)dx.$$

$$\lim_{n \to \infty} \frac{1}{n} \sum_{r=1}^{n} f\bigg(\frac{c_r}{c_n}\bigg) = \int_{0}^{1}f(x)dx.$$