Ask Your Question

Revision history [back]

One liner:

sage: sum([c*prod(R.gens()[i-1] for i in L) for L,c in u])
e1^2*e4 + e3^2 - 2*e2*e4 - e1*e5 + e6

One liner:You can access the parts of u (or iterate over them, in particular make a sum from them):

sage: sum([c*prod(R.gens()[i-1] list(u)
[([3, 3], 1), ([4, 1, 1], 1), ([4, 2], -2), ([5, 1], -1), ([6], 1)]

Each element is a pair ([partition], coefficient). For each partition, you want to susbtitute the integer i by the monomial ei and then multiply them (together with the coefficient). You can get the list (actually a tuple) of ei as follows:

sage: R.gens()
(e1, e2, e3, e4, e5, e6)

So that you can recover ei from i as follows (note the shift by 1):

sage: R.gens()[0]
sage: R.gens()[1]
sage: R.gens()[2]

Mixing all those ingredients together, you get the following one-liner:

sage: sum(c*prod(R.gens()[i-1] for i in L) P) for L,c P,c in u])
e1^2*e4 + e3^2 - 2*e2*e4 - e1*e5 + e6