Clairaut's Theorem: When are Mixed Partial Derivatives Equal?

A bit on Clairaut's Theorem: Suppose f is defined on a disk D that contains the point (a,b). If the functions (Subscript[f, x y]) and (Subscript[f, y x]) are both continuous on D, then (Subscript[f, x y])(a,b)=(Subscript[f, y x])(a,b).

The Basic Idea Behind Clairaut's Theorem

If we have a small change in a and a small change in b, the point (a,b) will become (a+Δ a,b+Δ b). Using the definition of derivative, we can write

(Subscript[f, x y])(a,b) = (lim_(Δb->0))( (lim_(Δa->0))(((f(a+Δa,b+Δb)-f(a,b+Δb)-f(a+Δa,b)+f(a,b))/(Δa Δb))))
(Subscript[f, y x])(a,b) = (lim_(Δa->0))( (lim_(Δb->0))(((f(a+Δa,b+Δb)-f(a,b+Δb)-f(a+Δa,b)+f(a,b))/(Δa Δb))))

So the question reduces to if these limits are the same, which they will be provided (Subscript[f, x y]) and (Subscript[f, y x]) are continuous functions. A rigorous proof requires the use of the Mean Value Theorem.

Example where (Subscript[f, x y])(x,y)=(Subscript[f, y x])(x,y)

f[x_,y_]=((x y)/((x^2)+(y^2)+5))

The function is continuous and smooth:

Plot3D[f[x,y],{x,-5,5},{y,-5,5},AxesLabel->{"x","y","z"}]

Notice that the first derivatives are defined, and they are also smooth:

fx[x_,y_]=D[f[x,y],x]
fy[x_,y_]=D[f[x,y],y]

Plot3D[fx[x,y],{x,-5,5},{y,-5,5},AxesLabel->{"x","y","z"}]
Plot3D[fy[x,y],{x,-5,5},{y,-5,5},AxesLabel->{"x","y","z"}]

Plots of the second derivatives show difficulties at the origin due to the sharp point we saw above (The second derivatives will have different values from 
different directions).

fxy[x_,y_]=D[fx[x,y],y]
fyx[x_,y_]=D[fy[x,y],x]

Plot3D[fxy[x,y],{x,-5,5},{y,-5,5},AxesLabel->{"x","y","z"},PlotRange->{All,All,All}]
Plot3D[fyx[x,y],{x,-5,5},{y,-5,5},AxesLabel->{"x","y","z"},PlotRange->{All,All,All},PlotStyle->Directive[Yellow,Specularity[White,20],Opacity[0.8]]]

They are a perfect match:

Show[%,%%]

Example where (Subscript[f, x y])(a,b)≠(Subscript[f, y x])(a,b)

f[x_,y_]=Piecewise[{{(((x^3)y-x (y^3))/((x^2)+(y^2))),x≠0&&y≠0},{0,x==0&&y==0}}]

The function is continuous and smooth:

Plot3D[f[x,y],{x,-5,5},{y,-5,5},AxesLabel->{"x","y","z"}]

Notice that the first derivatives are defined, but that they possess a sharp point at the origin.

fx[x_,y_]=D[f[x,y],x]
fy[x_,y_]=D[f[x,y],y]

Plot3D[fx[x,y],{x,-5,5},{y,-5,5},AxesLabel->{"x","y","z"}]
Plot3D[fy[x,y],{x,-5,5},{y,-5,5},AxesLabel->{"x","y","z"}]

Plots of the second derivatives show difficulties at the origin due to the sharp point we saw above (The second derivatives will have different values from 
different directions).

fxy[x_,y_]=D[fx[x,y],y]
fyx[x_,y_]=D[fy[x,y],x]

Plot3D[fxy[x,y],{x,-5,5},{y,-5,5},AxesLabel->{"x","y","z"}]
Plot3D[fyx[x,y],{x,-5,5},{y,-5,5},AxesLabel->{"x","y","z"}]

Mathematica gives us an incorrect result if we ask for the value of the second derivatives at the origin:

fxy[0,0]

If we take a step back and instead evaluate limits, we get correct results:

Limit[((3 (x^2)-3 (y^2))/((x^2)+(y^2)))-((2 x ((x^3)-3 x (y^2)))/((((x^2)+(y^2)))^2))-((2 y (3 (x^2) y-(y^3)))/((((x^2)+(y^2)))^2))+((8 x y ((x^3) y-x (y^3)))/((((x^2)+(y^2)))^3)),x->0]
Limit[%,y->0]

So (Subscript[f, x y])(0,0)=-1.

Limit[((3 (x^2)-3 (y^2))/((x^2)+(y^2)))-((2 x ((x^3)-3 x (y^2)))/((((x^2)+(y^2)))^2))-((2 y (3 (x^2) y-(y^3)))/((((x^2)+(y^2)))^2))+((8 x y ((x^3) y-x (y^3)))/((((x^2)+(y^2)))^3)),y->0]
Limit[%,x->0]

So (Subscript[f, y x ])(0,0)=+1. This shows the following (notice the only difference was in the order we took the two limits):

(Subscript[f, x y])(a,b) = (lim_(Δb->0))( (lim_(Δa->0))(((f(a+Δa,b+Δb)-f(a,b+Δb)-f(a+Δa,b)+f(a,b))/(Δa Δb))))=-1

(Subscript[f, y x])(a,b) = (lim_(Δa->0))( (lim_(Δb->0))(((f(a+Δa,b+Δb)-f(a,b+Δb)-f(a+Δa,b)+f(a,b))/(Δa Δb))))=+1

Notice that this agrees with the sketches above.

This does not violate Clairaut's theorem since the second derivatives are not continuous at (0,0) (that's what the two limits being unequal shows). Anywhere else, even very very very close to (0,0), the mixed second partial derivatives are equal.

fxy[-1.23*(10^(-20)),1.21*(10^(-20))]
fyx[-1.23*(10^(-20)),1.21*(10^(-20))]