First time here? Check out the FAQ!

Ask Your Question
1

Substitute elementary symmetric functions in a polynomial

asked 9 years ago

giomasce gravatar image

Suppose I do the following:

sage: SF=SymmetricFunctions(QQ)
sage: poly=SF.e()(SF.from_polynomial(x^2+y^2))
sage: poly
e[1, 1] - 2*e[2]

Now I would like to substitute e[1, 1] in that expression. However:

sage: poly.subs({SF.e()[1, 1]: 1})
e[1, 1] - 2*e[2]

Does not do what I want (in fact it does not do anything). Is there a way to substitute a specific elementary polynomial?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 9 years ago

tmonteil gravatar image

updated 9 years ago

Looking at the source code, the problem seems to be that the subs method requires to be able to count the number of generators of the parent of poly (i.e. Symmetric Functions over Rational Field in the elementary basis), which is infinite.

Since this parent does not provide any ngens method (that is supposed to count the number of generators), the subs method just returns poly unmodified.

So, you have to write your own. I am not completely sure, but i can suggest the following approach: you can have a look at the map_item method of poly. Since you basically want to replace e[1,1] by e[0] (=1), you can do:

sage: def substitution(item, coeff):
....:    if item == Partition([1, 1]):
....:        return (Partition([0]), coeff)
....:    else:
....:        return (item, coeff)

sage: poly.map_item(substitution)
e[] - 2*e[2]
Preview: (hide)
link

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: 9 years ago

Seen: 401 times

Last updated: Feb 17 '16