Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
up vote 8 down vote accepted

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.

share|improve this answer
Terrific thank you so much! – Name Feb 3 '13 at 20:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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