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$?
 A: $$\sum_{n=1}^{\infty}p^n\cos nx=-1+\sum_{n=0}^{\infty}p^n\cos nx$$
$=$Re$\displaystyle(\sum_{n=0}^{\infty}p^ne^{inx})=$Re$\displaystyle(\sum_{n=0}^{\infty}(pe^ix)^n)$
As $\displaystyle|e^{ix}|=1,|e^{ix}p|=|p|<1$ using this,   $\displaystyle\sum_{n=0}^{\infty}(pe^ix)^n=\dfrac1{1-pe^{ix}}$ 
Using Euler Formula $$\dfrac1{1-pe^{ix}}=\frac1{1-p(\cos x+i\sin x)}=\frac1{(1-p\cos x)-i(p\sin x)}$$
Do you how to express $\displaystyle\frac1{a+ib}$ as $A+iB$ where $a,b,A,B$ are real
A: Since $0<p<1$, we have
\begin{eqnarray}
\sum_{n=1}^\infty p^n\cos(nx)&=&\Re\sum_{n=1}^\infty p^ne^{inx}=\Re\sum_{n=1}^\infty(pe^{ix})^n=\Re\frac{pe^{ix}}{1-pe^{ix}}=\Re\frac{pe^{ix}(1-pe^{-ix})}{|1-pe^{ix}|^2}\\
&=&p\Re\frac{-p+\cos x+i\sin x}{|1-p\cos x-ip\sin x|^2}=p\frac{-p+\cos x}{(1-p\cos x)^2+p^2\sin^2x}\\
&=&p\frac{\cos x-p}{1-2p\cos x+p^2\cos^2x+p^2\sin^2x}=\frac{p(\cos x-p)}{1+p^2-2p\cos x}\\
&=&\frac12\left(\frac{1-p^2}{1-2p\cos x+p^2}-1\right).
\end{eqnarray}
A: 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$$
