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)
7493
ValueError: divide: arguments must be polynomials over the rationals