Prove that $\forall r\in (-1,1)$, $\frac{1-r^2}{1-2r\cos x+r^2}=1+2\sum_{n=1}^{\infty} r^n\cos nx$.
My approach: simplify the equation to $$-r^2=-r\cos x+\sum_{n=1}^{\infty}r^n(1-2r\cos x+r^2)\cos nx \ \ \ \ (\star )$$ Assime $r\neq 0$, define $f(x):=-\cos x+\sum_{n=1}^{\infty}r^{n-1}(1-2r\cos x+r^2)\cos nx$, then $f(0)=-1+\sum_{n=1}^{\infty}r^{n-1}(1-r)^2=-1+(1-r)^2\frac{1}{1-r}=-r$ and $(\star )$ hold. But
$$f'(x)=\sin x+\sum_{n=1}^{\infty}r^{n-1}((1+2r\sin x+r^2)\cos nx-n(1-2r\cos x+r^2)\sin nx)$$ Since power series can derivate term by term in its convergence interval. Since $(\star )$ LHS doesn't depend on $x$ there must be $f'(x)=0$ for $r\in (-1,1)$. But I have no idea how to prove $f'(x)=0$ here.
Also, I think my approach is too "artificial", and there should be a better solution exists. I have tried to wrote $\cos x$ in expansion form and use telescoping techniques, but without success.
Can anybody help? Thanks in advance.
Use complex numbers and the sum of a geometric series:
$$2\sum_{n=1}^\infty r^ne^{inx}=\frac{2re^{ix}}{1-re^{ix}}=\frac{2re^{ix}(1-re^{-ix})}{|1-re^{ix}|}=\frac{2re^{ix}-2r^2}{(1-r\cos x)^2+(r\sin x)^2}=$$
$$=\frac{2r(\cos x-r)+2ri\sin x}{1+r^2-2r\cos x}$$
and now take the real parts...