3
$\begingroup$

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.

$\endgroup$
4
  • 3
    $\begingroup$ As noted in the docs, it will succesively differentiate in the order of the variables given to it. $\endgroup$ Commented Jul 11, 2015 at 19:55
  • $\begingroup$ @Guesswhoitis. True. I read the documentation. So which do you pick? $\endgroup$
    – David
    Commented Jul 11, 2015 at 20:12
  • $\begingroup$ 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. $\endgroup$ Commented Jul 11, 2015 at 20:15
  • 10
    $\begingroup$ Use D[f[x, y], x, y] // Trace $\endgroup$
    – Bob Hanlon
    Commented Jul 11, 2015 at 21:53

2 Answers 2

2
$\begingroup$
TraditionalForm[HoldForm @ D[f[x, y], x, y]]

enter image description here

$\endgroup$
0
$\begingroup$

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[...].

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.