TITLE: The sum of the series $ \cos(x)-\cos(2x)+\cos(3x)-...$
QUESTION [5 upvotes]: In the book "The spirit of mathematical analysis" of Martin Ohm, the author gives an example of differentiating an infinite series and obtaining an absurd result (page 2)
From the series
$\frac{x}{2}=\sin(x)-\frac{1}{2}\sin2x+\frac{1}{3}\sin(3x)-...$ (1)
If one differentiate terms by terms, one obtains this series 
$\frac{1}{2}=\cos(x)-\cos(2x)+\cos(3x)-...$          (2)
The author said the last series is divergent, therefore this result is nonsensical.
My question is how does one obtain the first series? What transformation do you perform to obtain $\frac{x}{2}$ on the left hand side.
My second question how can we prove that the second series is divergent?

REPLY [2 votes]: For the first series, consider that you look for the imaginary part of
$$\sum_{n=1}^\infty (-1)^{n-1} \frac {e^{i n x}} n=\sum_{n=1}^\infty (-1)^{n-1} \frac {\left( e^{i x}\right)^n} n=\log \left(1+e^{i x}\right)$$So
$$\sum_{n=1}^\infty (-1)^{n-1} \frac {\sin(n x)} n=\frac{1}{2} i \left(\log \left(1+e^{-i x}\right)-\log \left(1+e^{i x}\right)\right)=\frac{1}{2} \left(\arg \left(1+e^{i x}\right)- \arg \left(1+e^{-i x}\right)\right)=\frac x 2$$ provided $-\pi \leq x \leq \pi$ .