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.Fri, 22 May 2015 14:08:24 -0500S.from_polynomial(f) -- convert a polynomial to symmetric functions BUT with a parameterhttp://ask.sagemath.org/question/26913/sfrom_polynomialf-convert-a-polynomial-to-symmetric-functions-but-with-a-parameter/I thought I'd ask a variation of an earlier question that was unanswered.
I use:
P.<x,y>=PolynomialRing(QQ)
S=SymmetricFunctions(QQ)
S.inject_shorthands()
f=x+y
e(S.from_polynomial(f))
resulting in `e[1]` (or x+y)
So that works, but when I try to do that for a polynomial with **parameters**, say
f=x+y+a+b
it complains that `a` and `b` are not defined. If I add them to the ring I get `e[1]`, but I suspect this is equivalent now to `x+y+a+b` (I didn't check because it should be `e[1]+a+b`).
Do I need to keep the ring defined the same but define maybe S as;
`S = SymmetricFunctions(QQ[x,y])` ?
This causes the error claiming that the function is not a symmetric polynomial.
By the way, I know I could use something like,
a=maxima.eval('elem([2,e1,e2],(x+y+a+b)/2,[x,y])')
to get `e1/2 + (a+b)/2`, but I then can't use `eval` or `sage_eval` on the result because there are parsing errors for larger equations, e.g. python complains about the use of '^' instead of '**' for exponentiation, etc. My other posted question, http://ask.sagemath.org/question/26728/successive-calls-to-maxima/, is in direct relation to this phenomena.Thu, 21 May 2015 19:38:23 -0500http://ask.sagemath.org/question/26913/sfrom_polynomialf-convert-a-polynomial-to-symmetric-functions-but-with-a-parameter/Answer by FrédéricC for <p>I thought I'd ask a variation of an earlier question that was unanswered. </p>
<p>I use:</p>
<pre><code>P.<x,y>=PolynomialRing(QQ)
S=SymmetricFunctions(QQ)
S.inject_shorthands()
f=x+y
e(S.from_polynomial(f))
</code></pre>
<p>resulting in <code>e[1]</code> (or x+y)</p>
<p>So that works, but when I try to do that for a polynomial with <strong>parameters</strong>, say </p>
<pre><code>f=x+y+a+b
</code></pre>
<p>it complains that <code>a</code> and <code>b</code> are not defined. If I add them to the ring I get <code>e[1]</code>, but I suspect this is equivalent now to <code>x+y+a+b</code> (I didn't check because it should be <code>e[1]+a+b</code>).</p>
<p>Do I need to keep the ring defined the same but define maybe S as;</p>
<p><code>S = SymmetricFunctions(QQ[x,y])</code> ? </p>
<p>This causes the error claiming that the function is not a symmetric polynomial.</p>
<p>By the way, I know I could use something like,</p>
<pre><code>a=maxima.eval('elem([2,e1,e2],(x+y+a+b)/2,[x,y])')
</code></pre>
<p>to get <code>e1/2 + (a+b)/2</code>, but I then can't use <code>eval</code> or <code>sage_eval</code>on the result because there are parsing errors for larger equations, e.g. python complains about the use of '^' instead of '**' for exponentiation, etc. My other posted question, <a href="http://ask.sagemath.org/question/26728/successive-calls-to-maxima/">http://ask.sagemath.org/question/2672...</a>, is in direct relation to this phenomena.</p>
http://ask.sagemath.org/question/26913/sfrom_polynomialf-convert-a-polynomial-to-symmetric-functions-but-with-a-parameter/?answer=26919#post-id-26919you just have to work over a base ring which is not QQ
sage: P.<x,y>=PolynomialRing(QQ['a'])
sage: a = P.base_ring().gen()
sage: f = x + y + a
sage: S=SymmetricFunctions(P.base_ring())
sage: S.from_polynomial(f)
a*m[] + m[1]Fri, 22 May 2015 13:42:31 -0500http://ask.sagemath.org/question/26913/sfrom_polynomialf-convert-a-polynomial-to-symmetric-functions-but-with-a-parameter/?answer=26919#post-id-26919Comment by natepower for <p>you just have to work over a base ring which is not QQ</p>
<pre><code>sage: P.<x,y>=PolynomialRing(QQ['a'])
sage: a = P.base_ring().gen()
sage: f = x + y + a
sage: S=SymmetricFunctions(P.base_ring())
sage: S.from_polynomial(f)
a*m[] + m[1]
</code></pre>
http://ask.sagemath.org/question/26913/sfrom_polynomialf-convert-a-polynomial-to-symmetric-functions-but-with-a-parameter/?comment=26920#post-id-26920Thanks! I've got what you've done, including other bases. This is exactly what I asked for!
Now I will try to get it to work for two pairs of symmetric variables, e.g., x&y AND a&b. I'll try defining another base ring, though I feel I'll need to also redefine the returned 'functions', e.g. m[] or m[1] with another letter.... like n[] and n[1]... I think `exy=S.elementary(); exy._prefix='exy'` etc. I'll try this today, and hopefully I won't have to ask again - unless it is on the tip of your tongue already ;)Fri, 22 May 2015 14:08:24 -0500http://ask.sagemath.org/question/26913/sfrom_polynomialf-convert-a-polynomial-to-symmetric-functions-but-with-a-parameter/?comment=26920#post-id-26920