As a complement: suitably interpreted, your computation is perfectly correct. That is, while the resulting series will not converge pointwise, there are many other possible (useful!) ways a Fourier series may converge. And, suitably interpreted, term-wise differentiation is always correct. [Edit: typo'd "pointwise" earlier, when I meant "termwise". Sorry!]
Recall that, for two Fourier expansions of "nice" functions $f(x)=\sum_n a_n e^{inx}$ and $g(x)=\sum_n b_ne^{inx}$, we have the Parseval-Plancherel theorem that ${1\over 2\pi}\int_0^{2\pi} f(x)\,\overline{g(x)}\,dx=\sum_n a_n\,\overline{b_n}$. And, yes, Fourier series do converge pointwise for infinitely-differentiable functions, and can be differentiated termwise...
Slightly changing your example, observe that the Fourier series $\delta(x)=\sum_n 1\cdot e^{inx}$ (the Dirac comb) certainly does not converge point-wise, because the terms do not go to $0$. Nevertheless, thinking in terms of Parseval-Plancherel, for nice function $f$
$$
f(0) \;=\; \sum_n a_n\,e^{in\cdot 0} \;=\; \sum_n a_n\cdot 1
$$
which has the same form as ${1\over 2\pi}\int_0^{2\pi} f(x)\cdot \overline{\delta(x)}\,dx$ if the latter were to make sense. That is, the evaluation-at-$0$ functional can be represented as a sort of inner product, under some constraints.
More precisely, for $s\in\mathbb R$, the $s$-th Sobolev space $H^s$ here consists of Fourier series $\sum_n b_ne^{inx}$ with $\sum_n |b_n|^2/(1+|n|)^s < \infty$. The Fourier series for the Dirac comb is in $H^{-{1\over 2}-\epsilon}$ for every $\epsilon>0$. For an "ordinary" function $f$ whose Fourier coefficients $a_n$ have sufficient decay to put $f$ in $H^{{1\over 2}+\epsilon}$, e.g., some smoothness of $f$ itself,
$$
|f(0)| \;=\; \Big|\sum_n a_n\cdot 1\Big| \;=\; \Big|\sum_n a_n\cdot (1+|n|)^{{1\over 2}+\epsilon}
\cdot {1\over (1+|n|)^{{1\over 2}+\epsilon}}\Big|
$$
and by Cauchy-Schwartz the square of this is dominated by
$$
\sum_n |a_n|^2(1+|n|)^{1+2\epsilon}
\cdot
\sum_n {1\over (1+|n|)^{1+2\epsilon}}
$$
That is, the evaluation functional $f\rightarrow f(0)$ is continuous in the $H^{{1\over 2}+\epsilon}$ metric topology, and the Dirac comb is a continuous linear functional on it. (This argument actually shows an instance of Sobolev imbedding, namely, that $H^{{1\over 2}+\epsilon}$ consists of continuous functions.)
Thus, a Fourier series in $H^{-s}$ (with $s> 0$), even though not pointwise convergent at all, directly gives a (continuous) linear functional on $H^s$ by extending Parseval-Plancherel:
$$
\Big(\sum_n b_n\,e^{inx}\Big)\bigg(\Big(\sum_n a_n e^{inx}\Big)\bigg)
\;=\; \sum_n a_n\cdot b_n
$$
That is, distributions have legitimate Fourier series expansions, though typically not converging pointwise at all. Termwise differentiation of not-very-convergent Fourier series is completely justifiable if construed as distributional derivatives, via integration by parts: after all, differentiation in the Fourier series is termwise multiplication by $in$.
Indeed, Sobolev and others looked at this sort of situation in the 1930s. A discussion in this direction, beginning more-or-less from scratch, is at http://www.math.umn.edu/~garrett/m/mfms/notes/09_sobolev.pdf
It bears repeating that there are many other types of convergence than pointwise.
This post imported from StackExchange Mathematics at 2014-06-01 19:37 (UCT), posted by SE-user paul garrett