Partial sums of trig functions identity Using the fact that
$$\sum\limits_{k=0}^{n}z^k=\frac{1-z^{n+1}}{1-z}$$
I want to find the partial sum for multiples of the trig funtions, ie. $1+\cos(\theta)+\cos(2\theta)+\cdots+\cos(n\theta)$ and $\sin(\theta)+\sin(2\theta)+\cdots+\sin(n\theta)$ by substituting in $z=e^{i\theta}$
By substituting and expanding, the LHS becomes
$$1+\cos(\theta)+i\sin(\theta)+\cos(2\theta)+i\sin(2\theta)+\cdots+\cos(n\theta)+i\sin(n\theta)$$
and the right hand side becomes
$$\frac{1-(e^{i\theta})^{n+1}}{1-e^{i\theta}}=\frac{1-e^{(n+1)\theta i}}{1-e^{i\theta}}=\frac{1-(\cos(n\theta+\theta)+i\sin(n\theta+\theta))}{1-(\cos(\theta)+i\sin(\theta))}$$
Taking real coefficients, this becomes
$$1+\cos(\theta)+\cos(2\theta)+\cdots+\cos(n\theta)=\frac{1-\cos(n\theta+\theta)}{1-\cos(\theta)}$$
But apparently the result for $\cos$ is 
$$\frac{1}{2}+\frac{\sin(n+\frac{1}{2})\theta}{2\sin(\theta/2)}$$
and I can't get to this from what I've got.
 A: Hint
$$\frac{1-e^{(n+1)\theta i}}{1-e^{i\theta}}=\frac{e^{i\theta\frac{n+1}2}}{e^{i\theta/2}}\frac{e^{-i\theta\frac{n+1}2}-e^{i\theta\frac{n+1}2}}{e^{-i\theta/2}-e^{i\theta/2}}=e^{in\theta/2}\frac{\sin(\theta(n+1)/2)}{\sin(\theta/2)}$$
and use the trigonometric relation
$$\cos(a)\sin(b)=\frac12(\sin(a+b)+\sin(a-b))$$
A: You cannot take the real component of a complex fraction by taking the real of the numerator and dividing it by the real of the denominator.
Instead, multiply top and bottom by $(1-\cos\theta) -i\sin\theta$ to make the denominator real and then take the real of the resulting fraction. 
Thus, to go from your result to the given solution, calculate (making use of various trigonometric sum of angle and double angle identities)
$$\Re\left(\frac{(1-\cos(n+1)\theta+i\sin(n+1)\theta)(1-\cos\theta-i\sin\theta)}{2(1\color{red}{-\cos\theta})}\right)\\=\frac{1}{2}+\frac{\color{blue}{\sin(n+1)\theta\sin\theta+\cos\theta\cos(n+1)\theta}-\cos(n+1)\theta}{2(1\color{red}{-1+2\sin^2(\theta/2))}}\\=\frac{1}{2}+\frac{\color{blue}{\cos n\theta}-\cos(n+1)\theta}{4\sin^2(\theta/2)}\\=\frac{1}{2}+\frac{2\sin(\theta/2)\sin((n+1)\theta/2)}{4\sin^2(\theta/2)}\\=\frac{1}{2}+\frac{\sin((n+1)\theta/2)}{2\sin(\theta/2)}$$
