Is it possible to detect the highest order (or generally all orders) of derivatives in an expression?


eqn = D[a[x,t],t] == D[a[x,t],x,x]

How would I go about detecting that the highest order of the partial derivative in x is 2 in eqn?

I was thinking of using MatchQ, however this

MatchQ[Derivative[2, 0][a][x, t], eqn]

just returns False.

Thank you!


1 Answer 1


How about this:

Cases[eqn, Derivative[orders__] -> {orders}, Infinity, Heads -> True]

(* Out: {{0, 1}, {2, 0}} *)

Now, you've got the orders of each derivative returned in a list that you can manipulate as you please.

  • $\begingroup$ Terrific thank you so much! $\endgroup$
    – Name
    Feb 3, 2013 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.