Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

Consider

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.