#cos45+icos135+…i^n*cos(45+90n)+…i^40*cos3645=?#
Sum of First 4 terms
#sum_(r=1)^(r=4)S_r#
#=cos45+icos135+i^2cos(45+90xx2)+i^3cos(45+90xx3)#
#=cos45-icos45+cos45-icos45#
#=1/sqrt2-i/sqrt2+1/sqrt2-i/sqrt2=sqrt2(1-i)#
Sum of Second 4 terms
#sum_(r=5)^(r=9)S_r#
#=i^4cos(45+90xx4)+i^5cos(45+90xx5)+i^6cos(45+90xx6)+i^7cos(45+90xx7)#
#=cos45-icos45+cos45-icos45#
#=1/sqrt2-i/sqrt2+1/sqrt2-i/sqrt2=sqrt2(1-i)#
Considering this way we get 10 groups of 4terms having same sum.
So our sum
#S=sum_(r=1)^(r=40)S_r+i^40*cos3645#
#=10xxsqrt2(1-i)+cos(45+90xx40)#
#=10sqrt2(1-i)+cos45#
#=10sqrt2(1-i)+1/sqrt2#