I need to create a list of expression differentials (1st, 2nd order and so on) and print results to the Grid. I'm trying to use next code (and a lot of other variants, but all were wrong). The problem is only in the line: ToString[D[z[x, y], {x, i - j}, {y, j}]].
MyFunction2[z_] := Block[ {x, y},
arr = {{1, 1}, {1, 2, 1}, {1, 3, 3, 1}, {1, 4, 6, 4, 1}};
result = {};
For[i = 1, i <= 4, i++,
res = "";
For[j = 0, j <= i , j++,
res = StringJoin[
res,
If[res == "", "", " + "],
If[arr[[i]][[j + 1]] > 1,
StringJoin[ToString[arr[[i]][[j + 1]]], "*"], ""],
ToString[D[z[x, y], {x, i - j}, {y, j}]],
If[i - j > 0, "dx", ""],
If[i - j > 1, StringJoin["^", ToString[ i - j]], ""],
If[j > 0, "dy", ""],
If[j > 1, StringJoin["^", ToString[j]], ""]
];
];
AppendTo[result, { StringJoin["d", If[i > 1, StringJoin["^", ToString[i]], ""], "z" ], res }];
];
Grid[result, Frame -> All]
];
MyFunction2[Sin[x*y]]
I am expecting to have something like this as the result: | dz | yCos(xy)dx + xCos(xy)dy |
But result I have is (the first 2 rows of the Grid):
Can you advise me please how can I convert the result of D[z[x, y], {x, i - j}, {y, j}] to the human-readable format? (I tried TraditionalForm[] but it is not what I exactly need)