# 2204.py import cmath def sommacoseni (x,*la): b=c=0; z1=cmath.exp(x*1j); z2=1/z1 for a in reversed(la): b=b*z1+a; c=c*z2+a return (b+c)/2 print sommacoseni(0.2,2,3,0,4,7,1,3) # (14.7458647279+0j)