ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 06 Jun 2016 12:40:20 -0500Coercion and Laurent polynomialhttps://ask.sagemath.org/question/33650/coercion-and-laurent-polynomial/
Hi! Is there a simple way to make easy coercion from Symbolic Ring to Laurent polynomial ring (or even algebraic extension)? I've only been able to bypass the problem by the following trick (and due the amount of time I've spent on this I'm happy to share it!) :
# Polynomial in the Symbolic Ring
var('t')
P = t^3 + 1/10*t + 3*t^-1
# Laurent polynomial
ringS.<t> = LaurentPolynomialRing(QQ)
#PP = ringS(P) # Not working
PP = ringS(sage_eval(str(P),locals={'t':t}))
print P, P.parent()
print PP, PP.parent()Thu, 02 Jun 2016 13:11:36 -0500https://ask.sagemath.org/question/33650/coercion-and-laurent-polynomial/Answer by FrédéricC for <p>Hi! Is there a simple way to make easy coercion from Symbolic Ring to Laurent polynomial ring (or even algebraic extension)? I've only been able to bypass the problem by the following trick (and due the amount of time I've spent on this I'm happy to share it!) :</p>
<pre><code># Polynomial in the Symbolic Ring
var('t')
P = t^3 + 1/10*t + 3*t^-1
# Laurent polynomial
ringS.<t> = LaurentPolynomialRing(QQ)
#PP = ringS(P) # Not working
PP = ringS(sage_eval(str(P),locals={'t':t}))
print P, P.parent()
print PP, PP.parent()
</code></pre>
https://ask.sagemath.org/question/33650/coercion-and-laurent-polynomial/?answer=33680#post-id-33680Like that
sage: var('t')
sage: P = t^3 + 1/10*t + 3*t^-1; P
t^3 + 1/10*t + 3/t
sage: rng = LaurentPolynomialRing(QQ,'t')
sage: rng(P.numerator())/rng(P.denominator())
3*t^-1 + 1/10*t + t^3
Mon, 06 Jun 2016 12:40:20 -0500https://ask.sagemath.org/question/33650/coercion-and-laurent-polynomial/?answer=33680#post-id-33680