On Thursday, August 27, 2015 at 6:47:00 AM UTC-7, fuglede....@gmail.com 
wrote:
>
> I ran into a problem where certain kinds of Laurent polynomials, defined 
> through fractions, would be coercable while some other ones, defined by 
> more or less the same fractions, would not be. It looks like a bug to me, 
> but I figured I would run it by here first. Here's a concrete example of 
> what I mean:
>
>
> sage: R.<x> = LaurentPolynomialRing(ZZ)
>
> sage: p = (1-x^2)/(1-x)
> sage: p
> x + 1
> sage: p.parent()
> Fraction Field of Univariate Polynomial Ring in x over Integer Ring
> sage: R(p)
> 1 + x
> sage: R(p).parent()
> Univariate Laurent Polynomial Ring in x over Integer Ring
>
> sage: q = (1-x^-2)/(1-x^-1)  # I.e., replace x by x^-1
> sage: q
> (x + 1)/x
> sage: q.parent()
> Fraction Field of Univariate Polynomial Ring in x over Integer Ring
> sage: R(q)
> TypeError: denominator must be a unit
>
> This is due to the conversion map, which just calls R._element_constructor 
in this case. The code there doesn't know about fraction fields, so it 
tries something generic: it tries to create an element of the underlying 
polynomial ring and wrap that as a laurent polynomial (which doesn't work, 
of course)
 
Be careful with the // operation, by the way, because it won't necessarily 
give you an error if you divide by a non-unit:

sage: (x+1)^3 //(3*x)
1 + x

(which is of course because "//" is not proper division in ZZ, but 
euclidean division)

-- 
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 sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to