Symmetric polynomials over a ring of polynomials

42 views
Skip to first unread message

Tom Harris

unread,
May 24, 2014, 10:29:38 AM5/24/14
to sage-s...@googlegroups.com
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?

Oleksandr Kazymyrov

unread,
Aug 11, 2014, 2:54:25 PM8/11/14
to sage-s...@googlegroups.com
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

slelievre

unread,
Aug 19, 2014, 2:34:34 PM8/19/14
to sage-s...@googlegroups.com


Le samedi 24 mai 2014 16:29:38 UTC+2, Tom Harris a écrit :
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?

Maybe the output of your function does not live in C?
Instead of ElemSym(p), you could try:

    ElemSym(C(p))

or

    p = C(p)
    ElemSym(p)

 
Reply all
Reply to author
Forward
0 new messages