3

pdConv is a very good tool.

How to modify pdConv (or a better way is to add an option?) to make the independent variables of the functions not show?

That is, display u[r,θ,z] as u.

Thank you!

pdConv[f_] := 
 TraditionalForm[
  f /. Derivative[inds__][g_][vars__] :> 
    Apply[Defer[D[g[vars], ##]] &, 
     Transpose[{{vars}, {inds}}] /. {{var_, 0} :> 
        Sequence[], {var_, 1} :> {var}}]]
cvgmt
  • 72,231
  • 4
  • 75
  • 133
xinxin guo
  • 1,323
  • 9
  • 11

1 Answers1

2
Clear@pdConv;
pdConv[f_, pat_List] := pdConv[f, Alternatives @@ pat]

defaultpat = _Subscript | _Symbol?(Context[#] === Context[] &);

pdConv[f_, pat_ : defaultpat] := 
 f /. {Derivative[inds__][g : pat][vars__] :> 
     Apply[Defer@
        D[g, ##] &, {{vars}, {inds}}\[Transpose] /. {{var_, 0} :> 
         Sequence[], {var_, 1} :> {var}}], (g : pat)[__] :> g} // TraditionalForm

Please read the document carefully to understand why the code is modified in this manner.

The function can be used in 2 ways. The one-argument syntax should handle most of the usual cases:

D[Subscript[f, 1][x, y], x, x] + D[g[x, y], y] + 
  Subscript[f, 1][x, y] + g[x, y] == 0 // pdConv

enter image description here

For edge cases, set a second argument to specify functions whose independent variables should be omitted:

pdConv[D[\[FormalA][x, y], x] + D[OverTilde[v][x, y], y] + 
       f[\[FormalA][x, y], OverTilde[v][x, y]] == 0, {\[FormalA], OverTilde[v]}]

enter image description here

xzczd
  • 65,995
  • 9
  • 163
  • 468