Limit of Integral with a Limit Here's a little question I saw in a book recently, which I can see but can't set out my own formal proof and it's annoying me.
Say $\lim_{x\to\infty} g(x) = a$
and $g$ is continuous,
so now prove that
$\lim_{x\to\infty} \frac{1}{x} \int_0^x g(y) \mathrm{d}y = a$ .
I can see that if we define $\int_0^x g(y)\mathrm{d}y  = G(x) - G(0)$ 
then $\frac{1}{x} \int_0^x g(y) \mathrm{d}y = \frac{G(x) - G(0)}{x}$
which clearly looks a lot like the limit of a differential, but I'm not sure how to handle the limit?!
 A: Perhaps you assume $g$ is continuous, at least some kind of integrability has to be assumed.
Hints:


*

*Since $\lim_{x\to\infty} g(x) =a$ exists, we can for each $\varepsilon>0$ find $x_0$ such that $$|g(x)-a|<\varepsilon$$ for all $x\geq x_0$.

*Split the integral $$\int_0^x=\int_0^{x_0}+\int_{x_0}^x$$

*What can we say about $$\frac{1}{x}\int_0^{x_0} ?$$

*What can we say about $$\frac{1}{x}\int_{x_0}^x ?$$ 
A: We don't need $g(x)$ to be continous, we only need $g(x)$ to be integrable.
Take any $\varepsilon > 0$. Since $\lim_{x\to +\infty} g(x) = a$, for any $x>M_\varepsilon$ we have $|g(x)-a|<\varepsilon$. Take 
$$I_\varepsilon = \int_{0}^{M_\varepsilon}\left|g(x)-a\right|\,dx$$
and
$$n_\varepsilon = \left\lceil\frac{I_\varepsilon}{\epsilon}\right\rceil.$$
For any $x>0$ we have:
$$-a+\frac{1}{x}\int_{0}^{x}g(x)\,dx=\frac{1}{x}\int_{0}^{x}(g(x)-a)\,dx,$$
so, for any $x> \max(n_\varepsilon, M_\varepsilon)$ we have:
$$\left|-a+\frac{1}{x}\int_{0}^{x}g(x)dx\right|\leq \frac{I_\varepsilon}{x}+\frac{1}{x}\int_{M_\varepsilon}^{x}|g(x)-a|\,dx \leq 2\varepsilon.$$
Since $\varepsilon$ can be taken arbitrarily small, the last inequality gives:
$$\lim_{x\to +\infty}\frac{1}{x}\int_{0}^{x}g(x)\,dx = a,$$
QED.
