Hi Tom,

Your code works perfectly in Sage 6.2 on Mac

R.<x1,x2,x3> = PolynomialRing(ZZ,3)
C.<c1,c2> = PolynomialRing(R,2)

Sym = SymmetricFunctions(R)
e = Sym.elementary()

def ElemSym(p):
# checks whether a polynomial is symmetric (coefficients in ZZ[l1,l2,l3])
    f = Sym.from_polynomial(p)
    return e(f)

p = ((x1^3 - 2*x1*x2 + x3)*c1^2 - (x1*x2 - x3)*c1 + x3)*c2^2 + x1^3 + 
c1^2*x3 - (x1*x2 - x3)*c1 - ((x1*x2 - x3)*c1^2 - (x1^3 - x1*x2 + x3)*c1 + 
x1*x2 - x3)*c2 - 2*x1*x2 + x3
ElemSym(p) == ElemSym(((x1^3 - 2*x1*x2 + x3)*c1^2 - (x1*x2 - x3)*c1 + 
x3)*c2^2 + x1^3 + c1^2*x3 - (x1*x2 - x3)*c1 - ((x1*x2 - x3)*c1^2 - (x1^3 - 
x1*x2 + x3)*c1 + x1*x2 - x3)*c2 - 2*x1*x2 + x3)
True

Best regards,
Oleksandr

On Saturday, May 24, 2014 4:29:38 PM UTC+2, Tom Harris wrote:
>
> Hi all,
>
> I am new to sage, so please forgive me if this is a trivial question.
>
> I am trying to express certain polynomials, which are symmetric in a 
> subset of the variables, in terms of elementary symmetric polynomials on 
> the symmetric subset (with coefficients that are polynomials in the other 
> variables.
>
> Here is my setup:
> _____________________________________________________________________
>
> R.<x1,x2,x3> = PolynomialRing(ZZ,3)
> C.<c1,c2> = PolynomialRing(R,2)
>
> Sym = SymmetricFunctions(R)
> e = Sym.elementary()
>
> def ElemSym(p):
> # checks whether a polynomial is symmetric (coefficients in ZZ[l1,l2,l3])
>     f = Sym.from_polynomial(p)
>     return e(f)
> _____________________________________________________________________
>
> If one enters some polynomials of the desired form by hand, e.g., 
>
> g = (x1^2 - 2*x2^2)*c1 +c1*c2 + (x1^2 -2*x2^2)*c2
>
> and calls ElemSym(g)
>
> then sage returns
>
> (x1^2-2*x2^2)*e[1] + e[2]
>
> as expected.
>
> Now I have some code to generate the polynomial which I am interested in, 
> I store it as p:
>
> p = (output of some functions)
>
> ( p is ((x1^3 - 2*x1*x2 + x3)*c1^2 - (x1*x2 - x3)*c1 + x3)*c2^2 + x1^3 + 
> c1^2*x3 - (x1*x2 - x3)*c1 - ((x1*x2 - x3)*c1^2 - (x1^3 - x1*x2 + x3)*c1 + 
> x1*x2 - x3)*c2 - 2*x1*x2 + x3) 
>
> Now the curious thing: p is (naively at least) symmetric in c1 and c2, but 
> calling ElemSym(p) returns an error:
>
> ValueError: x0 + 2*x1 + x2 is not a symmetric polynomial
>
> but if I copy the polynomial itself and call
>
> ElemSym(((x1^3 - 2*x1*x2 + x3)*c1^2 - (x1*x2 - x3)*c1 + x3)*c2^2 + x1^3 + 
> c1^2*x3 - (x1*x2 - x3)*c1 - ((x1*x2 - x3)*c1^2 - (x1^3 - x1*x2 + x3)*c1 + 
> x1*x2 - x3)*c2 - 2*x1*x2 + x3)),
>
> then it works and I get
>
> (x1^3-2*x1*x2+x3)*e[] + (-x1*x2+x3)*e[1] + x3*e[1, 1] + 
> (x1^3-x1*x2-x3)*e[2] + (-x1*x2+x3)*e[2, 1] + (x1^3-2*x1*x2+x3)*e[2, 2] + 
> (3*x1*x2-3*x3)*e[3] + (-2*x1^3+4*x1*x2-2*x3)*e[3, 1] + 
> (2*x1^3-4*x1*x2+2*x3)*e[4]
>
> as expected.
>
> Can somebody help me understand what is going on here?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to