What steps are taken to make this complex expression equal this? How would you show that $$\sum_{n=1}^{\infty}p^n\cos(nx)=\frac{1}{2}\left(\frac{1-p^2}{1-2p\cos(x)+p^2}-1\right)$$ when $p$ is positive, real, and $p<1$?

Note that:
$$\sum_{n=1}^\infty p^n\cos(nx)=\Re{(\sum_{n=1}^\infty}p^ne^{inx})=\Re({\frac{1}{1-pe^{ix}}})$$
$$\forall |pe^{ix}|=|p|<1$$
