(self, c)
Return None if it's not possible to make self in the form
           c * something in a nice way, i.e. preserving the properties
           of arguments of self.

           >>> from sympy import symbols, Rational

           >>> x, y = symbols('x,y', real=True)

           >>> ((x*y)**3).extract_multiplicatively(x**2 * y)
           x*y**2

           >>> ((x*y)**3).extract_multiplicatively(x**4 * y)

           >>> (2*x).extract_multiplicatively(2)
           x

           >>> (2*x).extract_multiplicatively(3)

           >>> (Rational(1,2)*x).extract_multiplicatively(3)
           x/6
Return None if it's not possible to make self in the form
           c * something in a nice way, i.e. preserving the properties
           of arguments of self.
Return None if it s not possible to make self in the form c * something in a nice way i . e . preserving the properties of arguments of self .
def extract_multiplicatively(self, c):
        """Return None if it's not possible to make self in the form
           c * something in a nice way, i.e. preserving the properties
           of arguments of self.

           >>> from sympy import symbols, Rational

           >>> x, y = symbols('x,y', real=True)

           >>> ((x*y)**3).extract_multiplicatively(x**2 * y)
           x*y**2

           >>> ((x*y)**3).extract_multiplicatively(x**4 * y)

           >>> (2*x).extract_multiplicatively(2)
           x

           >>> (2*x).extract_multiplicatively(3)

           >>> (Rational(1,2)*x).extract_multiplicatively(3)
           x/6

        """
        c = sympify(c)
        if c is S.One:
            return self
        elif c == self:
            return S.One
        if c.is_Add:
            cc, pc = c.primitive()
            if cc is not S.One:
                c = Mul(cc, pc, evaluate=False)
        if c.is_Mul:
            a, b = c.as_two_terms()
            x = self.extract_multiplicatively(a)
            if x is not None:
                return x.extract_multiplicatively(b)
        quotient = self / c
        if self.is_Number:
            if self is S.Infinity:
                if c.is_positive:
                    return S.Infinity
            elif self is S.NegativeInfinity:
                if c.is_negative:
                    return S.Infinity
                elif c.is_positive:
                    return S.NegativeInfinity
            elif self is S.ComplexInfinity:
                if not c.is_zero:
                    return S.ComplexInfinity
            elif self is S.NaN:
                return S.NaN
            elif self.is_Integer:
                if not quotient.is_Integer:
                    return None
                elif self.is_positive and quotient.is_negative:
                    return None
                else:
                    return quotient
            elif self.is_Rational:
                if not quotient.is_Rational:
                    return None
                elif self.is_positive and quotient.is_negative:
                    return None
                else:
                    return quotient
            elif self.is_Float:
                if not quotient.is_Float:
                    return None
                elif self.is_positive and quotient.is_negative:
                    return None
                else:
                    return quotient
        elif self.is_NumberSymbol or self.is_Symbol or self is S.ImaginaryUnit:
            if quotient.is_Mul and len(quotient.args) == 2:
                if quotient.args[0].is_Integer and quotient.args[0].is_positive and quotient.args[1] == self:
                    return quotient
            elif quotient.is_Integer and c.is_Number:
                return quotient
        elif self.is_Add:
            cs, ps = self.primitive()
            if cs is not S.One:
                return Mul(cs, ps, evaluate=False).extract_multiplicatively(c)
            newargs = []
            for arg in self.args:
                newarg = arg.extract_multiplicatively(c)
                if newarg is not None:
                    newargs.append(newarg)
                else:
                    return None
            return Add(*newargs)
        elif self.is_Mul:
            args = list(self.args)
            for i, arg in enumerate(args):
                newarg = arg.extract_multiplicatively(c)
                if newarg is not None:
                    args[i] = newarg
                    return Mul(*args)
        elif self.is_Pow:
            if c.is_Pow and c.base == self.base:
                new_exp = self.exp.extract_additively(c.exp)
                if new_exp is not None:
                    return self.base ** (new_exp)
            elif c == self.base:
                new_exp = self.exp.extract_additively(1)
                if new_exp is not None:
                    return self.base ** (new_exp)
def extract_multiplicatively ( self , c ) : c = sympify ( c ) if c is S . One : return self elif c == self : return S . One if c . is_Add : cc , pc = c . primitive ( ) if cc is not S . One : c = Mul ( cc , pc , evaluate = False ) if c . is_Mul : a , b = c . as_two_terms ( ) x = self . extract_multiplicatively ( a ) if x is not None : return x . extract_multiplicatively ( b ) quotient = self / c if self . is_Number : if self is S . Infinity : if c . is_positive : return S . Infinity elif self is S . NegativeInfinity : if c . is_negative : return S . Infinity elif c . is_positive : return S . NegativeInfinity elif self is S . ComplexInfinity : if not c . is_zero : return S . ComplexInfinity elif self is S . NaN : return S . NaN elif self . is_Integer : if not quotient . is_Integer : return None elif self . is_positive and quotient . is_negative : return None else : return quotient elif self . is_Rational : if not quotient . is_Rational : return None elif self . is_positive and quotient . is_negative : return None else : return quotient elif self . is_Float : if not quotient . is_Float : return None elif self . is_positive and quotient . is_negative : return None else : return quotient elif self . is_NumberSymbol or self . is_Symbol or self is S . ImaginaryUnit : if quotient . is_Mul and len ( quotient . args ) == 2 : if quotient . args [ 0 ] . is_Integer and quotient . args [ 0 ] . is_positive and quotient . args [ 1 ] == self : return quotient elif quotient . is_Integer and c . is_Number : return quotient elif self . is_Add : cs , ps = self . primitive ( ) if cs is not S . One : return Mul ( cs , ps , evaluate = False ) . extract_multiplicatively ( c ) newargs = [ ] for arg in self . args : newarg = arg . extract_multiplicatively ( c ) if newarg is not None : newargs . append ( newarg ) else : return None return Add ( * newargs ) elif self . is_Mul : args = list ( self . args ) for i , arg in enumerate ( args ) : newarg = arg . extract_multiplicatively ( c ) if newarg is not None : args [ i ] = newarg return Mul ( * args ) elif self . is_Pow : if c . is_Pow and c . base == self . base : new_exp = self . exp . extract_additively ( c . exp ) if new_exp is not None : return self . base ** ( new_exp ) elif c == self . base : new_exp = self . exp . extract_additively ( 1 ) if new_exp is not None : return self . base ** ( new_exp )