

def dmp_qq_heu_gcd(f, g, u, K0):
    '\n    Heuristic polynomial GCD in `Q[X]`.\n\n    Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``,\n    ``cff = quo(f, h)``, and ``cfg = quo(g, h)``.\n\n    Examples\n    ========\n\n    >>> from sympy.polys import ring, QQ\n    >>> R, x,y, = ring("x,y", QQ)\n\n    >>> f = QQ(1,4)*x**2 + x*y + y**2\n    >>> g = QQ(1,2)*x**2 + x*y\n\n    >>> R.dmp_qq_heu_gcd(f, g)\n    (x + 2*y, 1/4*x + 1/2*y, 1/2*x)\n\n    '
    result = _dmp_ff_trivial_gcd(f, g, u, K0)
    if (result is not None):
        return result
    K1 = K0.get_ring()
    (cf, f) = dmp_clear_denoms(f, u, K0, K1)
    (cg, g) = dmp_clear_denoms(g, u, K0, K1)
    f = dmp_convert(f, u, K0, K1)
    g = dmp_convert(g, u, K0, K1)
    (h, cff, cfg) = dmp_zz_heu_gcd(f, g, u, K1)
    h = dmp_convert(h, u, K1, K0)
    c = dmp_ground_LC(h, u, K0)
    h = dmp_ground_monic(h, u, K0)
    cff = dmp_convert(cff, u, K1, K0)
    cfg = dmp_convert(cfg, u, K1, K0)
    cff = dmp_mul_ground(cff, K0.quo(c, cf), u, K0)
    cfg = dmp_mul_ground(cfg, K0.quo(c, cg), u, K0)
    return (h, cff, cfg)

dataset/ETHPy150Open sympy/sympy/sympy/polys/euclidtools.py dmp_qq_heu_gcd/original