Simplify a series of $\cos x$ or $\sin x$ Suppose we have this series 
$$\sum\limits_{k=0}^n a^k \cos(kx) = 1 + a\cos(x) + a^2 \cos(2x) + a^3 \cos(3x) + \cdots + a^n\cos(nx)$$
What should we do to simplify this?

let $a$ be a real number and $z = \cos t + i \sin t$.
this looks like the real part of $$1 + az + (az)^2 + \dots + (az)^n = \frac{1- (az)^{n+1}}{1-az} $$  thanking the real part, we get 
$$1 +a\cos t + a^2 \cos 2t + \dots+a^n \cos nt = \text{real part} \frac{1- (az)^{n+1}}{1-az}$$
finding the real part of $$\frac{1- (az)^{n+1}}{1-az}=
\frac{1-a^{n+1}\cos (n+1)t - ia^{n+1}\sin(n+1)t }{1 - a\cos t -ia \sin t}
=\frac{[1-a^{n+1}\cos(n+1)t][1-a\cos t]-a^{n+2}\sin (n+1)t \sin t + i\dots}{(1-a\cos t)^2+a^2\sin^2t} = \frac{1-a^{n+1}\cos(n+1)t-a\cos t+a^{n+2}\cos(n+2)t + i\dots}{(1-2a\cos t+a^2)}$$
this is what i come up with 
$$ 1 +a\cos t + a^2 \cos 2t + \dots+a^n \cos nt = \frac{1-a^{n+1}\cos(n+1)t-a\cos t+a^{n+2}\cos(n+2)t}{(1-2a\cos t+a^2)}$$
