(p1, p2)
Subtract polynomial p2 from p1.

        Examples
        --------
        >>> from sympy.polys.domains import ZZ
        >>> from sympy.polys.rings import ring

        >>> _, x, y = ring('x, y', ZZ)
        >>> p1 = x + y**2
        >>> p2 = x*y + y**2
        >>> p1 - p2
        -x*y + x
Subtract polynomial p2 from p1.
Subtract polynomial p2 from p1 .
def __sub__(p1, p2):
        """Subtract polynomial p2 from p1.

        Examples
        --------
        >>> from sympy.polys.domains import ZZ
        >>> from sympy.polys.rings import ring

        >>> _, x, y = ring('x, y', ZZ)
        >>> p1 = x + y**2
        >>> p2 = x*y + y**2
        >>> p1 - p2
        -x*y + x

        """
        if not p2:
            return p1.copy()
        ring = p1.ring
        if isinstance(p2, ring.dtype):
            p = p1.copy()
            get = p.get
            zero = ring.domain.zero
            for k, v in p2.items():
                v = get(k, zero) - v
                if v:
                    p[k] = v
                else:
                    del p[k]
            return p
        elif isinstance(p2, PolyElement):
            if isinstance(ring.domain, PolynomialRing) and ring.domain.ring == p2.ring:
                pass
            elif isinstance(p2.ring.domain, PolynomialRing) and p2.ring.domain.ring == ring:
                return p2.__rsub__(p1)
            else:
                return NotImplemented

        try:
            p2 = ring.domain_new(p2)
        except CoercionFailed:
            return NotImplemented
        else:
            p = p1.copy()
            zm = ring.zero_monom
            if zm not in p1.keys():
                p[zm] = -p2
            else:
                if p2 == p[zm]:
                    del p[zm]
                else:
                    p[zm] -= p2
            return p
def __sub__ ( p1 , p2 ) : if not p2 : return p1 . copy ( ) ring = p1 . ring if isinstance ( p2 , ring . dtype ) : p = p1 . copy ( ) get = p . get zero = ring . domain . zero for k , v in p2 . items ( ) : v = get ( k , zero ) - v if v : p [ k ] = v else : del p [ k ] return p elif isinstance ( p2 , PolyElement ) : if isinstance ( ring . domain , PolynomialRing ) and ring . domain . ring == p2 . ring : pass elif isinstance ( p2 . ring . domain , PolynomialRing ) and p2 . ring . domain . ring == ring : return p2 . __rsub__ ( p1 ) else : return NotImplemented try : p2 = ring . domain_new ( p2 ) except CoercionFailed : return NotImplemented else : p = p1 . copy ( ) zm = ring . zero_monom if zm not in p1 . keys ( ) : p [ zm ] = - p2 else : if p2 == p [ zm ] : del p [ zm ] else : p [ zm ] -= p2 return p