(f, g, u, K)
return res, R
Resultant algorithm in `K[X]` using subresultant PRS.

    Examples
    ========

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

    >>> f = 3*x**2*y - y**3 - 4
    >>> g = x**2 + x*y**3 - 9

    >>> a = 3*x*y**4 + y**3 - 27*y + 4
    >>> b = -3*y**10 - 12*y**7 + y**6 - 54*y**4 + 8*y**3 + 729*y**2 - 216*y + 16

    >>> res, prs = R.dmp_prs_resultant(f, g)

    >>> res == b             # resultant has n-1 variables
    False
    >>> res == b.drop(x)
    True
    >>> prs == [f, g, a, b]
    True
Resultant algorithm in `K[X]` using subresultant PRS.
Resultant algorithm in K [ X ] using subresultant PRS .
def dmp_prs_resultant(f, g, u, K):
    """
    Resultant algorithm in `K[X]` using subresultant PRS.

    Examples
    ========

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

    >>> f = 3*x**2*y - y**3 - 4
    >>> g = x**2 + x*y**3 - 9

    >>> a = 3*x*y**4 + y**3 - 27*y + 4
    >>> b = -3*y**10 - 12*y**7 + y**6 - 54*y**4 + 8*y**3 + 729*y**2 - 216*y + 16

    >>> res, prs = R.dmp_prs_resultant(f, g)

    >>> res == b             # resultant has n-1 variables
    False
    >>> res == b.drop(x)
    True
    >>> prs == [f, g, a, b]
    True

    """
    if not u:
        return dup_prs_resultant(f, g, K)

    if dmp_zero_p(f, u) or dmp_zero_p(g, u):
        return (dmp_zero(u - 1), [])

    R, B, D = dmp_inner_subresultants(f, g, u, K)

    if dmp_degree(R[-1], u) > 0:
        return (dmp_zero(u - 1), R)
    if dmp_one_p(R[-2], u, K):
        return (dmp_LC(R[-1], K), R)

    s, i, v = 1, 1, u - 1

    p = dmp_one(v, K)
    q = dmp_one(v, K)

    for b, d in list(zip(B, D))[:-1]:
        du = dmp_degree(R[i - 1], u)
        dv = dmp_degree(R[i  ], u)
        dw = dmp_degree(R[i + 1], u)

        if du % 2 and dv % 2:
            s = -s

        lc, i = dmp_LC(R[i], K), i + 1

        p = dmp_mul(dmp_mul(p, dmp_pow(b, dv, v, K), v, K),
                    dmp_pow(lc, du - dw, v, K), v, K)
        q = dmp_mul(q, dmp_pow(lc, dv*(1 + d), v, K), v, K)

        _, p, q = dmp_inner_gcd(p, q, v, K)

    if s < 0:
        p = dmp_neg(p, v, K)

    i = dmp_degree(R[-2], u)

    res = dmp_pow(dmp_LC(R[-1], K), i, v, K)
    res = dmp_quo(dmp_mul(res, p, v, K), q, v, K)

    return res, R
def dmp_prs_resultant ( f , g , u , K ) : if not u : return dup_prs_resultant ( f , g , K ) if dmp_zero_p ( f , u ) or dmp_zero_p ( g , u ) : return ( dmp_zero ( u - 1 ) , [ ] ) R , B , D = dmp_inner_subresultants ( f , g , u , K ) if dmp_degree ( R [ - 1 ] , u ) > 0 : return ( dmp_zero ( u - 1 ) , R ) if dmp_one_p ( R [ - 2 ] , u , K ) : return ( dmp_LC ( R [ - 1 ] , K ) , R ) s , i , v = 1 , 1 , u - 1 p = dmp_one ( v , K ) q = dmp_one ( v , K ) for b , d in list ( zip ( B , D ) ) [ : - 1 ] : du = dmp_degree ( R [ i - 1 ] , u ) dv = dmp_degree ( R [ i ] , u ) dw = dmp_degree ( R [ i + 1 ] , u ) if du % 2 and dv % 2 : s = - s lc , i = dmp_LC ( R [ i ] , K ) , i + 1 p = dmp_mul ( dmp_mul ( p , dmp_pow ( b , dv , v , K ) , v , K ) , dmp_pow ( lc , du - dw , v , K ) , v , K ) q = dmp_mul ( q , dmp_pow ( lc , dv * ( 1 + d ) , v , K ) , v , K ) _ , p , q = dmp_inner_gcd ( p , q , v , K ) if s < 0 : p = dmp_neg ( p , v , K ) i = dmp_degree ( R [ - 2 ] , u ) res = dmp_pow ( dmp_LC ( R [ - 1 ] , K ) , i , v , K ) res = dmp_quo ( dmp_mul ( res , p , v , K ) , q , v , K ) return res , R