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

    Examples
    ========

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

    >>> R.dup_prs_resultant(x**2 + 1, x**2 - 1)
    (4, [x**2 + 1, x**2 - 1, -2])
Resultant algorithm in `K[x]` using subresultant PRS.
Resultant algorithm in K [ x ] using subresultant PRS .
def dup_prs_resultant(f, g, K):
    """
    Resultant algorithm in `K[x]` using subresultant PRS.

    Examples
    ========

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

    >>> R.dup_prs_resultant(x**2 + 1, x**2 - 1)
    (4, [x**2 + 1, x**2 - 1, -2])

    """
    if not f or not g:
        return (K.zero, [])

    R, B, D = dup_inner_subresultants(f, g, K)

    if dup_degree(R[-1]) > 0:
        return (K.zero, R)
    if R[-2] == [K.one]:
        return (dup_LC(R[-1], K), R)

    s, i = 1, 1
    p, q = K.one, K.one

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

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

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

        p *= b**dv * lc**(du - dw)
        q *= lc**(dv*(1 + d))

    if s < 0:
        p = -p

    i = dup_degree(R[-2])

    res = dup_LC(R[-1], K)**i
    res = K.quo(res*p, q)

    return res, R
def dup_prs_resultant ( f , g , K ) : if not f or not g : return ( K . zero , [ ] ) R , B , D = dup_inner_subresultants ( f , g , K ) if dup_degree ( R [ - 1 ] ) > 0 : return ( K . zero , R ) if R [ - 2 ] == [ K . one ] : return ( dup_LC ( R [ - 1 ] , K ) , R ) s , i = 1 , 1 p , q = K . one , K . one for b , d in list ( zip ( B , D ) ) [ : - 1 ] : du = dup_degree ( R [ i - 1 ] ) dv = dup_degree ( R [ i ] ) dw = dup_degree ( R [ i + 1 ] ) if du % 2 and dv % 2 : s = - s lc , i = dup_LC ( R [ i ] , K ) , i + 1 p *= b ** dv * lc ** ( du - dw ) q *= lc ** ( dv * ( 1 + d ) ) if s < 0 : p = - p i = dup_degree ( R [ - 2 ] ) res = dup_LC ( R [ - 1 ] , K ) ** i res = K . quo ( res * p , q ) return res , R