3
$\begingroup$

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!

$\endgroup$
10
$\begingroup$

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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