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}])
Asked
Active
Viewed 679 times
1
-
If it is only about formatting it nicely then: How to make traditional output for derivatives – Kuba Oct 07 '16 at 05:41
1 Answers
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}}]]]

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

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

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
-
1You can do the modification yourself; change
f[args]in the replacement rule to justf. – 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