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.Mon, 25 May 2015 16:04:46 -0500elementary symmetric functionshttp://ask.sagemath.org/question/26923/elementary-symmetric-functions/Hi, this is a continuation (though self-contained) on a previous question I luckily received an answer for;
http://ask.sagemath.org/question/26913/sfrom_polynomialf-convert-a-polynomial-to-symmetric-functions-but-with-a-parameter/
For those of you experts that know Maxima, I essentially want to do the following (to a polynomial);
elem([2,f1,f2],elem([2,e1,e2],x+y+a+b,[x,y]),[a,b])
which results in: `(x+y)+(a+b) = e1 + f1`, where Sage would (which is what I'm trying to do) return `e[1] + f[1]`.
This is what I tried (among others), mostly from the above referenced link;
P.<x,y>=PolynomialRing(QQ['a','b'])
[a,b]=P.base_ring().gens()
S=SymmetricFunctions(P.base_ring())
exy=S.elementary()
f=x+y+a+b
exy._prefix='exy'
o=exy(S.from_polynomial(f))
P2.<a,b>=PolynomialRing(QQ['x','y'])
[x,y]=P2.base_ring().gens()
S2.SymmetricFunctions(P2.base_ring())
eab=S2.elementary()
eab._prefix='eab'
oo=eab(S2.from_polynomial(o)); oo
I was hoping to see: `eab[1]+exy[1]`, but here an error is thrown saying that the polynomial is not symmetric. I've tried also (trying) to establish a base ring `QQ['x','y','a','b']` and then subrings but that also doesn't seem to work for me.
I think Sage is great and I'm sure there's something equivalent to the very simple task done in Maxima. For instance, this
maxima.eval('elem:2')
oo=maxima.eval('elem([2,f1,f2],elem([2,e1,e2],x+y+a+b,[x,y]),[a,b])')
does return the proper answer, `e1+f1`, but I cannot use this result because I need to process it further with Sage and have not found a way to **translate** this Maxima type of object to a Sage polynomial - especially since the parsing seems to bring up errors for larger equations and my real equations are extremely large.
Thanks all, again!
Fri, 22 May 2015 23:26:52 -0500http://ask.sagemath.org/question/26923/elementary-symmetric-functions/Answer by FrédéricC for <p>Hi, this is a continuation (though self-contained) on a previous question I luckily received an answer for;</p>
<p><a href="http://ask.sagemath.org/question/26913/sfrom_polynomialf-convert-a-polynomial-to-symmetric-functions-but-with-a-parameter/">http://ask.sagemath.org/question/2691...</a></p>
<p>For those of you experts that know Maxima, I essentially want to do the following (to a polynomial);</p>
<pre><code>elem([2,f1,f2],elem([2,e1,e2],x+y+a+b,[x,y]),[a,b])
</code></pre>
<p>which results in: <code>(x+y)+(a+b) = e1 + f1</code>, where Sage would (which is what I'm trying to do) return <code>e[1] + f[1]</code>.</p>
<p>This is what I tried (among others), mostly from the above referenced link;</p>
<pre><code>P.<x,y>=PolynomialRing(QQ['a','b'])
[a,b]=P.base_ring().gens()
S=SymmetricFunctions(P.base_ring())
exy=S.elementary()
f=x+y+a+b
exy._prefix='exy'
o=exy(S.from_polynomial(f))
P2.<a,b>=PolynomialRing(QQ['x','y'])
[x,y]=P2.base_ring().gens()
S2.SymmetricFunctions(P2.base_ring())
eab=S2.elementary()
eab._prefix='eab'
oo=eab(S2.from_polynomial(o)); oo
</code></pre>
<p>I was hoping to see: <code>eab[1]+exy[1]</code>, but here an error is thrown saying that the polynomial is not symmetric. I've tried also (trying) to establish a base ring <code>QQ['x','y','a','b']</code> and then subrings but that also doesn't seem to work for me. </p>
<p>I think Sage is great and I'm sure there's something equivalent to the very simple task done in Maxima. For instance, this</p>
<pre><code>maxima.eval('elem:2')
oo=maxima.eval('elem([2,f1,f2],elem([2,e1,e2],x+y+a+b,[x,y]),[a,b])')
</code></pre>
<p>does return the proper answer, <code>e1+f1</code>, but I cannot use this result because I need to process it further with Sage and have not found a way to <strong>translate</strong> this Maxima type of object to a Sage polynomial - especially since the parsing seems to bring up errors for larger equations and my real equations are extremely large.</p>
<p>Thanks all, again!</p>
http://ask.sagemath.org/question/26923/elementary-symmetric-functions/?answer=26925#post-id-26925This is a bit more subtle. Here is a way.
sage: P.<x,y>=PolynomialRing(QQ['a','b'])
sage: BR = P.base_ring()
sage: S1 = SymmetricFunctions(QQ).e()
sage: S2 = SymmetricFunctions(BR).e()
sage: a,b = BR.gens()
sage: f = x+y+a+b
sage: step1 = S2.from_polynomial(f);step1
(a+b)*e[] + e[1]
sage: sum(S1(i).tensor(S1.from_polynomial(c)) for i, c in step1)
e[] # e[1] + e[1] # e[]
The key point to understand is that you need to explain sage in what your answer lives. Here it is the tensor product of symmetric functions with themselves.
EDIT: I have changed the answer above to use the elementary basis.Sat, 23 May 2015 05:06:38 -0500http://ask.sagemath.org/question/26923/elementary-symmetric-functions/?answer=26925#post-id-26925Comment by natepower for <p>This is a bit more subtle. Here is a way.</p>
<pre><code>sage: P.<x,y>=PolynomialRing(QQ['a','b'])
sage: BR = P.base_ring()
sage: S1 = SymmetricFunctions(QQ).e()
sage: S2 = SymmetricFunctions(BR).e()
sage: a,b = BR.gens()
sage: f = x+y+a+b
sage: step1 = S2.from_polynomial(f);step1
(a+b)*e[] + e[1]
sage: sum(S1(i).tensor(S1.from_polynomial(c)) for i, c in step1)
e[] # e[1] + e[1] # e[]
</code></pre>
<p>The key point to understand is that you need to explain sage in what your answer lives. Here it is the tensor product of symmetric functions with themselves.</p>
<p>EDIT: I have changed the answer above to use the elementary basis.</p>
http://ask.sagemath.org/question/26923/elementary-symmetric-functions/?comment=26937#post-id-26937Well I have a huge rational expression of polynomials, `p = N/D` each term in variables `r11,r12,r21,r22,z1,z2,Q` and if I put it in terms of symmetric functions, such as `r11+r21 = e1 = fn(Q,z1,b1)`,``r12+r22 = f1 = fn(Q,z2,b2)`, then I can greatly simplify `p`. Further reduction occurs with these symmetry relations, `r11*r21 = e2 = B1` and `r12*r22 = f2 =B2`. I then take the resulting `p` and exchange `z`'s for `A`'s with `z1^2=A1` and `z2^2=A2`. This results in a polynomial in only `A1,A2,B1,B2,Q` and is much simpler, as I've done this in Maxima. Further processing involves parameterization, etc. Hope that's clearly explained...Mon, 25 May 2015 16:04:46 -0500http://ask.sagemath.org/question/26923/elementary-symmetric-functions/?comment=26937#post-id-26937Comment by FrédéricC for <p>This is a bit more subtle. Here is a way.</p>
<pre><code>sage: P.<x,y>=PolynomialRing(QQ['a','b'])
sage: BR = P.base_ring()
sage: S1 = SymmetricFunctions(QQ).e()
sage: S2 = SymmetricFunctions(BR).e()
sage: a,b = BR.gens()
sage: f = x+y+a+b
sage: step1 = S2.from_polynomial(f);step1
(a+b)*e[] + e[1]
sage: sum(S1(i).tensor(S1.from_polynomial(c)) for i, c in step1)
e[] # e[1] + e[1] # e[]
</code></pre>
<p>The key point to understand is that you need to explain sage in what your answer lives. Here it is the tensor product of symmetric functions with themselves.</p>
<p>EDIT: I have changed the answer above to use the elementary basis.</p>
http://ask.sagemath.org/question/26923/elementary-symmetric-functions/?comment=26936#post-id-26936What do you want to do with the result ? What is not working as you would like ?Mon, 25 May 2015 14:52:43 -0500http://ask.sagemath.org/question/26923/elementary-symmetric-functions/?comment=26936#post-id-26936Comment by natepower for <p>This is a bit more subtle. Here is a way.</p>
<pre><code>sage: P.<x,y>=PolynomialRing(QQ['a','b'])
sage: BR = P.base_ring()
sage: S1 = SymmetricFunctions(QQ).e()
sage: S2 = SymmetricFunctions(BR).e()
sage: a,b = BR.gens()
sage: f = x+y+a+b
sage: step1 = S2.from_polynomial(f);step1
(a+b)*e[] + e[1]
sage: sum(S1(i).tensor(S1.from_polynomial(c)) for i, c in step1)
e[] # e[1] + e[1] # e[]
</code></pre>
<p>The key point to understand is that you need to explain sage in what your answer lives. Here it is the tensor product of symmetric functions with themselves.</p>
<p>EDIT: I have changed the answer above to use the elementary basis.</p>
http://ask.sagemath.org/question/26923/elementary-symmetric-functions/?comment=26935#post-id-26935Hi, I need >15 pts to upvote - so it says... Thanks for all the help but I guess I'll have to rely on Maxima. The math aspect makes sense, and tensor algebra isn't an issue, but I fail in being able to work with Sage. It will be interesting to learn the differences between the Sage and Maxima! Maybe I'll figure out some alternative in Sage later. Thanks!Mon, 25 May 2015 14:08:50 -0500http://ask.sagemath.org/question/26923/elementary-symmetric-functions/?comment=26935#post-id-26935Comment by FrédéricC for <p>This is a bit more subtle. Here is a way.</p>
<pre><code>sage: P.<x,y>=PolynomialRing(QQ['a','b'])
sage: BR = P.base_ring()
sage: S1 = SymmetricFunctions(QQ).e()
sage: S2 = SymmetricFunctions(BR).e()
sage: a,b = BR.gens()
sage: f = x+y+a+b
sage: step1 = S2.from_polynomial(f);step1
(a+b)*e[] + e[1]
sage: sum(S1(i).tensor(S1.from_polynomial(c)) for i, c in step1)
e[] # e[1] + e[1] # e[]
</code></pre>
<p>The key point to understand is that you need to explain sage in what your answer lives. Here it is the tensor product of symmetric functions with themselves.</p>
<p>EDIT: I have changed the answer above to use the elementary basis.</p>
http://ask.sagemath.org/question/26923/elementary-symmetric-functions/?comment=26934#post-id-26934Could you please also upvote my answers (just above the "accept" button).
There is no way to have `e_1 + f_1` as this has not meaning other than in the tensor product. By the way, the tensor product is a perfectly normal algebra, in which you can do many things.Mon, 25 May 2015 14:00:24 -0500http://ask.sagemath.org/question/26923/elementary-symmetric-functions/?comment=26934#post-id-26934Comment by natepower for <p>This is a bit more subtle. Here is a way.</p>
<pre><code>sage: P.<x,y>=PolynomialRing(QQ['a','b'])
sage: BR = P.base_ring()
sage: S1 = SymmetricFunctions(QQ).e()
sage: S2 = SymmetricFunctions(BR).e()
sage: a,b = BR.gens()
sage: f = x+y+a+b
sage: step1 = S2.from_polynomial(f);step1
(a+b)*e[] + e[1]
sage: sum(S1(i).tensor(S1.from_polynomial(c)) for i, c in step1)
e[] # e[1] + e[1] # e[]
</code></pre>
<p>The key point to understand is that you need to explain sage in what your answer lives. Here it is the tensor product of symmetric functions with themselves.</p>
<p>EDIT: I have changed the answer above to use the elementary basis.</p>
http://ask.sagemath.org/question/26923/elementary-symmetric-functions/?comment=26933#post-id-26933Hello, and thank you again!!
Can you modify your answer;
-use the elementary basis, `exy=Sym.elementary(); exy._prefix='exy'` and
`eab=Sym2.elementary(); eab._prefix='eab'`?
-provide a way to distinguish between the two spaces in the tensor product?
What I mean is, for my **real** equation `c1+c2+...+(x*y)+(x+y)+(a+b)+... + (a*b*x*y) == c1 + c2 + ... + exy[2] + exy[1] + eab[1] + ... + exy[2]*eab[2] == c1 + c2 + ... + exy2 + exy1 + eab1 + ... exy2*eab2`, with the result not indexed and `c1`, `c2`, etc are constants? By the way, your result (to me) is understood as `1 \otimes e1 + f1 \otimes 1`, but I would need it as `e1 + f1`.
I've tried modifying your answer but had no luck at all. Your answers so far really point out important differences between Sage and Maxima.
Thanks so much!Mon, 25 May 2015 13:23:02 -0500http://ask.sagemath.org/question/26923/elementary-symmetric-functions/?comment=26933#post-id-26933