OK, I think now I am down to what's quite clearly a bug: sage: P.<x,y> = PolynomialRing(SR) sage: R.<z> = PolynomialRing(P, sparse=False); R Univariate Polynomial Ring in z over Multivariate Polynomial Ring in x, y over Symbolic Ring sage: A = -x*z^2 + x*z sage: B = -x sage: A // B z^2 - z sage: P.<x,y> = PolynomialRing(SR) sage: R.<z> = PolynomialRing(P, sparse=True); R Sparse Univariate Polynomial Ring in z over Multivariate Polynomial Ring in x, y over Symbolic Ring sage: A = -x*z^2 + x*z sage: B = -x sage: A // B --------------------------------------------------------------------------- TypeError Traceback (most recent call last) File ~/sage-develop/src/sage/rings/polynomial/polynomial_element_generic.py:852, in Polynomial_generic_sparse.quo_rem(self, other) 851 try: --> 852 c = R(rem.leading_coefficient() * ~other.leading_coefficient()) 853 except TypeError:
File ~/sage-develop/src/sage/structure/parent.pyx:897, in sage.structure.parent.Parent.__call__() 896 if no_extra_args: --> 897 return mor._call_(x) 898 else: File ~/sage-develop/src/sage/structure/coerce_maps.pyx:161, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_() 160 print(type(C._element_constructor), C._element_constructor) --> 161 raise 162 File ~/sage-develop/src/sage/structure/coerce_maps.pyx:156, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_() 155 try: --> 156 return C._element_constructor(x) 157 except Exception: File ~/sage-develop/src/sage/rings/polynomial/polynomial_ring.py:456, in PolynomialRing_general._element_constructor_(self, x, check, is_gen, construct, **kwds) 455 else: --> 456 raise TypeError("denominator must be a unit") 457 elif isinstance(x, pari_gen): TypeError: denominator must be a unit During handling of the above exception, another exception occurred: ArithmeticError Traceback (most recent call last) Input In [39], in <cell line: 1>() ----> 1 A // B File ~/sage-develop/src/sage/structure/element.pyx:1840, in sage.structure.element.Element.__floordiv__() 1838 return (<Element>left)._floordiv_(right) 1839 if BOTH_ARE_ELEMENT(cl): -> 1840 return coercion_model.bin_op(left, right, floordiv) 1841 1842 try: File ~/sage-develop/src/sage/structure/coerce.pyx:1204, in sage.structure.coerce.CoercionModel.bin_op() 1202 self._record_exception() 1203 else: -> 1204 return PyObject_CallObject(op, xy) 1205 1206 if op is mul: File ~/sage-develop/src/sage/structure/element.pyx:1838, in sage.structure.element.Element.__floordiv__() 1836 cdef int cl = classify_elements(left, right) 1837 if HAVE_SAME_PARENT(cl): -> 1838 return (<Element>left)._floordiv_(right) 1839 if BOTH_ARE_ELEMENT(cl): 1840 return coercion_model.bin_op(left, right, floordiv) File ~/sage-develop/src/sage/rings/polynomial/polynomial_element.pyx:2872, in sage.rings.polynomial.polynomial_element.Polynomial._floordiv_() 2870 # quite typical when removing gcds... 2871 return self -> 2872 Q, _ = self.quo_rem(right) 2873 return Q 2874 File ~/sage-develop/src/sage/structure/element.pyx:4498, in sage.structure.element.coerce_binop.new_method() 4496 def new_method(self, other, *args, **kwargs): 4497 if have_same_parent(self, other): -> 4498 return method(self, other, *args, **kwargs) 4499 else: 4500 a, b = coercion_model.canonical_coercion(self, other) File ~/sage-develop/src/sage/rings/polynomial/polynomial_element_generic.py:854, in Polynomial_generic_sparse.quo_rem(self, other) 852 c = R(rem.leading_coefficient() * ~other.leading_coefficient()) 853 except TypeError: --> 854 raise ArithmeticError("Division non exact (consider coercing to polynomials over the fraction field)") 855 e = rem.degree() - d 856 quo += c*R.one().shift(e) ArithmeticError: Division non exact (consider coercing to polynomials over the fraction field) sage: On Wednesday, 12 October 2022 at 23:50:04 UTC+2 Martin R wrote: > Possibly related: > > sage: P.<x,y> = PolynomialRing(SR) > sage: R.<z> = PolynomialRing(P); R > Univariate Polynomial Ring in z over Multivariate Polynomial Ring in x, y > over Symbolic Ring > sage: num = -x*z^2 + x*z > sage: den = x*z^2 + (-x-1)*z + 1 > sage: num.gcd(den) > z - 1 > sage: P.<x,y> = PolynomialRing(SR) > sage: R.<z> = PolynomialRing(P, sparse=True); R > Sparse Univariate Polynomial Ring in z over Multivariate Polynomial Ring > in x, y over Symbolic Ring > sage: num = -x*z^2 + x*z > sage: den = x*z^2 + (-x-1)*z + 1 > sage: num.gcd(den) > > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > File > ~/sage-develop/src/sage/rings/polynomial/polynomial_element_generic.py:852, > in Polynomial_generic_sparse.quo_rem(self, other) > 851 try: > --> 852 c = R(rem.leading_coefficient() * ~other.leading_coefficient()) > 853 except TypeError: > > > File ~/sage-develop/src/sage/structure/parent.pyx:897, in > sage.structure.parent.Parent.__call__() > 896 if no_extra_args: > --> 897 return mor._call_(x) > 898 else: > > File ~/sage-develop/src/sage/structure/coerce_maps.pyx:161, in > sage.structure.coerce_maps.DefaultConvertMap_unique._call_() > 160 print(type(C._element_constructor), C._element_constructor) > --> 161 raise > 162 > > File ~/sage-develop/src/sage/structure/coerce_maps.pyx:156, in > sage.structure.coerce_maps.DefaultConvertMap_unique._call_() > 155 try: > --> 156 return C._element_constructor(x) > 157 except Exception: > > File ~/sage-develop/src/sage/rings/polynomial/polynomial_ring.py:456, in > PolynomialRing_general._element_constructor_(self, x, check, is_gen, > construct, **kwds) > 455 else: > --> 456 raise TypeError("denominator must be a unit") > 457 elif isinstance(x, pari_gen): > > TypeError: denominator must be a unit > > > During handling of the above exception, another exception occurred: > > ArithmeticError Traceback (most recent call last) > Input In [82], in <cell line: 1>() > ----> 1 num.gcd(den) > > > File ~/sage-develop/src/sage/structure/element.pyx:4498, in > sage.structure.element.coerce_binop.new_method() > 4496 def new_method(self, other, *args, **kwargs): > 4497 if have_same_parent(self, other): > -> 4498 return method(self, other, *args, **kwargs) > 4499 else: > 4500 a, b = coercion_model.canonical_coercion(self, other) > > File > ~/sage-develop/src/sage/rings/polynomial/polynomial_element_generic.py:935, > in Polynomial_generic_sparse.gcd(self, other, algorithm) > 933 return S(g) > 934 elif algorithm=="generic": > --> 935 return Polynomial.gcd(self,other) > 936 else: > 937 raise ValueError("Unknown algorithm '%s'" % algorithm) > > > File ~/sage-develop/src/sage/structure/element.pyx:4498, in > sage.structure.element.coerce_binop.new_method() > 4496 def new_method(self, other, *args, **kwargs): > 4497 if have_same_parent(self, other): > -> 4498 return method(self, other, *args, **kwargs) > 4499 else: > 4500 a, b = coercion_model.canonical_coercion(self, other) > > File ~/sage-develop/src/sage/rings/polynomial/polynomial_element.pyx:4918, > in sage.rings.polynomial.polynomial_element.Polynomial.gcd() > 4916 raise NotImplementedError("%s does not provide a gcd > implementation for univariate polynomials"%self._parent._base) > 4917 else: > -> 4918 return doit(self, other) > 4919 > 4920 @coerce_binop > > File > ~/sage-develop/src/sage/categories/unique_factorization_domains.py:185, in > UniqueFactorizationDomains.ParentMethods._gcd_univariate_polynomial(self, > f, g) > 182 break > 184 d = a.gcd(b) > --> 185 A = A // a > 186 B = B // b > 187 g = h = 1 > > File ~/sage-develop/src/sage/structure/element.pyx:1840, in > sage.structure.element.Element.__floordiv__() > 1838 return (<Element>left)._floordiv_(right) > 1839 if BOTH_ARE_ELEMENT(cl): > -> 1840 return coercion_model.bin_op(left, right, floordiv) > 1841 > 1842 try: > > File ~/sage-develop/src/sage/structure/coerce.pyx:1204, in > sage.structure.coerce.CoercionModel.bin_op() > 1202 self._record_exception() > 1203 else: > -> 1204 return PyObject_CallObject(op, xy) > 1205 > 1206 if op is mul: > > File ~/sage-develop/src/sage/structure/element.pyx:1838, in > sage.structure.element.Element.__floordiv__() > 1836 cdef int cl = classify_elements(left, right) > 1837 if HAVE_SAME_PARENT(cl): > -> 1838 return (<Element>left)._floordiv_(right) > 1839 if BOTH_ARE_ELEMENT(cl): > 1840 return coercion_model.bin_op(left, right, floordiv) > > File ~/sage-develop/src/sage/rings/polynomial/polynomial_element.pyx:2872, > in sage.rings.polynomial.polynomial_element.Polynomial._floordiv_() > 2870 # quite typical when removing gcds... > 2871 return self > -> 2872 Q, _ = self.quo_rem(right) > 2873 return Q > 2874 > > File ~/sage-develop/src/sage/structure/element.pyx:4498, in > sage.structure.element.coerce_binop.new_method() > 4496 def new_method(self, other, *args, **kwargs): > 4497 if have_same_parent(self, other): > -> 4498 return method(self, other, *args, **kwargs) > 4499 else: > 4500 a, b = coercion_model.canonical_coercion(self, other) > > File > ~/sage-develop/src/sage/rings/polynomial/polynomial_element_generic.py:854, > in Polynomial_generic_sparse.quo_rem(self, other) > 852 c = R(rem.leading_coefficient() * ~other.leading_coefficient()) > 853 except TypeError: > --> 854 raise ArithmeticError("Division non exact (consider coercing > to polynomials over the fraction field)") > 855 e = rem.degree() - d > 856 quo += c*R.one().shift(e) > > ArithmeticError: Division non exact (consider coercing to polynomials over > the fraction field) > > On Wednesday, 12 October 2022 at 22:39:46 UTC+2 Martin R wrote: > >> I am not sure whether the following is to be expected. >> >> Martin >> >> sage: R.<x> = SR[] >> sage: S.<z> = R[] >> sage: (x*z).quo_rem(S(x)) >> >> --------------------------------------------------------------------------- >> TypeError Traceback (most recent call >> last) >> File >> ~/sage-develop/src/sage/rings/polynomial/polynomial_element.pyx:11713, in >> sage.rings.polynomial.polynomial_element.Polynomial_generic_dense.quo_rem() >> 11712 try: >> > 11713 q = R(q) >> 11714 except TypeError: >> >> File ~/sage-develop/src/sage/structure/parent.pyx:897, in >> sage.structure.parent.Parent.__call__() >> 896 if no_extra_args: >> --> 897 return mor._call_(x) >> 898 else: >> >> File ~/sage-develop/src/sage/categories/map.pyx:788, in >> sage.categories.map.Map._call_() >> 787 >> --> 788 cpdef Element _call_(self, x): >> 789 """ >> >> File ~/sage-develop/src/sage/rings/fraction_field.py:1254, in >> FractionFieldEmbeddingSection._call_(self, x, check) >> 1250 if check and not den.is_unit(): >> 1251 # This should probably be a ValueError. >> 1252 # However, too much existing code is expecting this to throw a >> 1253 # TypeError, so we decided to keep it for the time being. >> -> 1254 raise TypeError("fraction must have unit denominator") >> 1255 return num * den.inverse_of_unit() >> >> TypeError: fraction must have unit denominator >> >> During handling of the above exception, another exception occurred: >> >> ArithmeticError Traceback (most recent call >> last) >> Input In [41], in <cell line: 1>() >> ----> 1 (x*z).quo_rem(S(x)) >> >> File ~/sage-develop/src/sage/structure/element.pyx:4498, in >> sage.structure.element.coerce_binop.new_method() >> 4496 def new_method(self, other, *args, **kwargs): >> 4497 if have_same_parent(self, other): >> -> 4498 return method(self, other, *args, **kwargs) >> 4499 else: >> 4500 a, b = coercion_model.canonical_coercion(self, other) >> >> File >> ~/sage-develop/src/sage/rings/polynomial/polynomial_element.pyx:11715, in >> sage.rings.polynomial.polynomial_element.Polynomial_generic_dense.quo_rem() >> 11713 q = R(q) >> 11714 except TypeError: >> > 11715 raise ArithmeticError("division non exact (consider coercing >> to polynomials over the fraction field)") >> 11716 for j from n+k-2 >= j >= k: >> 11717 x[j] -= q * y[j-k] >> >> ArithmeticError: division non exact (consider coercing to polynomials >> over the fraction field) >> sage: > > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/b07395c7-efbe-462a-8dbc-3ccff8fe6e16n%40googlegroups.com.