Off[General::spell]
Off[General::spell1]

The clam shell function - when mixed partial derivatives are not equal

For most functions of two variables that we'll deal with, the mixed second order partial derivatives will be equal. But that's not always the case.  

Here's an example where that falls down.

Consider the function f(x,y) = ((x (y^3) - (x^3) y)/((x^2) + (y^2)))(but parameterised in terms of r and ϕ for the benefit of graphing).

x[r_, ϕ_] :=  r Cos[ϕ];
y[r_, ϕ_] :=  r Sin[ϕ];
f[r_, ϕ_] := ((x[r, ϕ] y[r, ϕ]^3 - x[r, ϕ]^3 y[r, ϕ])/(x[r, ϕ]^2 + y[r, ϕ]^2))

Notice that when I plot f(r,ϕ), I can't plot r = 0 because the function becomes indeterminate: like (1/0).

p1 = 
        ParametricPlot3D[{x[r, ϕ], y[r, ϕ], 2  f[r, ϕ], 
            EdgeForm[]}, {r, 0.0001, 1}, {ϕ, 0, 2  π}, 
          PlotPoints -> {16, 64}, 
          Boxed -> False];
p2 = 
        ParametricPlot3D[{0, y, 0}, {y, -1, 1}, 
          DisplayFunction -> Identity];
p3 = 
        ParametricPlot3D[{x, 0, 0}, {x, -1, 1}, 
          DisplayFunction -> Identity];
p4 = 
        ParametricPlot3D[{x, x, 0}, {x, -1, 1}, 
          DisplayFunction -> Identity];
p5 = 
        ParametricPlot3D[{x, -x, 0}, {x, -1, 1}, 
          DisplayFunction -> Identity];

So what happens when r = 0? Or equivalently, what happens at (x, y) = (0, 0)? To answer that question we need to find the limits of the function as x and y -> 0.  We'll start by defining the function exclusively in cartesian coordinates, but noting that (x, y) ≠ (0, 0).

F[x_, y_] := ((x (y^3) - (x^3) y)/((x^2) + (y^2)))

Now, let's assess the limits of F(x, y) as we approach x = 0 from the positive and negative sides, for any y. Then we'll do the same thing for the limits of F(x, y) as we approach y = 0 from the positive and negative sides.

{Limit[F[x, y], x -> 0, 
        Direction -> 1], 
Limit[F[x, y], x -> 0, 
        Direction -> -1], 
Limit[F[x, y], 
        y -> 0, Direction -> 1], 
Limit[F[x, y], 
        y -> 0, Direction -> -1]}

In all directions it appears that the function -> 0 as we approach the origin. Just to be sure, we can do the same thing for approaching x = 0 from the positive and negative sides, whilst at the same time approaching y = 0 from the positive and negative sides.

{Limit[Limit[F[x, y], x -> 0, Direction -> 1], y -> 0, 
        Direction -> 1], 
Limit[
        Limit[F[x, y], x -> 0, Direction -> -1], y -> 0, 
        Direction -> 1], 
Limit[
        Limit[F[x, y], x -> 0, Direction -> 1], y -> 0, 
        Direction -> -1], 
Limit[
        Limit[F[x, y], x -> 0, Direction -> -1], y -> 0, 
        Direction -> -1], 
Limit[
        Limit[F[x, y], y -> 0, Direction -> 1], x -> 0, 
        Direction -> 1], 
Limit[
        Limit[F[x, y], y -> 0, Direction -> -1], x -> 0, 
        Direction -> 1], 
Limit[
        Limit[F[x, y], y -> 0, Direction -> 1], x -> 0, 
        Direction -> -1], 
Limit[
        Limit[F[x, y], y -> 0, Direction -> -1], x -> 0, 
        Direction -> -1]}

As expected all answers = 0. So the function will be continuous if we add the condition F(x, y) = 0 for (x, y) = (0, 0).

Show[p1, p2, p3];

But are the derivatives continuous? 

These are the first order partial derivatives of F(x, y):

fx[x_, y_] = Simplify[D[F[x, y], {x, 1}]]
fy[x_, y_] = Simplify[D[F[x, y], {y, 1}]]

which are again indeterminate at (0, 0) so we need a special case for the origin. We can use a similar approach to above by using the definition of the derivative and some limit analysis. Note that in the numerator 0 is really F[0, 0].

Limit[((F[h, 0] - 0)/h), h -> 0]
Limit[((F[0, h] - 0)/h), h -> 0]

So as we approach the origin, the first derivatives -> 0 as well. 

We can show this to be the case with some graphs. To make the plotting easier I'll first parameterise in terms of cylindrical coordinates and plot for increasing radii not including r = 0.

Fx[r_, ϕ_] := 
      fx[x, y] /. {x ->  r Cos[ϕ], 
          y -> r Sin[ϕ]}
Fy[r_, ϕ_] := 
      fy[x, y] /. {x ->  r Cos[ϕ], 
          y -> r Sin[ϕ]}

    
pFx  =  
        ParametricPlot3D[{r Cos[ϕ], r Sin[ϕ], Fx[r, ϕ], 
            EdgeForm[]}, {r, 0.0001, 1}, {ϕ, 0, 2  π}, 
          PlotPoints -> {16, 64}, Boxed -> False, 
          DisplayFunction -> Identity];
pFy  =  
        ParametricPlot3D[{r Cos[ϕ], r Sin[ϕ], Fy[r, ϕ], 
            EdgeForm[]}, {r, 0.0001, 1}, {ϕ, 0, 2  π}, 
          PlotPoints -> {16, 64}, Boxed -> False,  
          DisplayFunction -> Identity];
Show[GraphicsArray[{pFx, pFy }]];

From the graphs it is evident that the first derivatives -> 0 as we approach the origin. Hence to complete the definitions for the first derivatives we must add (Subscript[f, x]) (0,  0)  =  0and (Subscript[f, y]) (0,  0)  =  0.  Our first derivatives are now continuous everywhere. 

What about the second order partial derivatives? Especially considering that we have said that most mixed second order partial derivatives are equal.

Here's the second order partial derivatives of F(x,y): (Subscript[f, xx]), (Subscript[f, yx]), (Subscript[f, xy]),  and (Subscript[f, yy]).

fxx[x_, y_] = Simplify[D[fx[x, y], {x, 1}]]
fxy[x_, y_] = Simplify[D[fx[x, y], {y, 1}]]
fyx[x_, y_] = Simplify[D[fy[x, y], {x, 1}]]
fyy[x_, y_] = Simplify[D[fy[x, y], {y, 1}]]

It appears that the mixed partial derivatives are equal to each other. But don't be fooled because again we have an indeterminate solution at the origin. So we need to do some limit analysis to see what's happening as we approach (0, 0).

Remember that when we require \(TraditionalForm\`f\_xy\ we\ begin\ by\ holding\ y\ constant\ and\ differentiating\ f\ with\ respect\ to\ x, \(\(then\)\(\ \)\(holding\)\(\ \)\(x\)\(\ \)\(constant\)\(\ \)\(and\)\(\ \)\(differentiating\)\(\ \)\(f\_x\)\(\ \)\(with\)\(\ \)\(respect\)\(\ \)\(to\)\(\ \)\(y . \ 
          Conversely\)\(\ \)\(if\)\(\ \)\)\)we require \(TraditionalForm\`f\_yx\ we\ hold\ y\ constant\ and\ differentiate\ f\ with\ respect\ to\ x, \ 
      and\ then\ hold\ x\ constant\ and\ differentiate\ f\_x\ with\ respect\ to\ y . \ \ Again\ using\ the\ definition\ of\ the\ derivative, \ \(\(here'\) \(s\)\(\ \)\(the\)\(\ \)\(limits\)\(\ \)\(of\)\(\ \)\)\)(Subscript[f, xx]), (Subscript[f, yx]), (Subscript[f, xy]),  and (Subscript[f, yy])as the origin is approached. Note that in the numerators 0 is really fx[0, 0] and fy[0, 0] where appropriate.

Limit[((fx[h, 0] - 0)/h), h -> 0]
Limit[((fx[0, h] - 0)/h), h -> 0]
Limit[((fy[h, 0] - 0)/h), h -> 0]
Limit[((fy[0, h] - 0)/h), h -> 0]

It can be seen here that as the origin is approached (Subscript[f, xy]) -> 1  whilst (Subscript[f, yx])  ->  -1 . Thus the second order mixed partial derivatives are not equal.

Perhaps some graphs will help show this.

Fxx[r_, ϕ_] := 
      fxx[x, y] /. {x ->  r Cos[ϕ], 
          y -> r Sin[ϕ]}
Fxy[r_, ϕ_] := 
      fxy[x, y] /. {x ->  r Cos[ϕ], 
          y -> r Sin[ϕ]}
Fyx[r_, ϕ_] := 
      fyx[x, y] /. {x ->  r Cos[ϕ], 
          y -> r Sin[ϕ]}
Fyy[r_, ϕ_] := 
      fyy[x, y] /. {x ->  r Cos[ϕ], 
          y -> r Sin[ϕ]}

pFxx  =  
        ParametricPlot3D[{r Cos[ϕ], r Sin[ϕ], Fxx[r, ϕ], 
            EdgeForm[]}, {r, 0.001, 10}, {ϕ, 0, 2  π}, 
          PlotPoints -> {16, 64}, Boxed -> False, 
          DisplayFunction -> Identity];
pFxy  =  
        ParametricPlot3D[{r Cos[ϕ], r Sin[ϕ], Fxy[r, ϕ], 
            EdgeForm[]}, {r, 0.001, 10}, {ϕ, 0, 2  π}, 
          PlotPoints -> {16, 64}, Boxed -> False,  
          DisplayFunction -> Identity];
pFyx  =  
        ParametricPlot3D[{r Cos[ϕ], r Sin[ϕ], Fyx[r, ϕ], 
            EdgeForm[]}, {r, 0.001, 10}, {ϕ, 0, 2  π}, 
          PlotPoints -> {16, 64}, Boxed -> False, 
          DisplayFunction -> Identity];
pFyy  =  
        ParametricPlot3D[{r Cos[ϕ], r Sin[ϕ], Fyy[r, ϕ], 
            EdgeForm[]}, {r, 0.001, 10}, {ϕ, 0, 2  π}, 
          PlotPoints -> {16, 64}, Boxed -> False,  
          DisplayFunction -> Identity];
Show[GraphicsArray[{{pFxx, pFxy }, {pFyx, pFyy}}]];

So the second order mixed partial derivatives are not equal because we can't agree on what value they tend to as we approach the origin.

It also appears that we might have continuity problems with (Subscript[f, xx]) and (Subscript[f, yy]). Check it out for yourself.