gcd sometimes works, sometimes throws an error

asked 2021-12-02 05:03:51 +0100

vnb gravatar image
 sage: a = 1/(x-1/x) 
sage: b = 1/(x-1/x)/x 
sage: a.gcd(b)

Sometimes I can get the result of a.gcd(b)

sage: a.gcd(b)
1/(x - 1/x)

But sometimes I get an error

sage: a.gcd(b)
ValueError                                Traceback (most recent call last)
<ipython-input-19-b4da4d9362f4> in <module>
----> 1 a.gcd(b)

/usr/local/anaconda3/envs/sage/lib/python3.8/site-packages/sage/symbolic/expression.pyx in 
sage.symbolic.expression.Expression.gcd (build/cythonized/sage/symbolic/expression.cpp:42801)()
   7489         """
   7490         cdef Expression r = self.coerce_in(b)
-> 7491         cdef GEx x = g_gcd(self._gobj, r._gobj)
   7492         return new_Expression_from_GEx(self._parent, x)

ValueError: divide: arguments must be polynomials over the rationals
edit retag flag offensive close merge delete