Performing a differentiation on a Fourier series I'm tutoring a set of problem sheet to do with Fourier series and one problem is as follows:

The Fourier series for a sawtooth wave is,
$f(x)=x=-\sum^{\infty}_{n=1}\frac{2(-1)^n\sin(nx)}{n}$ for $-\pi < x<\pi$.
If you differentiate this you get 
$1=-2\sum^{\infty}_{n=1}(-1)^n\cos(nx)$ again for $-\pi < x<\pi$
What is wrong with this?

I have the solutions sheet and it says that it does not converge to 1 (fair enough, I plotted it to large $n$ and it sort of converges but oscillates between 0 and 2 in the interval) and then states ...

An assumption has been made that you can interchange the order of summation 
  and differentiation in the result stated.

It then goes to note that you can interchange the order of summation and integration
I don't understand the argument, can anyone shed some light on this?
 A: 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-Schwarz 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.
A: "What's wrong with this?" What is wrong is the following:
We are talking about the function $f(x):=x$ $\,(-\pi<x<\pi)$ continued periodically on all of ${\mathbb R}$, and we are presented with a series "representing $f$" which barely converges – in fact we need the oscillations of $\sin$ to make it converge. One cannot expect that such a series, resp. its formal (termwise) derivative, is able to represent $f'$ correctly. The relevant theorem here says: If the termwise differentiated series converges uniformly then it actually represents $f'$. In the case at hand the termwise differentiated series doesn't even converge, so it can't represent anything.
It is a fact of life that the Fourier series of a function $f$ with a jump continuity at a single point is badly convergent at all points, and a fortiori its formal derivatives are not able to represent the derivatives of $f$ even in points $x$ where $f$ is smooth.
A: My answer in 'Conceptual/Graphical understanding of the Fourier Series' could help.
You are computing the derivative of a function given by $y=x$ in $(-\pi,\pi]$. From the distributions' point of view the derivative will be $1$ except at $x=\pi$ where you'll get $-2\pi \delta(x-\pi)$ (from a jump discontinuity of $-2\pi$ because of the transition from $\pi$ to $-\pi$).
Of course we have to repeat this for every period $2\pi$ so that the full result will be : $$1 -2\pi \sum_{n\in \mathbb{Z}} \delta(x-\pi -2n\pi)$$ 
(it seems that you found a nice explication in Pete Olver's 'Fourier Series' pdf)
This is a 'Dirac comb' (note that the Fourier series in this link corresponds nearly to your result).
More exactly you got : 
$$\sum_{n=-\infty}^\infty \delta(x-a-2\pi n)=\frac 1{2\pi}+\frac 1{\pi}\sum_{n=1}^\infty \cos\left(n(x-a)\right)$$
in the special case $a=\pi$ producing $(-1)^n\cos(nx)$ at the right
I should add that this is a 'formal' result since $\sum^{\infty}_{n=1}(-1)^n\cos(nx)$ is not convergent!
Hoping all this clarified things,
A: "It then goes to note that you can interchange the order of summation and integration"
In your case an integration will get $n$ into the denominators, so the resulting series may converge.
