Collecting coefficients of derivatives
I have a complicated expression involving derivatives of a function, and I'd like to collect all of the first, second, third, etc. derivatives. For example, my expression starts:
a1*a2*a3*x*f(x) + a1*a2*x^2*diff(f(x), x) + a1*a3*x^2*diff(f(x), x) + a2*a3*x^2*diff(f(x), x)
and I would like to rewrite that part as
a1*a2*a3*x*f(x) + (a1*a2*x^2*+ a1*a3*x^2+ a2*a3*x^2)*diff(f(x), x)
How do I tell Sage to do this?