And I just don't see where something is divided by zero or have power of complex number, all variables have only real positive value.
Not true. On the first iteration of
for i in range(0,k-1):
sum+=(ser(i*2*3.1415926/k))**8
you have i=0
, so the argument to ser
is 0, so a == 0
, and you have (a**(2j-1))
, which takes 0 to a complex power.
Maybe you meant a**(2*j-1)
? Python uses j
for the unit imaginary, and so 2j-1
is a complex number.