Prove that $\lim_{n\to\infty}\frac1{n}\int_0^{n}xf(x)dx=0$.

Let $f$ be a continuous, nonnegative, real-valued function and $$\int_0^{\infty}f(x)dx<\infty.$$ Prove that $$\lim_{n\to\infty}\frac1{n}\int_0^{n}xf(x)dx=0.$$

A start: If $\lim\limits_{n\to\infty}\int_0^{n}xf(x)dx$ is finite, then it's obvious. Otherwise, perform L'Hopital's rule, we get $\lim nf(n)$, which we want to show is $0$.


Let $u_n=\frac1{n}\int_0^{n}xf(x)dx \geq 0$. Let $\varepsilon > 0$. We need to show that $u_n \leq \varepsilon$ for large enough $n$.

By hypotesis, there is a $a$ such that $\int_a^{\infty}f(x)dx \leq \frac{\varepsilon}{2}$.

Let $n$ be an integer such that $n\geq {\sf max}(a,\frac{2\int_0^a xf(x)dx}{\varepsilon})$. Then

$$ u_n=\int_0^a \frac{xf(x)}{n}dx + \int_a^n \frac{xf(x)}{n}dx \leq \frac{\varepsilon}{2}+ \int_a^n \frac{nf(x)}{n}dx \leq \frac{\varepsilon}{2}+\frac{\varepsilon}{2} =\varepsilon $$

and we are done.


$$\forall n\geqslant k,\qquad0\leqslant\frac1{n}\int_0^{n}xf(x)\mathrm dx\leqslant\frac1n\int_0^{k}xf(x)\mathrm dx+\int_k^{\infty}f(x)\mathrm dx$$