Dear All, here is a brief status update on this issue. TL;DR: Laurent Polynomial Ring does not provide a gcd implementation.
Recall that we are in this situation: sage: L = LaurentPolynomialRing(LaurentPolynomialRing(ZZ,'t'),'x') sage: R = L.fraction_field() sage: R.inject_variables() Defining x sage: x.gcd(x) 1 This is the implementation of gcd called by x.gcd(x) @coerce_binop def gcd(self, other): P = self.parent() try: selfN = self.numerator() selfD = self.denominator() selfGCD = selfN.gcd(selfD) otherN = other.numerator() otherD = other.denominator() otherGCD = otherN.gcd(otherD) selfN = selfN // selfGCD selfD = selfD // selfGCD otherN = otherN // otherGCD otherD = otherD // otherGCD tmp = P(selfN.gcd(otherN))/P(selfD.lcm(otherD)) return tmp except (AttributeError, NotImplementedError, TypeError, ValueError): zero = P.zero() if self == zero and other == zero: return zero return P.one() clearly selfN is x and selfD is 1 as elements of L but sage: selfN.gcd(selfD) ... NotImplementedError: Univariate Laurent Polynomial Ring in t over Integer Ring does not provide a gcd implementation for univariate polynomials S. PS: of course this is not just a problem with units: sage: (x+1).gcd(x+1) 1 sage: (x+1).numerator().gcd(1) NotImplementedError: Univariate Laurent Polynomial Ring in t over Integer Ring does not provide a gcd implementation for univariate polynomials * Travis Scrimshaw <tsc...@ucdavis.edu> [2015-10-10 05:57:20]: > I think I slightly misspoke about the gcd. See the details on > [1]http://trac.sagemath.org/ticket/16993. > Best, > Travis > On Friday, October 9, 2015 at 4:12:12 PM UTC-5, Travis Scrimshaw wrote: > > Hey Salvatore, > Â Â I would say this is the same problem as simplifying scalars of > fraction fields of polynomials over QQ, that gcd(x, x) = 1 rather than > x because x is a unit. I don't think we have a way around this > currently other than doing some kind of explicit coercion. > Best, > Travis > On Friday, October 9, 2015 at 1:40:22 PM UTC-5, Salvatore Stella wrote: > > Dear all, > I just noted the following odd behaviour: > sage: L = LaurentPolynomialRing(ZZ, 'x').fraction_field() > sage: L.inject_variables() > Defining x > sage: x/x > 1 > As one should expect but if we change the base ring then things get > messy: > sage: L = LaurentPolynomialRing(LaurentPolynomialRing(ZZ,'t'), > 'x').fraction_field() > sage: L.inject_variables() > Defining x > sage: x/x > x/x > sage: _.denominator() > x > The fact that x/x is printed out as x/x is still ok if somewhat > annoying. But > the return value of denominator() is definitely not what I would > expect. > Is this intentional? > Thanks > Salvatore > > References > > 1. http://trac.sagemath.org/ticket/16993 -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-combinat-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-combinat-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-combinat-devel. For more options, visit https://groups.google.com/d/optout.