I have a Laurent polynomial ring in two variables: R = Z[u,u^-1,v,v^-1].

I want to implement the ring automorphism of R which sends u to u^-1 and v 
to v^-1.

If p(u,v) is in R then p.subsitutue(u,u^-1,v=v^-1) should work but sadly 
not:

sage: p=2*u**-1*v**-1+u*v
sage: p.substitute(u=u^-1,v=v^-1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-39-eb90c4c3368e> in <module>()
----> 1 p.substitute(u=u**-Integer(1),v=v**-Integer(1))

/usr/local/src/sage/sage-5.11/local/lib/python2.7/site-packages/sage/structure/element.so
 
in sage.structure.element.Element.substitute 
(sage/structure/element.c:6349)()

/usr/local/src/sage/sage-5.11/local/lib/python2.7/site-packages/sage/rings/polynomial/laurent_polynomial.so
 
in sage.rings.polynomial.laurent_polynomial.LaurentPolynomial_mpair.subs 
(sage/rings/polynomial/laurent_polynomial.c:10753)()

/usr/local/src/sage/sage-5.11/local/lib/python2.7/site-packages/sage/structure/element.so
 
in sage.structure.element.RingElement.__imul__ 
(sage/structure/element.c:14780)()

/usr/local/src/sage/sage-5.11/local/lib/python2.7/site-packages/sage/structure/coerce.so
 
in sage.structure.coerce.CoercionModel_cache_maps.bin_op 
(sage/structure/coerce.c:8169)()

TypeError: unsupported operand parent(s) for '*': 'Multivariate Laurent 
Polynomial Ring in u, v over Rational Field' and 'Multivariate Laurent 
Polynomial Ring in u, v over Integer Ring'

I played with this for a little while and finally worked out where the 
prblem is. Consider:

sage: [ [c,u**-exp[0],v**-exp[1]] for (exp,c) in p.dict().iteritems()]
[[2, u, v], [1, u^-1, v^-1]]
sage: [ [c,u**-exp[0]*v**-exp[1]] for (exp,c) in p.dict().iteritems()]
[[2, u*v], [1, u^-1*v^-1]]
sage: [ [c*u**-exp[0]*v**-exp[1]] for (exp,c) in p.dict().iteritems()]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-36-e01dd53c18a2> in <module>()
----> 1 [ [c*u**-exp[Integer(0)]*v**-exp[Integer(1)]] for (exp,c) in 
p.dict().iteritems()]

/usr/local/src/sage/sage-5.11/local/lib/python2.7/site-packages/sage/structure/element.so
 
in sage.structure.element.RingElement.__mul__ 
(sage/structure/element.c:14531)()

/usr/local/src/sage/sage-5.11/local/lib/python2.7/site-packages/sage/structure/coerce.so
 
in sage.structure.coerce.CoercionModel_cache_maps.bin_op 
(sage/structure/coerce.c:8169)()

TypeError: unsupported operand parent(s) for '*': 'Multivariate Laurent 
Polynomial Ring in u, v over Rational Field' and 'Multivariate Laurent 
Polynomial Ring in u, v over Integer Ring'

So it seems that sage is happy to prduce the monomials but that when it 
comes to multiplying by the integer coefficeints it coerces itself into the 
field of fractions and blows up. On the plus side, at least I have a 
solution:

sage: sum( R(c)*u**-exp[0]*v**-exp[1] for (exp,c) in p.dict().iteritems() )
2*u*v + u^-1*v^-1

Am I missing something or is this the easiest hack to get this to work?

Andrew

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to