from math import pi, e
def F(array, x):
value = 0
for i in xrange(len(array)):
value += array[i] * (x**i)
return value
W =[]
for i in xrange(8):
W.append(pow(e, (2*pi*1j*i) / 8))
#print W
ansa, ansb = [], []
a = [1,1,2,0,0,0,0,0]
b = [1,3,0,0,0,0,0,0]
for i in xrange(8):
ansa.append(F(a, W[i]))
ansb.append(F(b, W[i]))
print ansa
print
print ansb
ZnJvbSBtYXRoIGltcG9ydCBwaSwgZQpkZWYgRihhcnJheSwgeCk6CiAgICB2YWx1ZSA9IDAKICAgIGZvciBpIGluIHhyYW5nZShsZW4oYXJyYXkpKToKICAgICAgICB2YWx1ZSArPSBhcnJheVtpXSAqICh4KippKQogICAgcmV0dXJuIHZhbHVlCgpXID1bXQpmb3IgaSBpbiB4cmFuZ2UoOCk6CiAgICBXLmFwcGVuZChwb3coZSwgKDIqcGkqMWoqaSkgLyA4KSkKI3ByaW50IFcKCmFuc2EsIGFuc2IgPSBbXSwgW10KYSA9IFsxLDEsMiwwLDAsMCwwLDBdCmIgPSBbMSwzLDAsMCwwLDAsMCwwXQpmb3IgaSBpbiB4cmFuZ2UoOCk6CiAgICBhbnNhLmFwcGVuZChGKGEsIFdbaV0pKQogICAgYW5zYi5hcHBlbmQoRihiLCBXW2ldKSkKcHJpbnQgYW5zYQpwcmludApwcmludCBhbnNiCiAgICAgICAgCg==
[(4+0j), (1.7071067811865477+2.7071067811865475j), (-1+1.0000000000000002j), (0.2928932188134522-1.2928932188134525j), (2-3.6739403974420594e-16j), (0.2928932188134529+1.292893218813453j), (-1.0000000000000002-0.9999999999999992j), (1.7071067811865466-2.707106781186548j)]
[(4+0j), (3.121320343559643+2.1213203435596424j), (1.0000000000000002+3j), (-1.1213203435596424+2.121320343559643j), (-2+3.6739403974420594e-16j), (-1.1213203435596428-2.1213203435596424j), (0.9999999999999994-3j), (3.121320343559642-2.121320343559643j)]