'Return a dictionary mapping terms to their Rational coefficient.
Since the dictionary is a defaultdict, inquiries about terms which
were not present will return a coefficient of 0. If an expression is
not an Add it is considered to have a single term.
Examples
>>> from sympy.abc import a, x
>>> (3*x + a*x + 4).as_coefficients_dict()
{1: 4, x: 3, a*x: 1}
>>> _[a]
0
>>> (3*a*x).as_coefficients_dict()
{a*x: 3}'

def as_coefficients_dict(self):

    (c, m) = self.as_coeff_Mul()
    if (not c.is_Rational):
        c = S.One
        m = self
    d = defaultdict(int)
    d.update({m: c})
    return d
