Skip to main content
2 of 2
added 10 characters in body

Finding the maximum order derivative of an expression

I have an expression that is the the sum and product of undefined derivatives and their derivatives.

e.g. f g+ Dt[f, t] g +Dt[g, {t, 2}] f

What I would like to find is the maximum order of the derivatives, and so 2 would be returned for the above example.

My first attempts use Cases to make lists of the order of derivatives. This would send Dt[x_, t] -> 1 and Dt[x_, {t, n_}] -> n. However for some reason Dt[f, t] and Dt[f, {t, 2}] fail to match with their respective patterns and don't trigger the rule. If, in the rules, the x_ is replaced with f the rules will trigger but only for f and no other function. Is there a way to do this search without a strict list of the available functions?