(f, g, K0)
return h, cff, cfg
Heuristic polynomial GCD in `Q[x]`.

    Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``,
    ``cff = quo(f, h)``, and ``cfg = quo(g, h)``.

    Examples
    ========

    >>> from sympy.polys import ring, QQ
    >>> R, x = ring("x", QQ)

    >>> f = QQ(1,2)*x**2 + QQ(7,4)*x + QQ(3,2)
    >>> g = QQ(1,2)*x**2 + x

    >>> R.dup_qq_heu_gcd(f, g)
    (x + 2, 1/2*x + 3/4, 1/2*x)
Heuristic polynomial GCD in `Q[x]`.
Heuristic polynomial GCD in Q [ x ] .
def dup_qq_heu_gcd(f, g, K0):
    """
    Heuristic polynomial GCD in `Q[x]`.

    Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``,
    ``cff = quo(f, h)``, and ``cfg = quo(g, h)``.

    Examples
    ========

    >>> from sympy.polys import ring, QQ
    >>> R, x = ring("x", QQ)

    >>> f = QQ(1,2)*x**2 + QQ(7,4)*x + QQ(3,2)
    >>> g = QQ(1,2)*x**2 + x

    >>> R.dup_qq_heu_gcd(f, g)
    (x + 2, 1/2*x + 3/4, 1/2*x)

    """
    result = _dup_ff_trivial_gcd(f, g, K0)

    if result is not None:
        return result

    K1 = K0.get_ring()

    cf, f = dup_clear_denoms(f, K0, K1)
    cg, g = dup_clear_denoms(g, K0, K1)

    f = dup_convert(f, K0, K1)
    g = dup_convert(g, K0, K1)

    h, cff, cfg = dup_zz_heu_gcd(f, g, K1)

    h = dup_convert(h, K1, K0)

    c = dup_LC(h, K0)
    h = dup_monic(h, K0)

    cff = dup_convert(cff, K1, K0)
    cfg = dup_convert(cfg, K1, K0)

    cff = dup_mul_ground(cff, K0.quo(c, cf), K0)
    cfg = dup_mul_ground(cfg, K0.quo(c, cg), K0)

    return h, cff, cfg
def dup_qq_heu_gcd ( f , g , K0 ) : result = _dup_ff_trivial_gcd ( f , g , K0 ) if result is not None : return result K1 = K0 . get_ring ( ) cf , f = dup_clear_denoms ( f , K0 , K1 ) cg , g = dup_clear_denoms ( g , K0 , K1 ) f = dup_convert ( f , K0 , K1 ) g = dup_convert ( g , K0 , K1 ) h , cff , cfg = dup_zz_heu_gcd ( f , g , K1 ) h = dup_convert ( h , K1 , K0 ) c = dup_LC ( h , K0 ) h = dup_monic ( h , K0 ) cff = dup_convert ( cff , K1 , K0 ) cfg = dup_convert ( cfg , K1 , K0 ) cff = dup_mul_ground ( cff , K0 . quo ( c , cf ) , K0 ) cfg = dup_mul_ground ( cfg , K0 . quo ( c , cg ) , K0 ) return h , cff , cfg