Proving that the limit of an integral of a series exists The goal is to show that the following limit exists
$$\lim_{T\to\infty} \frac{1}{T}\int_{-T}^T f(x)dx$$
where
$$f(x)=\sum_{n=1}^\infty \frac{e^{ia_n x}}{n^2}$$
I already showed that $f$ is bounded and continuous, and the series converges absolutely. Here's what I've done:
1) Switch the sum and the integral (ok because series converges absolutely), and I get
$$\lim_{T\to\infty} \frac{1}{T}\int_{-T}^T f(x)dx = \lim_{T\to\infty}\sum_{n=1}^\infty \frac{2\sin\left(a_n T\right)}{T a_n n^2}.$$
It seems like I can switch the limit and sum again (I would need to make this rigorous, but that's a relatively nice-looking series), and then I get
$$\lim_{T->\infty} \frac{1}{T}\int_{-T}^T f(x)dx = \lim_{T\to\infty}\sum_{n=1}^\infty 0 = 0.$$
I tried this for the case when $\{a_n\} = a$ for all $n$ (i.e. the series is a constant). When it's just a constant, it's easy to evaluate the expression without switching the integral, limit, or sum. We can just go at it directly, and we get 0.
Is what I wrote reasonable? I always get a bit worried when I end up with zero, but I'm reassured by the case when $\{a_n\}$ is a constant.
 A: Two theorems:


*

*Let $I$ be a bounded interval of $\mathbb R$ and $f_n:I\to \mathbb C$ a sequence of continuous functions. If $\sum_n f_n$ converges uniformly to a function $S$ then $S$ is continuous and $$\int_IS(x)~\mathrm dx=\sum_{n=0}^{\infty}\left(\int_If_n(x)~\mathrm dx\right)$$

*Let $I$ be an interval of $\mathbb R$, $a\in \bar I$ and $f_n:I\to \mathbb C$ such that each $f_n$ has a limit at $a$ and $\sum f_n$ converges uniformly to a function $S$. Then $\displaystyle \sum_n (\lim_{t\to a}f_n(t))$ converges and $$\lim_{t\to a}S(t)=\sum_n (\lim_{t\to a}f_n(t))$$
These results are taught at undergrad level in France, so you should be able to find proofs easily.

Assuming none of the $a_n$ is $0$
Let $T$ be a fixed real. Note that $\displaystyle \frac{1}{T}\int_{-T}^T \sum_{n=1}^\infty \frac{e^{ia_n x}}{n^2}dx = \int_{-1}^1 \sum_{n=1}^\infty \frac{e^{ia_n Tu}}{n^2}du$.
Since $\displaystyle \sum_{n\geq1} \frac{e^{ia_n Tu}}{n^2}$ converges uniformly over $[-1,1]$, you can use the first theorem to get $$\displaystyle \int_{-1}^1 \sum_{n=1}^\infty \frac{e^{ia_n Tu}}{n^2}du = 2\sum_{n=1}^\infty \frac{1}{n^2}\frac{\sin(a_nT)}{a_nT}$$
Now, let $\displaystyle g_n:\mathbb R\to \mathbb R, T\to \frac{1}{n^2}\frac{\sin(a_nT)}{a_nT}$
Each $g_n$ converges to $0$ as $T$ goes to $\infty$ and $\displaystyle \sum_{n=1}^\infty \frac{1}{n^2}\frac{\sin(a_nT)}{a_nT}$ converges uniformly over $\mathbb R$ (essentially because $x\to \frac{\sin x}{x}$ is bounded).
Applying  the second theorem yields $$\lim_T \sum_{n=1}^\infty \frac{1}{n^2}\frac{\sin(a_nT)}{a_nT} = 0$$
Hence $$ \lim_T \frac{1}{T}\int_{-T}^T \sum_{n=1}^\infty \frac{e^{ia_n x}}{n^2}dx =0$$
In the general case, $$ \lim_T \frac{1}{T}\int_{-T}^T \sum_{n=1}^\infty \frac{e^{ia_n x}}{n^2}dx =\sum_{n\geq 1, a_n\neq 0} \frac{1}{n^2}$$
