(f, g, K)
Subtract dense polynomials in ``K[x]``.

    Examples
    ========

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

    >>> R.dup_sub(x**2 - 1, x - 2)
    x**2 - x + 1
Subtract dense polynomials in ``K[x]``.
Subtract dense polynomials in K [ x ] .
def dup_sub(f, g, K):
    """
    Subtract dense polynomials in ``K[x]``.

    Examples
    ========

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

    >>> R.dup_sub(x**2 - 1, x - 2)
    x**2 - x + 1

    """
    if not f:
        return dup_neg(g, K)
    if not g:
        return f

    df = dup_degree(f)
    dg = dup_degree(g)

    if df == dg:
        return dup_strip([ a - b for a, b in zip(f, g) ])
    else:
        k = abs(df - dg)

        if df > dg:
            h, f = f[:k], f[k:]
        else:
            h, g = dup_neg(g[:k], K), g[k:]

        return h + [ a - b for a, b in zip(f, g) ]
def dup_sub ( f , g , K ) : if not f : return dup_neg ( g , K ) if not g : return f df = dup_degree ( f ) dg = dup_degree ( g ) if df == dg : return dup_strip ( [ a - b for a , b in zip ( f , g ) ] ) else : k = abs ( df - dg ) if df > dg : h , f = f [ : k ] , f [ k : ] else : h , g = dup_neg ( g [ : k ] , K ) , g [ k : ] return h + [ a - b for a , b in zip ( f , g ) ]