# Riemann sum formula for definite integral using prime numbers

I had asked this question in MSE. It got lot of upvotes but no answer (except one which was too long to be posted as a comment) hence I am posting it in MO.

While answering another question in MSE I had used the following result which I thought was a trivial consequence of the prime number theorem and equidistribution. However, I realized from the comments that many people thought that this was not either true or counter intuitive. Hence I am posting this as a question looking for a proof or disproof.

Let $$p_k$$ be the $$k$$-th prime and $$f$$ be a continuous function Riemann integrable in $$(0,1)$$ such that

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

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

My approach: It was was based on showing that as $$n \to \infty$$, the ratios $$p_r/p_n$$ approached equidistribution in $$(0,1)$$ hence the integral follows as a property of equidistributed sequence.

Motivation: There are several identities, limits etc on prime numbers which can be easily proven using this simple formula.

• One avenue of proof (probably similar to the one you describe) is to use the prime number theorem with error term to say that every interval of length $p_n/\log p_n$ between $0$ and $p_n$ has approximately $1/\log p_n$ of the primes being summed, then approximate each $f(p_r/p_n)$ by the nearby value $f(kn/\log p_n)$ for the appropriate $k$, then sum. – Greg Martin Sep 22 '18 at 0:18

The statement follows from the prime number theorem. By an approximation argument, we can assume that $$f$$ is continuously differentiable on $$[0,1]$$. Then, $$\sum_{r=1}^{n}f\left(\frac{p_r}{p_n}\right)=\int_0^1 f(x)\,d\pi(p_n x)=nf(1)-\int_0^1 f'(x)\pi(p_n x)\,dx.$$ We estimate the last integral for fixed $$f$$: $$\int_0^1 f'(x)\pi(p_n x)\,dx=\int_{\frac{1}{\log n}}^1 f'(x)\pi(p_n x)\,dx+o(n).$$ In the last integral, we have by the prime number theorem, $$\pi(p_n x)\sim\frac{p_n x}{\log(p_n x)}\sim\frac{p_n x}{\log n}\sim nx,$$ so that \begin{align*}\int_0^1 f'(x)\pi(p_n x)\,dx &=\int_{\frac{1}{\log n}}^1 f'(x)\bigl(nx+o(nx)\bigr)\,dx+o(n)\\ &=\int_{0}^1 f'(x)\bigl(nx+o(nx)\bigr)\,dx+o(n)\\ &=n\int_0^1 f'(x)x\,dx+o(n)\\ &=nf(1)-n\int_0^1 f(x)\,dx + o(n). \end{align*} Putting everything together, $$\sum_{r=1}^{n}f\left(\frac{p_r}{p_n}\right)=n\int_0^1 f(x)\,dx + o(n),$$ that is, $$\frac{1}{n}\sum_{r=1}^{n}f\left(\frac{p_r}{p_n}\right)=\int_0^1 f(x)\,dx + o(1).$$