# Creating symmetric polynomials of squares of variables?

I have five variables: a,b,c,d,e, for which I want to use the elementary symmetric polynomials of their squares:

s1 = a^2+b^2+c^2+d^2+e^2

s2 = a^2b^2 + a^2c^2 + ... + d^2e^2

and so on, to:

s5 = a^2b^2c^2d^2e^2.

Now, I can do this by hand, or by pulling out the coefficients of the polynomial

P = (x+a^2)(x+b^2)...(x+e^2)

However, is there a nicer way which uses Sage's own extensive symmetric polynomial functionality?

edit retag close merge delete

( 2018-07-26 15:40:04 -0600 )edit

Documentation and tutorials:

( 2018-07-26 15:40:41 -0600 )edit

Sort by ยป oldest newest most voted

You can probably proceed like the code below, or some version of it. I am not very familiar with symmetric polynomials in Sage, so this is something I could figure out in the 5min I looked at the docs. The main thing used is to determine the variables and use the .subs() method to substitute the squares of the variables. This can be extended so that it is all handled programmatically, instead of manually as I have done below.

sage: s = SymmetricFunctionAlgebra(QQ)
sage: f = s([2,1])
sage: p = f.expand(2); p
x0^2*x1 + x0*x1^2
sage: (x0, x1) = p.variables() # p.inject_variables() seems to be missing?
sage: p.subs(x0=x0^2, x1=x1^2)
x0^4*x1^2 + x0^2*x1^4


I must say the docs need a fair amount of work. I get zero idea from the documentation what s([2,1]) does. And there could be an elementary introduction in the SymmetricFunctionAlgebra function about the effect of the different basis, or at least some examples which show the differences.

more