Integration and differentiation of Fourier series

Fourier series (as with infinite series in general) cannot always be term-by-term differentiated. For general series we have the following theorem

Theorem: Term-by-term differentiation: If a series $\sum f_k(x_0)$ converges at some point $x_0\in [a,b]$ and the series of derivatives $g(x) = \sum f_k'(x)$ converges uniformly on $[a,b]$ then the series $f(x) = \sum f_k(x)$ converges uniformly for all $x\in[a,b]$ and $f(x)$ is differentiable with $f'(x) = g(x)$.

Your example fails this theorem dramatically as the derivative of the Fourier series of $x$ do not converge anywhere.

We also have some more specific results. The following theorem gives conditions for which this can be done for Fourier series:

Theorem (Term-by-term differentiation of Fourier series): If $f$ is a piecewise smooth function and if $f$ is also continuous on $[-L,L]$, then the Fourier series of $f$ can be term-by-term differentiated if $f(-L) = f(L)$.

The last condition is not satisfied when the Fourier series has a jump-discontinuity as $x=L$ so we in general we don't expect to be able to term-by-term differentiate a Fourier series that has a jump-discontinuity (thought the theorem does not rule it out). For your example of the Fourier series of $f(x) = x$ the first condition are satisfyed as $f$ is both smooth and continuous on $[-1,1]$ however $f(-1) \not= f(1)$ so the theorem does not apply.

For integration of Fourier series we have the following theorem

Theorem (Term-by-term integration of Fourier series): The Fourier series of a piecewise smooth function $f$ can always be term-by-term integrated to give a convergent series that always converges to the integral of $f$ for $x\in[-L,L]$.

Note that the resulting series does not have to be a Fourier series. For example if we have a Fourier series $f(x) = a_0 + \ldots$ with $a_0\not= 0$ then $\int f(x){\rm d}x = a_0x+ \ldots$ and the presence of the $a_0x$ term makes this not be a Fourier series (though for this example one can probably expand $x$ in a Fourier series to get such a series).

The proofs of the theorems above can be found in any good textbook on Fourier series. You can also find them in the following course notes (by P. Laval).