ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 26 Jul 2018 15:40:41 -0500Creating symmetric polynomials of squares of variables?http://ask.sagemath.org/question/9737/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?Thu, 31 Jan 2013 15:14:19 -0600http://ask.sagemath.org/question/9737/creating-symmetric-polynomials-of-squares-of-variables/Comment by slelievre for <p>I have five variables: a,b,c,d,e, for which I want to use the elementary symmetric polynomials of their squares:</p>
<p>s1 = a^2+b^2+c^2+d^2+e^2</p>
<p>s2 = a^2b^2 + a^2c^2 + ... + d^2e^2</p>
<p>and so on, to: </p>
<p>s5 = a^2b^2c^2d^2e^2.</p>
<p>Now, I can do this by hand, or by pulling out the coefficients of the polynomial</p>
<p>P = (x+a^2)(x+b^2)...(x+e^2)</p>
<p>However, is there a nicer way which uses Sage's own extensive symmetric polynomial functionality?</p>
http://ask.sagemath.org/question/9737/creating-symmetric-polynomials-of-squares-of-variables/?comment=43172#post-id-43172Documentation and tutorials:
- [SageMath documentation on symmetric functions](http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/sf/sf.html)
- [Demo on symmetric functions](https://more-sagemath-tutorials.readthedocs.io/en/latest/demo-symmetric-functions.html)
- [Tutorial on symmetric functions](https://more-sagemath-tutorials.readthedocs.io/en/latest/tutorial-symmetric-functions.html)Thu, 26 Jul 2018 15:40:41 -0500http://ask.sagemath.org/question/9737/creating-symmetric-polynomials-of-squares-of-variables/?comment=43172#post-id-43172Comment by slelievre for <p>I have five variables: a,b,c,d,e, for which I want to use the elementary symmetric polynomials of their squares:</p>
<p>s1 = a^2+b^2+c^2+d^2+e^2</p>
<p>s2 = a^2b^2 + a^2c^2 + ... + d^2e^2</p>
<p>and so on, to: </p>
<p>s5 = a^2b^2c^2d^2e^2.</p>
<p>Now, I can do this by hand, or by pulling out the coefficients of the polynomial</p>
<p>P = (x+a^2)(x+b^2)...(x+e^2)</p>
<p>However, is there a nicer way which uses Sage's own extensive symmetric polynomial functionality?</p>
http://ask.sagemath.org/question/9737/creating-symmetric-polynomials-of-squares-of-variables/?comment=43169#post-id-43169Possibly related questions (including the present one):
- [Ask Sage 9737 (2013-01): Symmetric polynomials of squares of variables](https://ask.sagemath.org/question/9737)
- [Ask Sage 32569 (2016-02): Symmetric polynomial as polynomial on elementary symmetric polynomials](https://ask.sagemath.org/question/32569)
- [Ask Sage 33378 (2016-05): Symmetric function as polynomial on elementary symmetric functions](https://ask.sagemath.org/question/33378)
- [Ask Sage 42872 (2018-07): Symmetric polynomial in terms of elementary symmetric polynomials](https://ask.sagemath.org/question/42872)Thu, 26 Jul 2018 15:40:04 -0500http://ask.sagemath.org/question/9737/creating-symmetric-polynomials-of-squares-of-variables/?comment=43169#post-id-43169Answer by ppurka for <p>I have five variables: a,b,c,d,e, for which I want to use the elementary symmetric polynomials of their squares:</p>
<p>s1 = a^2+b^2+c^2+d^2+e^2</p>
<p>s2 = a^2b^2 + a^2c^2 + ... + d^2e^2</p>
<p>and so on, to: </p>
<p>s5 = a^2b^2c^2d^2e^2.</p>
<p>Now, I can do this by hand, or by pulling out the coefficients of the polynomial</p>
<p>P = (x+a^2)(x+b^2)...(x+e^2)</p>
<p>However, is there a nicer way which uses Sage's own extensive symmetric polynomial functionality?</p>
http://ask.sagemath.org/question/9737/creating-symmetric-polynomials-of-squares-of-variables/?answer=14501#post-id-14501You 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.Thu, 31 Jan 2013 20:33:30 -0600http://ask.sagemath.org/question/9737/creating-symmetric-polynomials-of-squares-of-variables/?answer=14501#post-id-14501