Rewording the question, we are asked to find an equation for 1+costheta+cos2theta+...+cosntheta
To solve this you need De Moirve's theorem: (cistheta)^n=cisntheta=cosntheta+isinntheta
Notice that the sum 1+cistheta+cis2theta+...+cisntheta is the same as 1+cistheta+(cistheta)^2+...+(cistheta)^n; a geometric series.
Seeing that the first term is 1, the ratio cistheta and the number of terms is n+1, we can represent this neatly:
1+cistheta+(cistheta)^2+...+(cistheta)^n=1((cistheta)^(n+1)-1)/(cistheta-1)
1+cistheta+(cistheta)^2+...+(cistheta)^n=((cis(n+1)theta)-1)/(cistheta-1)
I am going to use a trick when simplifying cistheta-1 here:
cisntheta-1=c
=1-2sin^2(ntheta/2)+i2sin(ntheta/2)cos(ntheta/2)-1
=-2sin(ntheta/2)(sin(ntheta/2)+icos(ntheta/2))
=-2sin(ntheta/2)(cos(90-ntheta/2)+isin(90-ntheta/2))
=-2sin(ntheta/2)cis(90-ntheta/2)
Notice that the left hand side can be expanded to:
1+costheta+isintheta+cos2theta+isin2theta+...+cosntheta+isinntheta, and that the real part of this is what we want. Thus, we need to find the real component of ((cis(n+1)theta)-1)/(cistheta-1)
((cis(n+1)theta)-1)/(cistheta-1)
(-2sin((n+1)theta/2)cis(90-(n+1)theta/2))/(-2sin(theta/2)cis(90-theta/2))
(sin((n+1)theta/2)cis(90-(n+1)theta/2-(90-theta/2)))/(sin(theta/2))
(sin((n+1)theta/2)cis(-ntheta/2))/(sin(theta/2))
Getting the real part, we see get
(sin((n+1)theta/2)cos(-ntheta/2))/(sin(theta/2))
(sin((n+1)theta/2)cos(ntheta/2))/(sin(theta/2))
and we're done