I am trying to integrate the Fourier series of $$f(x) = x,-\pi<x<\pi.$$ Using complex exponentials to find the series, I get the series $$\frac{2}{\pi} \sum_{n=1}^{\infty}\frac{(-1)^{n+1}}{n} \cdot \sin(nx).$$
Integrating will add an $n$ to the denominator and result in more rapid convergence. But when I try to integrate this series, I just end up with the series times the integral $\int_{-\pi}^{\pi}\sin(nx) \,dx$, which makes everything zero. If I integrate it termwise, I also end up with zero.
Does anybody know what mistake I am making? I am told by that integrating this, one can obtain $$\sum_{n=1}^{\infty}\frac{(-1)^{n+1}}{n^2} = 1 - \frac{1}{4} + \frac{1}{9}-\frac{1}{16} + ... = \frac{\pi^2}{12}.$$
Any help at all is appreciated, as I am quite flustered that this simple problem has stumped me.