1

How to convert the expression Derivative[1, 0][f][r, z] into the following in Mathematica automatically D[f[r, z], {r, 1}, {z, 0}] (or to traditional form of D[f[r, z], {r, 1}, {z, 0}])

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
SPJ
  • 117
  • 5

1 Answers1

5

Not too hard:

Derivative[2, 0, 1][h][p, q, r] /. Derivative[id__][f_][args__] :> 
TraditionalForm[Inactive[D][f[args], Sequence @@ Transpose[{{args}, {id}}]]]

a derivative in TraditionalForm

Slightly more elaborate:

Derivative[2, 0, 1][h][p, q, r] /. Derivative[id__][f_][args__] :> 
TraditionalForm[Inactive[D][f[args],
                Sequence @@ DeleteCases[Transpose[{{args}, {id}}], {_, 0}]]]

a derivative in TraditionalForm, with some variables removed

Even more elaborate:

Derivative[2, 0, 1][h][p, q, r] /. Derivative[id__][f_][args__] :> 
TraditionalForm[Inactive[D][f[args], 
                Sequence @@ (DeleteCases[Transpose[{{args}, {id}}], {_, 0}] /.
                             {x_, 1} :> x)]]

still another derivative in TraditionalForm, with some variables removed

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
  • It will be nice if we can format the output with function name h only, that is without the varaibles p,q,r – SPJ Oct 07 '16 at 06:00
  • 1
    You can do the modification yourself; change f[args] in the replacement rule to just f. – J. M.'s missing motivation Oct 07 '16 at 06:01
  • 2
    @Subin This is not what the quesiton is about. If you just want to make custom formatting then say so, and probably the asnwer I've linked is a duplicate. Otherwise you should accept everything which leads to D[f[r, z], {r, 1}, {z, 0}] // Hold // TraditionalForm. – Kuba Oct 07 '16 at 07:08