I am interested in the properties of Fourier series under integration and differentiation, and I've noticed a "strange" phenomenon. Suppose I have a Fourier series which I Integrate, and suppose that I can integrate it term by term.
$$f(x)=a_0+\sum_{n=1}^\infty a_n \cos(nx)+\sum_{n=1}^\infty b_n \sin(nx)$$
$$\int f(x)dx=C+a_0 x+\sum_{n=1}^\infty \frac{a_n}{n} \sin(nx)-\sum_{n=1}^\infty \frac{b_n}{n} \cos(nx) $$
Now because I want the integral to be represented as a Fourier series as well, I use the Fourier series for $x$:
$$x=\sum_{n=1}^\infty \frac{2}{\pi}\frac{(-1)^{n+1}}{n}\sin(nx)$$
So I have:
$$\int f(x)dx=C+\sum_{n=1}^\infty \left(\frac{2a_0}{\pi}\frac{(-1)^{n+1}}{n}+\frac{a_n}{n}\right)\sin(nx)+\sum_{n=1}^\infty \frac{b_n}{n}\cos(nx)$$
My problem is that upon differentiation (term by term), this series does not appear to give back the original Fourier series, as the constant term has been shifted into the cosine terms.
I think my mistake is the step I take converting the $x$ to a Fourier series, because it can't then be differentiated term by term (see this question). Am I correct? And does this mean the integral of a Fourier series cannot be another Fourier series?