

def dup_rr_prs_gcd(f, g, K):
    '\n    Computes polynomial GCD using subresultants over a ring.\n\n    Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``, ``cff = quo(f, h)``,\n    and ``cfg = quo(g, h)``.\n\n    Examples\n    ========\n\n    >>> from sympy.polys import ring, ZZ\n    >>> R, x = ring("x", ZZ)\n\n    >>> R.dup_rr_prs_gcd(x**2 - 1, x**2 - 3*x + 2)\n    (x - 1, x + 1, x - 2)\n\n    '
    result = _dup_rr_trivial_gcd(f, g, K)
    if (result is not None):
        return result
    (fc, F) = dup_primitive(f, K)
    (gc, G) = dup_primitive(g, K)
    c = K.gcd(fc, gc)
    h = dup_subresultants(F, G, K)[(- 1)]
    (_, h) = dup_primitive(h, K)
    if K.is_negative(dup_LC(h, K)):
        c = (- c)
    h = dup_mul_ground(h, c, K)
    cff = dup_quo(f, h, K)
    cfg = dup_quo(g, h, K)
    return (h, cff, cfg)

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