(p1, p2)
Multiply two polynomials.

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

        >>> _, x, y = ring('x, y', QQ)
        >>> p1 = x + y
        >>> p2 = x - y
        >>> p1*p2
        x**2 - y**2
Multiply two polynomials.
Multiply two polynomials .
def __mul__(p1, p2):
        """Multiply two polynomials.

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

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

        """
        ring = p1.ring
        p = ring.zero
        if not p1 or not p2:
            return p
        elif isinstance(p2, ring.dtype):
            get = p.get
            zero = ring.domain.zero
            monomial_mul = ring.monomial_mul
            p2it = list(p2.items())
            for exp1, v1 in p1.items():
                for exp2, v2 in p2it:
                    exp = monomial_mul(exp1, exp2)
                    p[exp] = get(exp, zero) + v1*v2
            p.strip_zero()
            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.__rmul__(p1)
            else:
                return NotImplemented

        try:
            p2 = ring.domain_new(p2)
        except CoercionFailed:
            return NotImplemented
        else:
            for exp1, v1 in p1.items():
                v = v1*p2
                if v:
                    p[exp1] = v
            return p
def __mul__ ( p1 , p2 ) : ring = p1 . ring p = ring . zero if not p1 or not p2 : return p elif isinstance ( p2 , ring . dtype ) : get = p . get zero = ring . domain . zero monomial_mul = ring . monomial_mul p2it = list ( p2 . items ( ) ) for exp1 , v1 in p1 . items ( ) : for exp2 , v2 in p2it : exp = monomial_mul ( exp1 , exp2 ) p [ exp ] = get ( exp , zero ) + v1 * v2 p . strip_zero ( ) 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 . __rmul__ ( p1 ) else : return NotImplemented try : p2 = ring . domain_new ( p2 ) except CoercionFailed : return NotImplemented else : for exp1 , v1 in p1 . items ( ) : v = v1 * p2 if v : p [ exp1 ] = v return p