Let #1+costheta+isintheta=r(cosalpha+isinalpha)#, here #r=sqrt((1+costheta)^2+sin^2theta)=sqrt(2+2costheta)#
= #sqrt(2+4cos^2(theta/2)-2)=2cos(theta/2)#
and #tanalpha=sintheta/(1+costheta)==(2sin(theta/2)cos(theta/2))/(2cos^2(theta/2))=tan(theta/2)# or #alpha=theta/2#
then #1+costheta-isintheta=r(cos(-alpha)+isin(-alpha))=r(cosalpha-isinalpha)#
and we can write #(1+costheta+isintheta)^n+(1+costheta-isintheta)^n# using DE MOivre's theorem as
#r^n(cosnalpha+isinnalpha+cosnalpha-isinnalpha)#
= #2r^ncosnalpha#
= #2*2^ncos^n(theta/2)cos((ntheta)/2)#
= #2^(n+1)cos^n(theta/2)cos((ntheta)/2)#