# Meaning of D[f[x,y],x,y]

In calculus, we show our students:

$$\frac{\partial^2 f}{\partial x\partial y} =\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial y}\right)$$

Now, in Mathematica, which of the following matches this second partial derivative: D[f[x,y],x,y] or D[f[x,y],y,x]?

I am aware of Clairaut's rule and this probably won't be an issue (as counterexamples usually involve limit use), but like double integrals, I find the ordering sometimes confusing.

• As noted in the docs, it will succesively differentiate in the order of the variables given to it. Commented Jul 11, 2015 at 19:55
• @Guesswhoitis. True. I read the documentation. So which do you pick? Commented Jul 11, 2015 at 20:12
• Well, you differentiated with respect to yfirst before x, so... ;) with respect to multiple integrals, the convention of "outermost limits first" can be admittedly confusing at first. Commented Jul 11, 2015 at 20:15
• Use D[f[x, y], x, y] // Trace Commented Jul 11, 2015 at 21:53

TraditionalForm[HoldForm @ D[f[x, y], x, y]]


D[f[x,y],x,y] first differentiates with respect to x, then to y!

Simply test it with ToString[y]:

In[18]:= f[x_, y_] = Sin[x y]

In[19]:= D[f[x, y], x, ToString[y]] // Quiet

Out[19]= D[y Cos[x y], y]

In[20]:= D[f[x, y], ToString[y], x] // Quiet

Out[20]= D[Sin[x y], y, x]


both stop at the first ToString[...].