How did Euler obtain these two formulae? Are they correct? I am reading this book on trigonometric series, "Тригонометрические ряды от Эйлера до Лебега" (Trigonometric series from Euler to Lebesgue) , it is in Russian, and my Russian is abysmal. But there is a very interesting formula, it is:
$$\dfrac{1-r\cos(x)}{1-2r\cos(x)+r^2}=1+r\cos(x)+r^2\cos(2x)+r^{3}\cos(3x)...$$
$$\dfrac{r\sin(x)}{1-2r\cos(x)+r^2}=r\sin(x)+r^2\sin(2x)+r^{3}\sin(3x)...$$
As $r=1$ or $r=-1$
We have: $$-\dfrac{1}{2}=\cos(x)+2\cos(x)+3\cos(3x)+...$$
$$\dfrac{1}{2}=\cos(x)-2\cos(x)+3\cos(3x)+...$$
He integrated the second series and obtain the trigonometric series:
$$\dfrac{x}{2}=\sin(x)-\dfrac{1}{2}\sin(2x)+\dfrac{1}{3}\sin(3x)-...$$
The first and second series are divergent, so I think the result doesn't make sense, although the formal method of deriving it may seem correct.
The third series is correct on the interval $[\pi, -\pi]$, because the series expansion converges to that function (Correct me if I am wrong here, I haven't studied Fourier series).
I wish to ask how did he obtain the above formula? Are these formula incorrect because the issue of convergence? Also, which papers contain these results?

In Euler's time, the concept of convergence had not been properly defined. Much of his work lacks the rigor we are now used to.
At that time, even renowned mathematicians used to do things like manipulate divergent series freely and, at the end of their calculations, examine the result. If it made sense, they save it, if not, they discard it.
They developed an intuition about what could and could not be done, but they did not have the theory to back up many of the algebraic manipulations they did.
The formulas can be proved using $\displaystyle \cos(x) =\frac{e^{i x}+e^{-ix}}{2}$ and $\displaystyle\sin(x) =\frac{e^{i x} - e^{-ix}}{2i}$ to turn the sums into geometric series.
