Ask Your Question
0

symmetric functions with restricted number of variables

asked 2022-07-12 06:06:20 +0200

Max Alekseyev gravatar image

I'd like to restrict computations with symmetric functions to just a given number of variables.

For example,

m = SymmetricFunctions(QQ).m()
(1 + m[1])^5

produces

m[] + 5*m[1] + 20*m[1, 1] + 60*m[1, 1, 1] + 120*m[1, 1, 1, 1] + 120*m[1, 1, 1, 1, 1] + 10*m[2] + 30*m[2, 1] + 60*m[2, 1, 1] + 60*m[2, 1, 1, 1] + 30*m[2, 2] + 30*m[2, 2, 1] + 10*m[3] + 20*m[3, 1] + 20*m[3, 1, 1] + 10*m[3, 2] + 5*m[4] + 5*m[4, 1] + m[5]

However, if it's known that there are just 3 variables, the above result should be truncated to:

m[] + 5*m[1] + 20*m[1, 1] + 60*m[1, 1, 1] + 10*m[2] + 30*m[2, 1] + 60*m[2, 1, 1] + 30*m[2, 2] + 30*m[2, 2, 1] + 10*m[3] + 20*m[3, 1] + 20*m[3, 1, 1] + 10*m[3, 2] + 5*m[4] + 5*m[4, 1] + m[5]

I can surely truncate a particular expression myself, but I need an automated way to do so for all intermediate results in lengthy computation.

I guess I need somehow to define a custom ring of symmetric functions, where result of multiplication is truncated to a given (fixed) number of variables.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-07-12 15:06:51 +0200

Max Alekseyev gravatar image

I've found a solution via implementing a new basis:

from sage.combinat.sf.sfa import SymmetricFunctionAlgebra_generic as SFA_generic
from sage.categories.morphism import SetMorphism

class SFA_mvar(SFA_generic):
    def __init__(self, Sym, nvar):
        SFA_generic.__init__(self, Sym, basis_name=
          f"Monomial functions with {nvar} variables", prefix=f'm{nvar}')
        self._m = Sym.m()
        self.nvar = nvar
        cat = HopfAlgebras(Sym.base_ring()).WithBasis()
        self.register_coercion(
          SetMorphism(Hom(self._m, self, cat), self._m_to_self))
        self._m.register_coercion(
          SetMorphism(Hom(self, self._m, cat), self._self_to_m))
    def _m_to_self(self, f):
        # f is a function in monomial basis and the output is in the mvar basis
        #return sum(c*self(self._m[d]) for d,c in f if len(d)<=self.nvar)
        return self._from_dict( {d:c for d,c in f if len(d)<=self.nvar} )
    def _self_to_m(self, f):
        # f is in the mvar basis and the output is in the monomial basis
        return self._m.sum(c*self._m(d) for d,c in f)
    class Element(SFA_generic.Element):
        pass

Then

m3 = SFA_mvar(SymmetricFunctions(QQ),3)
(1+m3[1])^5

produces

m3[] + 5*m3[1] + 20*m3[1, 1] + 60*m3[1, 1, 1] + 10*m3[2] + 30*m3[2, 1] + 60*m3[2, 1, 1] + 30*m3[2, 2] + 30*m3[2, 2, 1] + 10*m3[3] + 20*m3[3, 1] + 20*m3[3, 1, 1] + 10*m3[3, 2] + 5*m3[4] + 5*m3[4, 1] + m3[5]
edit flag offensive delete link more
0

answered 2022-07-13 13:09:36 +0200

dan_fulea gravatar image

One possibility is to extract by hand the coefficients for partitions with a maximal entry equal to three.

m = SymmetricFunctions(QQ).m()
p = (1 + m[1])^5
q = sum([0] + [p.coefficient(s) * m[s] for s in p.support() if max([0] + list(s)) <= 3])

(The elements in p.support() are partitions, above i have inserted some ad-hoc condition to insure a maximal entry equal to three. Some more partition-like methods may be uses. The lists with one element [0] in the sum and [0] in the max were added to avoid taking sum or max from an empty list.)

edit flag offensive delete link more

Comments

It needs this be done automatically for every intermediate result (not just the final one!) in computations. Also, your condition max([0] + list(s)) <= 3 should be replaced with len(s) <= 3.

Max Alekseyev gravatar imageMax Alekseyev ( 2022-07-13 13:35:49 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-07-12 06:06:20 +0200

Seen: 155 times

Last updated: Jul 13 '22