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$
1

1 Answer 1

5
$\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$
3
  • $\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
    Commented Oct 7, 2016 at 6:00
  • 1
    $\begingroup$ You can do the modification yourself; change f[args] in the replacement rule to just f. $\endgroup$ Commented Oct 7, 2016 at 6:01
  • 2
    $\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
    Commented Oct 7, 2016 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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