(self, c)
return Add(*coeffs)
Return self - c if it's possible to subtract c from self and
        make all matching coefficients move towards zero, else return None.

        Examples
        ========

        >>> from sympy.abc import x, y
        >>> e = 2*x + 3
        >>> e.extract_additively(x + 1)
        x + 2
        >>> e.extract_additively(3*x)
        >>> e.extract_additively(4)
        >>> (y*(x + 1)).extract_additively(x + 1)
        >>> ((x + 1)*(x + 2*y + 1) + 3).extract_additively(x + 1)
        (x + 1)*(x + 2*y) + 3

        Sometimes auto-expansion will return a less simplified result
        than desired; gcd_terms might be used in such cases:

        >>> from sympy import gcd_terms
        >>> (4*x*(y + 1) + y).extract_additively(x)
        4*x*(y + 1) + x*(4*y + 3) - x*(4*y + 4) + y
        >>> gcd_terms(_)
        x*(4*y + 3) + y

        See Also
        ========
        extract_multiplicatively
        coeff
        as_coefficient
Return self - c if it's possible to subtract c from self and
        make all matching coefficients move towards zero, else return None.
Return self - c if it s possible to subtract c from self and make all matching coefficients move towards zero else return None .
def extract_additively(self, c):
        """Return self - c if it's possible to subtract c from self and
        make all matching coefficients move towards zero, else return None.

        Examples
        ========

        >>> from sympy.abc import x, y
        >>> e = 2*x + 3
        >>> e.extract_additively(x + 1)
        x + 2
        >>> e.extract_additively(3*x)
        >>> e.extract_additively(4)
        >>> (y*(x + 1)).extract_additively(x + 1)
        >>> ((x + 1)*(x + 2*y + 1) + 3).extract_additively(x + 1)
        (x + 1)*(x + 2*y) + 3

        Sometimes auto-expansion will return a less simplified result
        than desired; gcd_terms might be used in such cases:

        >>> from sympy import gcd_terms
        >>> (4*x*(y + 1) + y).extract_additively(x)
        4*x*(y + 1) + x*(4*y + 3) - x*(4*y + 4) + y
        >>> gcd_terms(_)
        x*(4*y + 3) + y

        See Also
        ========
        extract_multiplicatively
        coeff
        as_coefficient

        """

        c = sympify(c)
        if c is S.Zero:
            return self
        elif c == self:
            return S.Zero
        elif self is S.Zero:
            return None

        if self.is_Number:
            if not c.is_Number:
                return None
            co = self
            diff = co - c
            # XXX should we match types? i.e should 3 - .1 succeed?
            if (co > 0 and diff > 0 and diff < co or
                    co < 0 and diff < 0 and diff > co):
                return diff
            return None

        if c.is_Number:
            co, t = self.as_coeff_Add()
            xa = co.extract_additively(c)
            if xa is None:
                return None
            return xa + t

        # handle the args[0].is_Number case separately
        # since we will have trouble looking for the coeff of
        # a number.
        if c.is_Add and c.args[0].is_Number:
            # whole term as a term factor
            co = self.coeff(c)
            xa0 = (co.extract_additively(1) or 0)*c
            if xa0:
                diff = self - co*c
                return (xa0 + (diff.extract_additively(c) or diff)) or None
            # term-wise
            h, t = c.as_coeff_Add()
            sh, st = self.as_coeff_Add()
            xa = sh.extract_additively(h)
            if xa is None:
                return None
            xa2 = st.extract_additively(t)
            if xa2 is None:
                return None
            return xa + xa2

        # whole term as a term factor
        co = self.coeff(c)
        xa0 = (co.extract_additively(1) or 0)*c
        if xa0:
            diff = self - co*c
            return (xa0 + (diff.extract_additively(c) or diff)) or None
        # term-wise
        coeffs = []
        for a in Add.make_args(c):
            ac, at = a.as_coeff_Mul()
            co = self.coeff(at)
            if not co:
                return None
            coc, cot = co.as_coeff_Add()
            xa = coc.extract_additively(ac)
            if xa is None:
                return None
            self -= co*at
            coeffs.append((cot + xa)*at)
        coeffs.append(self)
        return Add(*coeffs)
def extract_additively ( self , c ) : c = sympify ( c ) if c is S . Zero : return self elif c == self : return S . Zero elif self is S . Zero : return None if self . is_Number : if not c . is_Number : return None co = self diff = co - c # XXX should we match types? i.e should 3 - .1 succeed? if ( co > 0 and diff > 0 and diff < co or co < 0 and diff < 0 and diff > co ) : return diff return None if c . is_Number : co , t = self . as_coeff_Add ( ) xa = co . extract_additively ( c ) if xa is None : return None return xa + t # handle the args[0].is_Number case separately # since we will have trouble looking for the coeff of # a number. if c . is_Add and c . args [ 0 ] . is_Number : # whole term as a term factor co = self . coeff ( c ) xa0 = ( co . extract_additively ( 1 ) or 0 ) * c if xa0 : diff = self - co * c return ( xa0 + ( diff . extract_additively ( c ) or diff ) ) or None # term-wise h , t = c . as_coeff_Add ( ) sh , st = self . as_coeff_Add ( ) xa = sh . extract_additively ( h ) if xa is None : return None xa2 = st . extract_additively ( t ) if xa2 is None : return None return xa + xa2 # whole term as a term factor co = self . coeff ( c ) xa0 = ( co . extract_additively ( 1 ) or 0 ) * c if xa0 : diff = self - co * c return ( xa0 + ( diff . extract_additively ( c ) or diff ) ) or None # term-wise coeffs = [ ] for a in Add . make_args ( c ) : ac , at = a . as_coeff_Mul ( ) co = self . coeff ( at ) if not co : return None coc , cot = co . as_coeff_Add ( ) xa = coc . extract_additively ( ac ) if xa is None : return None self -= co * at coeffs . append ( ( cot + xa ) * at ) coeffs . append ( self ) return Add ( * coeffs )