Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

By dividing two polynomials, you ask quite explicitly for an element of the fraction field of the polynomials' parent :

sage: R1.<t>=ZZ[]
sage: foo=(t-1)*(t-2)*(t-3) ; foo
t^3 - 6*t^2 + 11*t - 6
sage: foo.parent()
Univariate Polynomial Ring in t over Integer Ring
sage: foo/(t-2)
t^2 - 4*t + 3
sage: (foo/(t-2)).parent()
Fraction Field of Univariate Polynomial Ring in t over Integer Ring

If you need a polynomial, you can try the explicit conversion :

sage: R1(foo/(t-2)).parent()
Univariate Polynomial Ring in t over Integer Ring

... except that it will fail if the conversion is impossible (i. e. your divisor is not a (product of) $t-u$ monomial(s) where (all the) $u$(s) is (are) root(s) of the polynomial :

sage: foo/(t-4)
(t^3 - 6*t^2 + 11*t - 6)/(t - 4)

Note that the result is not simplified (it cannot be...).

sage: (foo/(t-4)).parent()
Fraction Field of Univariate Polynomial Ring in t over Integer Ring

as expected. Therefore :

sage: R1(foo/(t-24))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-38-eda6314d7474> in <module>
----> 1 R1(foo/(t-Integer(24)))

/usr/local/sage-9/local/lib/python3.9/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9351)()
    896         if mor is not None:
    897             if no_extra_args:
--> 898                 return mor._call_(x)
    899             else:
    900                 return mor._call_with_args(x, args, kwds)

/usr/local/sage-9/local/lib/python3.9/site-packages/sage/categories/map.pyx in sage.categories.map.Map._call_ (build/cythonized/sage/categories/map.c:7089)()
    788         return self._call_with_args(x, args, kwds)
    789 
--> 790     cpdef Element _call_(self, x):
    791         """
    792         Call method with a single argument, not implemented in the base class.

/usr/local/sage-9/local/lib/python3.9/site-packages/sage/rings/fraction_field.py in _call_(self, x, check)
   1240             # However, too much existing code is expecting this to throw a
   1241             # TypeError, so we decided to keep it for the time being.
-> 1242             raise TypeError("fraction must have unit denominator")
   1243         return num * den.inverse_of_unit()
   1244 

TypeError: fraction must have unit denominator

You can also try the euclidean division :

sage: q, r = foo.quo_rem(t-4) ; (q, r)
(t^2 - 2*t + 3, 6)
sage: q.parent()
Univariate Polynomial Ring in t over Integer Ring

but be damn sure to check that r is zero !

HTH,