The model() function in https://github.com/sympy/sympy/pull/598 will
do this for you. You have to say what you consider to be a variable,
however, so it won't lump 'b' and 'c' together unless you tell it that
'x' is the variable. But if you just give it an arbitrary Dummy() for
x, it will lump everything else together. We aren't sure what to call
this function. Could it be lump()?

As it works now, however, it will absorb numbers that are only
multiplying constants -- it absorbs all constants into a lumped
constant, so your equation would become:

    >>> model(2*b*c, x)
    C0
    >>> model(2*b*c, b)
    C0*b

What you have to think about is what multiplied things you *don't*
want to absorb. Otherwise, what you could do something like:

    >>> eq=2*b*c
    >>> eq.subs([(m.as_coeff_Mul()[1], Dummy('C'+str(i))) for i, m in
enumerate(eq.atoms(Mul))])
    2*_C0
    >>> eq=2*b*c+cos(a)*b
    >>> eq.subs([(m.as_coeff_Mul()[1], Dummy('C'+str(i))) for i, m in
enumerate(eq.atoms(Mul))])
    _C0 + 2*_C1

/c

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to