Replace derivatives using vector notation

I seek to replace derivatives like D[u[x, y], x, x] which are evaluated as $u^{(2,0)}[x,y]$ by variables with names like uxx. Derivatives that I work with are denoted by their "order-vector", for example {2,0} is the vector for this particular derivative and {1,1} is for uxy. I have a list of different derivative vectors and I want to create rule for replacement which is comprised of elements like $u^{(2,0)}[x,y]\rightarrow uxx$. But for that, I need to transform {2,0} into (2,0) which mathematica doesn't want to do:

dsT={1,0,0,0};
ToExpression[StringReplace[ToString[dsT], {"}" -> ")", "{" -> "("}]]


This returns an error though without "ToExpression" the output is exaxtly what I need "(1, 0, 0, 0)". How can I do this conversion for any length of derivative vector?

• Your ToExpression approach won't work because (1, 0, 0, 0) is not a valid Mathematica expression (try entering it directly and see). Instead, note that $u^{(2,0)}[x,y]$ is actually represented internally as Derivative[2, 0][u][x, y], as you can find out by evaluating FullForm on such an expression. So you should be replacing expressions involving Derivative[2, 0], not involving (2, 0). – Rahul Mar 14 '18 at 15:38
• @Rahul but neither 2,0 is a valid mathematica expression. How can I put it into Derivative[]? – Vsevolod A. Mar 14 '18 at 15:44

Here is one method:

derivativeToSymbol[expr_] /; Nest[Head, expr, 3] === Derivative := Block[{args, tmp},
args = List @@ expr; tmp = Head[expr];
Symbol[(ToString @@ tmp) <>


Examples:

derivativeToSymbol[D[u[x, y], x, x]]
uxx

derivativeToSymbol[D[u[x, y, z], {x, 3}, z]]
uxxxz

• Can I adopt that to unknown number of variables? Like if I know their number beforehand how to write function u as u[t1,t2,t3...tn] automatically with just the number n? – Vsevolod A. Mar 14 '18 at 15:42
• Nope. But you should have included that requirement in your question if you really need it. – J. M. is away Mar 14 '18 at 15:47
• There is really no way to declare list of arguments for a function? I can generate this "code" by very simple string manipulatios. – Vsevolod A. Mar 14 '18 at 15:52

Turned out to be:

dsT = {1, 0, 0, 1, 0};
vars = Table[ToExpression["x" <> ToString[i]], {i, 1, Length[dsT]}];

\!$$\*SuperscriptBox[\(u$$,
TagBox[
RowBox[{"(",
RowBox[{"Sequence", "@@", "dsT"}], ")"}],
Derivative],
MultilineFunction->None]\)[Sequence @@ vars]