1 | initial version |
This is a polynomial of degree $5$ in the variables $\lambda_n$ where the sum of the indices in each monomial is $t_1+t_2+t_3+t_4+t_5$.
It seems Sage doesn't easily generate partitions of $n$ into $k$ nonnegative integers, so we implement this helper function for it (we partition $n+k$ into $k$ positive integers and subtract 1 from each one):
def nonnegative_partitions(n, length):
from itertools import permutations
for part in Partitions(n+length, length=length):
seen = set([])
for shuffled_part in permutations(part):
shuffled_part = tuple(x-1 for x in shuffled_part)
if not shuffled_part in seen:
yield shuffled_part
seen.add(shuffled_part)
Here we also take care that $4 = 2+2$ is counted only once. You can implement the formula as:
def S(t):
F2 = GF(2)
Lamb = PolynomialRing(F2, sum(t)+1, names='l_')
lamb = Lamb.gens()
result = Lamb.zero()
for indices in nonnegative_partitions(sum(t), length=5):
(i,j,h,m,idc) = indices
for k in nonnegative_partitions(i-t[0], length=4):
M1 = F2(binomial(t[4]-k[0], k[0]) * binomial(t[3]-k[1], k[1]) * binomial(t[2]-k[2], k[2]) * binomial(t[1]-k[3], k[3]))
for l in nonnegative_partitions(j-t[1]+k[3], length=3):
M2 = F2(binomial(t[4]-k[0]-l[0], l[0]) * binomial(t[3]-k[1]-l[1],l[1]) * binomial(t[2]-k[2]-l[2],l[2]))
for u in nonnegative_partitions(h-t[2]+k[2]+l[2], length=2):
M3 = F2(binomial(t[4]-k[0]-l[0]-u[0], u[0]) * binomial(t[3]-k[1]-l[1]-u[1],u[1]))
M4 = F2(binomial(sum(t)-sum([i,j,h,m]), m-t[3]+k[1]+l[1]+u[1]))
result += M1*M2*M3*M4*lamb[i]*lamb[j]*lamb[h]*lamb[m]*lamb[idc]
return result
For example,
sage: S((1,2,3,4,5))
l_3^5 + l_2*l_3^3*l_4 + l_1*l_3^2*l_4^2 + l_2^2*l_3^2*l_5 + l_1*l_3^3*l_5 + l_1*l_2*l_3*l_4*l_5 + l_0*l_3^2*l_4*l_5 + l_1^2*l_4^2*l_5 + l_1*l_2^2*l_5^2 + l_0*l_1*l_4*l_5^2 + l_1*l_2*l_3^2*l_6 + l_0*l_3^3*l_6 + l_1^2*l_2*l_5*l_6 + l_1^2*l_3^2*l_7 + l_0*l_1*l_3*l_4*l_7 + l_0*l_1*l_2*l_5*l_7 + l_0^2*l_3*l_5*l_7 + l_0*l_1*l_2*l_3*l_9 + l_0^2*l_3^2*l_9 + l_0*l_1^2*l_3*l_10
2 | No.2 Revision |
This is a polynomial of degree $5$ in the noncommutative variables $\lambda_n$ where the sum of the indices in each monomial is $t_1+t_2+t_3+t_4+t_5$.
It seems Sage doesn't easily generate partitions of $n$ into $k$ nonnegative integers, so we implement this helper function for it (we partition $n+k$ into $k$ positive integers and subtract 1 from each one):
def nonnegative_partitions(n, length):
from itertools import permutations
for part in Partitions(n+length, length=length):
seen = set([])
for shuffled_part in permutations(part):
shuffled_part = tuple(x-1 for x in shuffled_part)
if not shuffled_part in seen:
yield shuffled_part
seen.add(shuffled_part)
Here we also take care that $4 = 2+2$ is counted only once. You can implement the formula as:
def S(t):
F2 = GF(2)
Lamb = PolynomialRing(F2, FreeAlgebra(F2, sum(t)+1, names='l_')
lamb = Lamb.gens()
result = Lamb.zero()
for indices in nonnegative_partitions(sum(t), length=5):
(i,j,h,m,idc) = indices
for k in nonnegative_partitions(i-t[0], length=4):
M1 = F2(binomial(t[4]-k[0], k[0]) * binomial(t[3]-k[1], k[1]) * binomial(t[2]-k[2], k[2]) * binomial(t[1]-k[3], k[3]))
for l in nonnegative_partitions(j-t[1]+k[3], length=3):
M2 = F2(binomial(t[4]-k[0]-l[0], l[0]) * binomial(t[3]-k[1]-l[1],l[1]) * binomial(t[2]-k[2]-l[2],l[2]))
for u in nonnegative_partitions(h-t[2]+k[2]+l[2], length=2):
M3 = F2(binomial(t[4]-k[0]-l[0]-u[0], u[0]) * binomial(t[3]-k[1]-l[1]-u[1],u[1]))
M4 = F2(binomial(sum(t)-sum([i,j,h,m]), m-t[3]+k[1]+l[1]+u[1]))
result += M1*M2*M3*M4*lamb[i]*lamb[j]*lamb[h]*lamb[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5 + l_3*l_2*l_4*l_1*l_5 + l_3*l_2*l_7*l_0*l_3 + l_3^3*l_1*l_5 + l_3^5 + l_2*l_3^3*l_4 + l_1*l_3^2*l_4^2 + l_2^2*l_3^2*l_5 + l_1*l_3^3*l_5 + l_1*l_2*l_3*l_4*l_5 + l_0*l_3^2*l_4*l_5 + l_1^2*l_4^2*l_5 + l_1*l_2^2*l_5^2 + l_0*l_1*l_4*l_5^2 + l_1*l_2*l_3^2*l_6 + l_0*l_3^3*l_6 + l_1^2*l_2*l_5*l_6 + l_1^2*l_3^2*l_7 + l_0*l_1*l_3*l_4*l_7 + l_0*l_1*l_2*l_5*l_7 + l_0^2*l_3*l_5*l_7 + l_0*l_1*l_2*l_3*l_9 + l_0^2*l_3^2*l_9 + l_0*l_1^2*l_3*l_10
l_3*l_5*l_1*l_3^2 + l_3*l_6*l_0*l_1*l_5 + l_4*l_0*l_3^2*l_5 + l_4*l_0*l_3*l_5*l_3 + l_4*l_0*l_5*l_3^2 + l_4*l_0*l_7*l_1*l_3 + l_4*l_2*l_3*l_1*l_5 + l_4*l_3*l_0*l_3*l_5 + l_4*l_3*l_0*l_5*l_3 + l_4*l_3*l_1*l_2*l_5 + l_4*l_3*l_2*l_3^2 + l_4*l_3*l_5*l_0*l_3 + l_4^2*l_1*l_3^2 + l_4*l_7*l_1*l_0*l_3 + l_5*l_0*l_3*l_2*l_5 + l_5*l_0*l_4*l_1*l_5 + l_5*l_0*l_7*l_0*l_3 + l_5*l_1*l_3^3 + l_5*l_3*l_1*l_3^2 + l_5*l_4*l_3*l_0*l_3 + l_5*l_6*l_1*l_0*l_3 + l_6*l_0*l_3*l_1*l_5 + l_6*l_3*l_0*l_1*l_5 + l_6*l_3^2*l_0*l_3 + l_6*l_5*l_1*l_0*l_3 + l_8*l_0*l_1*l_3^2 + l_8*l_1*l_0*l_1*l_5 + l_8*l_1*l_3*l_0*l_3 + l_9*l_0*l_3*l_0*l_3
When you compute S(t)
for several t
with different sum(t)
then they will belong to different FreeAlgebra
s (with different number of generators $\lambda_n$), but the names of the generators are "compatible", so adding elements should coerce them into the larger parent FreeAlgebra
. Unfortunately this doesn't work (yet), so you have to use a workaround like this:
sage: S_1 = S((1,1,1,3,4)); S_2 = S((1,2,3,4,5)); S_3 = S((1,1,1,6,6))
sage: S_2.parent()
Free Algebra on 16 generators (l_0, l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8, l_9, l_10, l_11, l_12, l_13, l_14, l_15) over Finite Field of size 2
sage: S_2.parent() == S_3.parent() # the biggest FreeAlgebra that contains all of them
True
sage: S_2.parent()(str(S_1)) + S_2 + S_3
l_1^3*l_3*l_4 + l_1^3*l_4*l_3 + l_1^3*l_5*l_2 + l_1^3*l_6^2 + l_1^3*l_7*l_5 + l_1^3*l_9*l_3 + l_1^2*l_2*l_3^2 + l_1^2*l_2*l_5*l_6 + l_1^2*l_3^2*l_2 + l_1^2*l_3*l_4*l_1 + l_1^2*l_3*l_5^2 + l_1^2*l_3*l_7*l_3 + l_1^2*l_4*l_3*l_6 + l_1^2*l_4^2*l_5 + l_1^2*l_5*l_0*l_3 + l_1^2*l_5*l_1*l_2 + l_1^2*l_5*l_3*l_5 + l_1^2*l_7*l_0*l_1 + l_1^2*l_7*l_3^2 + l_1^2*l_8*l_0*l_5 + l_1^2*l_8*l_2*l_3 + l_1*l_2*l_1*l_3^2 + l_1*l_2*l_1*l_5*l_6 + l_1*l_2*l_3^2*l_6 + l_1*l_2*l_3*l_6*l_3 + l_1*l_2*l_4*l_3*l_5 + l_1*l_2*l_4*l_5*l_3 + l_1*l_2*l_5*l_2*l_5 + l_1*l_2*l_6*l_3^2 + l_1*l_2*l_7*l_0*l_5 + l_1*l_2*l_8*l_1*l_3 + l_1*l_2*l_9*l_0*l_3 + l_1*l_3*l_0*l_3^2 + l_1*l_3*l_0*l_5*l_6 + l_1*l_3*l_2*l_3*l_1 + l_1*l_3*l_2*l_3*l_6 + l_1*l_3*l_2*l_4*l_5 + l_1*l_3^2*l_0*l_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