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.

I can extract the parameters of a single variable derivative with the rule

D[f[x], x] /. Derivative[order_][fcn_][variable_] ->
  {order, fcn, variable}

produces

{1, f, x}

How do I generalize this to the multivariate case? For example,

D[f[x, y], x, y] /. Derivative[order_][fcn_][variable_] ->
  {order, fcn, variable}

produces

Mathematica graphics

The match didn't work -- but I can't seem to reproduce the actual Mathematica display.

I'm sure there's some magic syntax that will accomplish the match. I tried a few variations to no avail. Can anyone help?

Thanks much.

share|improve this question
add comment

1 Answer

You have to look at the FullForm or InputForm to see, how you can match your expression.

InputForm[D[f[x, y], x, y]]

(*
  Derivative[1, 1][f][x, y]
*)

The order in your second example is a sequence of numbers. The same is true for the variables you try to match. Therefore you have to use BlankSequence in your pattern

D[f[x, y], x, y] /. 
 Derivative[order__][fcn_][variable__] -> {{order}, fcn, {variable}}

(*
  {{1, 1}, f, {x, y}}
*)
share|improve this answer
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.