Question: Collect by differenatiation order

This question is related to the Question collect and sort

My question is similar to the one referenced, but a bit more complicated.

Considering a PDE of order n, I would like it to be collected by the order of differentiation.

A simple example:

simplify(( (3+4*x)*diff(f(x), `$`(x, 2)))+(5+4*y+z)*(diff(f(x), x))+(1+r+y)*f(x))

where the idea is to return to the form prior to simplification, including the sort by differentiation order.

After it is simplified, I can get the coeff of only the highest order derivative, as

coeff(%, f(x) ) and coeff(%, diff(f(x),x) )

give

Error, unable to compute coeff.

Furthermore, I couldn't find a way to find the highest order derivative in order to make a loop.

It will be best if I can also control the way the coefficients of the derivatives are displayed, e.g. factored or expanded.

Please Wait...