1
$\begingroup$

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}])

$\endgroup$
3
$\begingroup$

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

$\endgroup$
  • $\begingroup$ It will be nice if we can format the output with function name h only, that is without the varaibles p,q,r $\endgroup$ – SPJ Oct 7 '16 at 6:00
  • 1
    $\begingroup$ You can do the modification yourself; change f[args] in the replacement rule to just f. $\endgroup$ – J. M. will be back soon Oct 7 '16 at 6:01
  • 1
    $\begingroup$ @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. $\endgroup$ – Kuba Oct 7 '16 at 7:08

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.