(self, other)
return Factors(self_factors), Factors(other_factors)
Return ``self`` and ``other`` with ``gcd`` removed from each.
        The only differences between this and method ``div`` is that this
        is 1) optimized for the case when there are few factors in common and
        2) this does not raise an error if ``other`` is zero.

        See Also
        ========
        div
Return ``self`` and ``other`` with ``gcd`` removed from each.
        The only differences between this and method ``div`` is that this
        is 1) optimized for the case when there are few factors in common and
        2) this does not raise an error if ``other`` is zero.
Return self and other with gcd removed from each . The only differences between this and method div is that this is 1 ) optimized for the case when there are few factors in common and 2 ) this does not raise an error if other is zero .
def normal(self, other):
        """Return ``self`` and ``other`` with ``gcd`` removed from each.
        The only differences between this and method ``div`` is that this
        is 1) optimized for the case when there are few factors in common and
        2) this does not raise an error if ``other`` is zero.

        See Also
        ========
        div

        """
        if not isinstance(other, Factors):
            other = Factors(other)
            if other.is_zero:
                return (Factors(), Factors(S.Zero))
            if self.is_zero:
                return (Factors(S.Zero), Factors())

        self_factors = dict(self.factors)
        other_factors = dict(other.factors)

        for factor, self_exp in self.factors.items():
            try:
                other_exp = other.factors[factor]
            except KeyError:
                continue

            exp = self_exp - other_exp

            if not exp:
                del self_factors[factor]
                del other_factors[factor]
            elif _isnumber(exp):
                if exp > 0:
                    self_factors[factor] = exp
                    del other_factors[factor]
                else:
                    del self_factors[factor]
                    other_factors[factor] = -exp
            else:
                r = self_exp.extract_additively(other_exp)
                if r is not None:
                    if r:
                        self_factors[factor] = r
                        del other_factors[factor]
                    else:  # should be handled already
                        del self_factors[factor]
                        del other_factors[factor]
                else:
                    sc, sa = self_exp.as_coeff_Add()
                    if sc:
                        oc, oa = other_exp.as_coeff_Add()
                        diff = sc - oc
                        if diff > 0:
                            self_factors[factor] -= oc
                            other_exp = oa
                        elif diff < 0:
                            self_factors[factor] -= sc
                            other_factors[factor] -= sc
                            other_exp = oa - diff
                        else:
                            self_factors[factor] = sa
                            other_exp = oa
                    if other_exp:
                        other_factors[factor] = other_exp
                    else:
                        del other_factors[factor]

        return Factors(self_factors), Factors(other_factors)
def normal ( self , other ) : if not isinstance ( other , Factors ) : other = Factors ( other ) if other . is_zero : return ( Factors ( ) , Factors ( S . Zero ) ) if self . is_zero : return ( Factors ( S . Zero ) , Factors ( ) ) self_factors = dict ( self . factors ) other_factors = dict ( other . factors ) for factor , self_exp in self . factors . items ( ) : try : other_exp = other . factors [ factor ] except KeyError : continue exp = self_exp - other_exp if not exp : del self_factors [ factor ] del other_factors [ factor ] elif _isnumber ( exp ) : if exp > 0 : self_factors [ factor ] = exp del other_factors [ factor ] else : del self_factors [ factor ] other_factors [ factor ] = - exp else : r = self_exp . extract_additively ( other_exp ) if r is not None : if r : self_factors [ factor ] = r del other_factors [ factor ] else : # should be handled already del self_factors [ factor ] del other_factors [ factor ] else : sc , sa = self_exp . as_coeff_Add ( ) if sc : oc , oa = other_exp . as_coeff_Add ( ) diff = sc - oc if diff > 0 : self_factors [ factor ] -= oc other_exp = oa elif diff < 0 : self_factors [ factor ] -= sc other_factors [ factor ] -= sc other_exp = oa - diff else : self_factors [ factor ] = sa other_exp = oa if other_exp : other_factors [ factor ] = other_exp else : del other_factors [ factor ] return Factors ( self_factors ) , Factors ( other_factors )