I have very large expression and I want to extract and sum up all the numerical coefficients which multiply the summands.
For example,
expr = x + 2*y + 3*z*w
What I need is for Mathematica to do is to extract the numerical coefficients {1, 2, 3}
and sum them up, 1+2+3=6
.
I cannot use Coefficient
function, because the expressions (represented by x
, y
, z
and w
in the above example) are very complicated, and the summation is huge.
Does anyone have any suggestions how to solve this? Thank you.