Show that $\sum_{k=0}^{\infty} p^k\cos(kx) = \frac{1-p\cos(x)}{1-2p\cos(x)+p^2}$ using complex numbers. I have this equality that I'm trying to show. I have tried many times but I can't get it to work.
Could you please help me?
I would like to first make this finite sum equal something.
$$\sum_{k=0}^np^k\cos(kx) = S_{n}(p, x), -1 < p < 1 $$
And then use it to calculate the infinite sum, which should be the right side.
$$\lim_{n \to {\infty}} S_n(p, x)=\sum_{k=0}^{\infty}p^k\cos(kx) = \frac{1-p\cos(x)}{1-2p\cos(x)+p^2}$$
I would like to use complex numbers to show this.
EDIT: I know that I have to use Euler's identity, I just can't get the algebra to work.
I have gotten so far but I don't know how to continue.
$$\frac{(pe^{ix})^{(n+1)/2}((pe^{ix})^{-(n+1)/2}-(pe^{ix})^{(n+1)/2})}{(pe^{ix})^{1/2}((pe^{ix})^{-1/2}-(pe^{ix})^{1/2})}$$
Thank you in advance!
 A: If $p$ is a real number then $ p^k \cos(kx)$ is the real part of the complex number
$$
 p^k (\cos(kx) + i \sin(kx)) = p^k e^{ikx} = (pe^{ix})^k \, .
$$
So you can compute the geometric sum
$$
\sum_{k=0}^n (pe^{ix})^k = \frac{1-(pe^{ix})^{n+1}}{1-pe^{ix}} 
$$
and determine its real part. That is done by expanding the fraction with the conjugate of the denominator:
$$
 \frac{(1-(pe^{ix})^{n+1})(1-pe^{-ix})}{(1-pe^{ix})(1-pe^{-ix})}
= \frac{1 -p^{n+1} e^{i(n+1)x} -pe^{-ix} + p^{n+2}e^{inx}  }{1-2p \cos(x) + p^2} \, .
$$
It follows that
$$
\sum_{k=0}^np^k\cos(kx) = \frac{1 - p^{n+1}\cos((n+1)x) - p \cos(x) + p^{n+2} \cos(nx)}{1-2p \cos(x) + p^2} \, .
$$
A: Hint:
$p^k\cos(kx)=\operatorname{Re}\bigl(p^k\mathrm e^{ikx}\bigr)=\operatorname{Re}\bigl(p\mathrm e^{ix}\bigr)^k$, so you just have to calculate the sum of a geometric series, and take its real part.
A: This is an attempt
to verify this result directly.
$\begin{array}\\
S(n, p, x)
&=(1-2p \cos(x) + p^2)\sum_{k=0}^np^k\cos(kx)\\
&=\sum_{k=0}^np^k\cos(kx)-2p \cos(x)\sum_{k=0}^np^k\cos(kx)+p^2\sum_{k=0}^np^k\cos(kx)\\
&=\sum_{k=0}^np^k\cos(kx)-\sum_{k=0}^n2p^{k+1} \cos(x)\cos(kx)+\sum_{k=0}^np^{k+2}\cos(kx)\\
&=\sum_{k=0}^np^k\cos(kx)-\sum_{k=0}^np^{k+1}(\cos((k+1)x)\\
&\qquad+\cos((k-1)x)+\sum_{k=0}^np^{k+2}\cos(kx)\\
&=\sum_{k=0}^np^k\cos(kx)-\sum_{k=0}^np^{k+1}\cos((k+1)x)\\
&\qquad-\sum_{k=0}^np^{k+1}\cos((k-1)x)+\sum_{k=0}^np^{k+2}\cos(kx)\\
&=\sum_{k=0}^np^k\cos(kx)-\sum_{k=1}^{n+1}p^{k}\cos(kx)-p\cos(-x)\\
&\qquad-\sum_{k=0}^{n-1}p^{k+2}\cos(kx)+\sum_{k=0}^np^{k+2}\cos(kx)\\
&=1-p^{n+1}\cos((n+1)x)-p\cos(x)+p^{n+2}\cos(nx)\\
\end{array}
$
And it works!
