# Mixed partial derivatives with respect to n variables

I have the following generic set of variables:

x = {x1, x2, ..., xn}
nu = {0, 1, 2, ..., n - 1}
order(nu) := Total @ nu;


I would like to calculate:

$$\frac{\partial^{\operatorname{order}(v)}}{\partial_1^{\nu_1} \partial_2^{\nu_2} \dots \partial_n^{\nu_n}}$$

With a generic $$x$$. Indeed, I would like a function of this sort:

MyMixedDerivative[f,x_?VectorQ]:= ...


Suggestions?

• You might need Derivative. – Αλέξανδρος Ζεγγ Jul 31 at 7:58
• I tried this: but it does not seam to work out: testx = {x1, x2, x3}; testf[x1_, x2_, x3_] := x1^3 x2^2 x3^2 Derivative[Table[1, {i, 1, 3}]][testf[x1, x2, x3]] – Mirko Aveta Jul 31 at 8:07
• How about Derivative[Sequence @@ Table[1, {i, 1, 3}]][testf][Sequence @@ testx]? – Αλέξανδρος Ζεγγ Jul 31 at 8:12
• It doesn't perform the derivative. I really can't figure out why. – Mirko Aveta Jul 31 at 8:14
• It does. See my new comment. – Αλέξανδρος Ζεγγ Jul 31 at 8:16

OK. If one looks at the documentation of Derivative, it should be found that Derivative accepts two arguments. The first is a Sequence of orders of derivatives to be taken and the second is a Function or a Symbol representing a function, say f. So when the order argument is passed to Derivative, it should be destructured from a List to a Sequence:

testx = {x1, x2, x3}; testf[x1_, x2_, x3_] := x1^3 x2^2 x3^2;
Derivative[Sequence @@ Table[1, {i, 1, 3}]][testf][Sequence @@ testx]


which gives

12 x1^2 x2 x3

Moreover, if one digs deeper in the "Details" part of the documentation, s/he should find out that the above description of requirement is not quite accurate. The true requirement is to achieve a structure consistency between the order argument and the argument of f. So below codes work as well

testf2[{x1_, x2_, x3_}] := x1^3 x2^2 x3^2;
Derivative[Table[1, {i, 1, 3}]][testf2][testx]

testf3[{x1_, x2_}, x3_] := x1^3 x2^2 x3^2;
Derivative[{1, 1}, 1][testf3][{x1, x2}, x3]


and other combinations of Sequence and List as the argument.

• The second part of your comment is inspiring. Thank you a lot. – Mirko Aveta Jul 31 at 8:38
• @MirkoAveta You are welcome. Actually, it is a new point to me, too :) – Αλέξανδρος Ζεγγ Jul 31 at 8:50
• In short, Derivative[] is supposed to inherit the argument structure of the function it is operating on. To give yet another example: Derivative[{1, 0}, {0}, 0][HypergeometricPFQ][{-2, 1/2}, {1}, 1/2] is equivalent to Derivative[1, 0, 0, 0][Hypergeometric2F1][-2, 1/2, 1, 1/2], since HypergeometricPFQ[{a, b}, {c}, x] == Hypergeometric2F1[a, b, c, x]. – J. M. will be back soon Aug 1 at 12:42
• @J.M.isaway Thx for your comments. Yes, "to inherit" is an accurate and concise description. – Αλέξανδρος Ζεγγ Aug 1 at 12:48