Working in a stack of multivariate polynomial rings, how can I compute the quotient of two polynomials in those cases where I know the remainder to be zero?
Reading the docs I found two likely approaches, but neither seems to work as I'd have hoped. See below for error messages.
Example:
sage: PR1.<a,b>=QQ[]
sage: PR2.<x,y>=PR1[]
sage: n=(x-y)*(x+3*y)
sage: d=(x-y)
sage: n/d
(x^2 + 2*x*y + (-3)*y^2)/(x - y)
sage: PR2(n/d)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-cc8d100cc210> in <module>()
----> 1 PR2(n/d)
…/sage/rings/polynomial/multi_polynomial_ring.pyc in __call__(self, x, check)
449 return x.numerator()
450 else:
--> 451 raise TypeError, "unable to coerce since the denominator is not 1"
452
453 elif is_SingularElement(x) and self._has_singular:
TypeError: unable to coerce since the denominator is not 1
sage: n.quo_rem(d)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-d17781c77d90> in <module>()
----> 1 n.quo_rem(d)
…/sage/structure/element.so in sage.structure.element.NamedBinopMethod.__call__ (sage/structure/element.c:24924)()
…/sage/rings/polynomial/multi_polynomial_element.pyc in quo_rem(self, right)
1730 return self.quo_rem(right) # this looks like recursion, but, in fact, it may be that self, right are a totally new composite type
1731 R = self.parent()
-> 1732 R._singular_().set_ring()
1733 X = self._singular_().division(right._singular_())
1734 return R(X[1][1,1]), R(X[2][1])
…/sage/rings/polynomial/polynomial_singular_interface.pyc in _singular_(self, singular)
213 return R
214 except (AttributeError, ValueError):
--> 215 return self._singular_init_(singular)
216
217 def _singular_init_(self, singular=singular_default):
…/sage/rings/polynomial/polynomial_singular_interface.pyc in _singular_init_(self, singular)
229 """
230 if not can_convert_to_singular(self):
--> 231 raise TypeError, "no conversion of this ring to a Singular ring defined"
232
233 if self.ngens()==1:
TypeError: no conversion of this ring to a Singular ring defined