I want to implement the Swinnerton dyer polynomials in python with the library sympy. Now I came up with the following code:
from itertools import *
from sympy import *
x = symbols("x")
y = symbols("y")
def swinnerton_dyer(N):
combos = list(product([0,1],repeat=N))
lin_facs = []
p = Poly(1,y)
for combo in combos:
lin_fac = y
for i in range(len(combo)):
lin_fac += (-1)**combo[i] * sqrt(x+i)
lin_facs.append(lin_fac)
p*=lin_fac
The code works fine so far.
My question is: Is it possible to calculate this directly in the product
function from itertools?