diff --git a/sympy/polys/euclidtools.py b/sympy/polys/euclidtools.py index 31d95e8c30c5..768a44a94930 100644 --- a/sympy/polys/euclidtools.py +++ b/sympy/polys/euclidtools.py @@ -1880,35 +1880,18 @@ def dmp_cancel(f, g, u, K, include=True): cq, f = dmp_clear_denoms(f, u, K0, K, convert=True) cp, g = dmp_clear_denoms(g, u, K0, K, convert=True) - else: cp, cq = K.one, K.one _, p, q = dmp_inner_gcd(f, g, u, K) - domul = True if K0 is not None: - _, _cp, _cq = K.cofactors(cp, cq) + _, cp, cq = K.cofactors(cp, cq) p = dmp_convert(p, u, K, K0) q = dmp_convert(q, u, K, K0) - if (_cp, _cq) != (1,1) and 1 in (_cp, _cq) and 'QQ' in str(K0) and str(K) == 'ZZ': # XXX what's the better way to test for this situation? - domul=False - def zz(l, c): - from mpmath.libmp import MPZ - rv = [] - for i in l: - if type(i) is list: - rv.append(zz(i)) - else: - rv.append(MPZ(i*c)) - return rv - p = zz(p, _cp) - q = zz(q, _cq) - cp = cq = 1 - else: - cp, cq = _cp, _cq - K = K0 + + K = K0 p_neg = K.is_negative(dmp_ground_LC(p, u, K)) q_neg = K.is_negative(dmp_ground_LC(q, u, K)) @@ -1923,7 +1906,7 @@ def zz(l, c): if not include: return cp, cq, p, q - if domul: - p = dmp_mul_ground(p, cp, u, K) - q = dmp_mul_ground(q, cq, u, K) + p = dmp_mul_ground(p, cp, u, K) + q = dmp_mul_ground(q, cq, u, K) + return p, q