# Examining the function $f(x,y)=xy(x^2-y^2)/(x^2+y^2)$

Consider the function $$f(x,y)=\begin{cases} xy\dfrac{x^2-y^2}{x^2+y^2},&(x,y)\ne(0,0)\\ 0,&(x,y)=(0,0) \end{cases}$$

I can show that $f_x(0,0)=f_y(0,0)=0$.

f[x_, y_] = If[{x, y} != {0, 0}, x y (x^2 - y^2)/(x^2 + y^2), 0];
Limit[(f[0 + h, 0] - f[0, 0])/h, h -> 0]
Limit[(f[0, 0 + h] - f[0, 0])/h, h -> 0]


Hand calculations produce the same results. Because $f(0,0)=0$, the tangent plane is $z=0$.

Consider:

DynamicModule[{f},
f[x_, y_] = x y (x^2 - y^2)/(x^2 + y^2);
Manipulate[
Show[
Plot3D[{f[x, y], 0}, {x, -w, w}, {y, -w, w},
PlotStyle -> {Directive[Red], Directive[LightBlue, Opacity[.8]]},
PlotRange -> All,
BoxRatios -> Automatic,
PerformanceGoal -> "Quality"]
],
{{w, 2.5}, .01, 3}
]]


Which produces this image:

When you move the slide, things appear to flatten out. I can show that the function $f$ is continuous at (0,0). Let $\epsilon>0$. Choose $\delta=\sqrt{\epsilon/2}$. Then, whenever $0<|(x,y)-(0,0)|<\delta$, or equivalently, whenever $0<\sqrt{x^2+y^2}<\delta=\sqrt{\epsilon/2}$, then: \begin{align*} \left|f(x,y)-f(0,0)\right| &=\left|xy\dfrac{x^2-y^2}{x^2+y^2}-0\right|\\ &=\dfrac{|x^3y-xy^3|}{x^2+y^2}\\ &\le \dfrac{x^2|xy|+y^2|xy|}{x^2+y^2}\\ &\le2|xy|\\ &=2|x||y|\\ &\le2\sqrt{x^2+y^2}\sqrt{x^2+y^2}\\ &=2(x^2+y^2)\\ &<\epsilon \end{align*}

However, in order for the tangent plane to be a good approximation of f near (0,0), f must be differentiable at (0,0). There is a theorem that says that if the partial derivatives exist on an open region containing (0,0) and if they are continuous at (0,0), then f is differentiable at (0,0) and the talent plane is a good approximation of f near (0,0).

So, I compute $f_x(x,y)$.

fx[x_, y_] = D[f[x, y], x] // Simplify


And we have already verified that $f_x(0,0)=0$, so: $$f_x(x,y)=\begin{cases} \dfrac{y(x^4+4x^2y^2-y^4)}{(x^2+y^2)^2},&(x,y)\ne(0,0)\\ 0,&(x,y)=(0,0) \end{cases}$$

Now, is $f_x(x,y)$ continuous at (0,0)?

Plot3D[fx[x, y], {x, -3, 3}, {y, -3, 3},
MeshFunctions -> {#3 &}]


Which produces this image:

ContourPlot[fx[x, y], {x, -3, 3}, {y, -3, 3}]


Which produces this image.

There are a few contours that approach (0,0), but if I hover my mouse over them and approach the origin, they are all equal to 0. So I don't see a path to the origin that will give me an answer different from zero. Still, this doesn't prove that it is continuous at (0,0).

I can't come up with a hand calculation proof that $\displaystyle lim_{(x,y)\to(0,0)}f_x(x,y)=f_x(0,0),$ so I started to try to use Mathematica to show that $$\left|\dfrac{y(x^4+4x^2y^2-y^4)}{(x^2+y^2)^2}-0\right|<\epsilon\quad\text{whenever}\quad0<\sqrt{x^2+y^2}<\delta.$$

I tried

Solve[Abs[fx[x, y] - 0] < 0.1, {x, y}]


Which I had to abort. Then I tried:

Solve[-0.1 < fx[x, y] < 0.1, {x, y}]


Then I tried:

Reduce[-0.1 < fx[x, y] < 0.1, {x, y}]


Not much luck in any case. How can I go about finding a region about (0,0) so that

$$\left|\dfrac{y(x^4+4x^2y^2-y^4)}{(x^2+y^2)^2}-0\right|<0.1$$

• By the way, I would define f with f[x_, y_] := Piecewise[{{x y (x^2 - y^2)/(x^2 + y^2), x != 0 && y != 0}}, 0]. Piecewise is usually better that If for defining mathematical functions. – Michael E2 Jul 14 '15 at 17:55
• @MichaelE2. I know Piecewise is easier to use when you have more than two branches, but are you also referring to a performance issue? Is Piecewise faster in general? – David Jul 14 '15 at 18:21
• Yes, but not so much about speed. I'm not sure I can recall all the issues. Perhaps the most important is built-in discontinuity processing for Plot, NDSolve, etc. -- even D: Compare D[If[x >= 0, x^2, 1], x] vs. D[Piecewise[{{x^2, x >= 0}}, 1], x]. Another difference is that Piecewise evaluates its arguments (even though it is HoldAll); If does not. Whether that's an advantage or not might depend, but it's a difference to keep in mind. – Michael E2 Jul 14 '15 at 18:43
• @MichaelE2. I finally came up with a hand proof that $f_{x}(x,y)$ is continuous at (0,0). For $\epsilon>0$, I found that $\delta=\epsilon/5$ would work. Hence, with $\epsilon=0.1$, my $\delta=1/50$, which turns out to be your res[[3]]. – David Jul 14 '15 at 21:04

Reduce (on exact input) returns quickly and series of conditions joined by Or. The first one implies any disk of radius less than 1/10, d being the radius squared, is sufficient.

res = Reduce[-1/10 < (y (x^4 + 4 x^2 y^2 - y^4))/(x^2 + y^2)^2 < 1/10 &&
x^2 + y^2 < d, {d, x, y}];
dom = If[Head[res] == Or, First[res]]
(*
0 < d <= 1/100 && (
(-Sqrt[d] < x < 0 && -Sqrt[d - x^2] < y < Sqrt[d - x^2]) ||
(x == 0 && (-Sqrt[d] < y < 0 || 0 < y < Sqrt[d])) ||
(0 < x < Sqrt[d] && -Sqrt[d - x^2] < y < Sqrt[d - x^2]))
*)

Block[{d = 1/100},
RegionPlot[dom, {x, -1/3, 1/3}, {y, -1/3, 1/3}]
]


The result fits with the image of $f_x$ in the question, too.

• I gave this a try with: dom = res[[3]]; Block[{d = 1/50}, RegionPlot[dom, {x, -1/3, 1/3}, {y, -1/3, 1/3}] ], but it didn't work. And after executing this command, res no longer existed. – David Jul 14 '15 at 21:12
• @David By "res no longer existed," you perhaps meant that your kernel crashed. At least mine did. But it seems to work if you take it in stages: dom = res[[3]]; Block[{d = 1/50}, newdom = dom]; RegionPlot[newdom, {x, -1/3, 1/3}, {y, -1/3, 1/3}]. Crashing with RegionPlot is not unfamiliar to me, but I don't know why it did. In this version dom is evaluated once and for all and the result stored in newdom. In the other code, dom is reevaluated many times. I don't know why that would matter, though. – Michael E2 Jul 14 '15 at 21:28
• You are right. I didn't have the sound on my computer up loud enough, so I didn't hear the beep. Now I do. You suggestions works, though the image is a little strange. Not a perfect circle. – David Jul 15 '15 at 4:29