Prove this formula $\frac{1-r\cos(x)}{1-2r\cos(x)+r^2}= 1+\sum_{n=1}^{+\infty}r^{n}\cos\left(nx\right)$
There is possibly a better way, and I think this was discussed as solved example in tristam needham's book(*). Any who, we begin with geometric series:
$$ \frac{1}{1-x} = \sum_{j=0}^{\infty} x^j$$
Sub: $ x \to re^{ i \theta}$ and simplfy
$$ \frac{1}{(1- r \cos \theta) - i \sin \theta} = \sum_{j=0}^{\infty} r^j e^{i j\theta} \tag{2}$$
For LHS, by multiplying with complex conjguate
$$ \frac{1}{(1-r \cos \theta) - i r\sin \theta} = \frac{ (1-r \cos \theta) + i \sin \theta}{ 2 - 2 r \cos \theta+r^2} \tag{1}$$
Equating real part in (1) to real part in (2),
$$ \frac{1 - r \cos \theta}{ 2 - 2r \cos \theta + r^2} = \sum_{j=0}^{\infty} r^j \cos j \theta$$
Done!
Another identity could be made by equating imaginary parts
*: Indeed it was! See page-78, 79 of Visual Complex Analysis to see how this is simply the fourier series corresponding to the geometric series. Simply two ways to view a function: As an infinite trignometric sum or as a infinite polynomial series. Pretty neat.
Similar to Buraian's answer, a method I enjoy using is using the equivalent series for $\sin$, and then adding $C+iS$, as follows:
Let $$\begin{align} C&=1+r\cos x+r^2\cos2x+r^3\cos3x+\cdots\\ S&=r\sin x+r^2\sin2x+r^3\sin3x+\cdots\\ \end{align}$$ Then $$\begin{align} C+iS&=1+r(\cos x+i\sin x)+r^2(\cos 2x+i\sin2x)+r^3(\cos3x+i\sin3x)+\cdots\\ &=1+re^{ix}+(re^{ix})^2+(re^{ix})^3+\cdots\\ &=\frac{1}{1-re^{ix}}=\frac{(1-re^{-ix})}{(1-re^{ix})(1-re^{-ix})}=\frac{1-r\cos x+ri\sin x}{1-2r\cos x+r^2} \end{align}$$ Hence, equating real and imaginary parts we obtain $$\begin{align} C&=\frac{1-r\cos x}{1-2r\cos x+r^2}\\ S&=\frac{r\sin x}{1-2r\cos x+r^2}\\ \end{align}$$ I hope that was helpful and gives you a new and interesting method for attacking these sorts of problems.
$\cos(nx)=2\cos(x)\cos((n-1)x)-\cos((n-2)x)$, then $$\sum_{n=1}^\infty r^n\cos(nx)=2\cos(x)\sum_{n=1}^\infty r^n\cos((n-1)x)-\sum_{n=1}^\infty r^n \cos((n-2)x) $$ $$ =2r\cos(x)\sum_{n=0}^\infty r^n\cos(nx)-r^2\sum_{n=0}^\infty r^n \cos(nx) $$ Then, after some algebra, $$\sum_{n=1}^\infty r^n\cos(nx)=\frac{r\cos(x)-r^2}{1-2r\cos(x)+r^2}$$