Prove for every $r\in(-1,1)$: $$\int_{0}^{\pi}\frac{r}{1-2r\cos x+r^2}\,dx=\int_{0}^{\pi}\frac{\cos x}{1-2r\cos x+r^2}\,dx$$
I tried proving that $$\int_{0}^{\pi}\frac{\cos x-r}{1-2r\cos x+r^2}dx=0$$ using variable substitution with $t=\tan(x/2)$ but it didn't get me anywhere.
We may notice that: $$ 1-2r\cos x+r^2 = (r-e^{ix})(r-e^{-ix}) \tag{1}$$ hence: $$ J(r)=\int_{0}^{\pi}\frac{r-e^{ix}}{1-2r\cos x+r^2}\,dx = \int_{0}^{\pi}\frac{dx}{r-e^{-ix}} \tag{2}$$ but for every $n\in\mathbb{N}\setminus\{0\}$ we have: $$ \int_{0}^{\pi}e^{-nix}\,dx = \left\{\begin{array}{rcl}-\frac{2i}{n}&\text{if}&n\equiv 1\pmod{2}\\ 0 &\text{if}& n\equiv 0\pmod{2}\end{array}\right. \tag{3}$$ hence by expanding the integrand function in the RHS of $(2)$ as a geometric series we have that, given $r\in(-1,1)$, $$ 0 = \text{Re } J(r) = \int_{0}^{\pi}\frac{r-\cos x}{1-2r\cos x+r^2}\,dx\tag{4} $$ as wanted.