What's a good example to illustrate the fact that a function all of whose partial derivatives exist may not be continuous?

3$\begingroup$ I removed the tag "matheducation" (and replaced it by "examples"). Remember: this whole site is matheducation in the sense that people are asking math questions and hoping to learn from the answers. The tag should be saved for questions with an explicit pedagogical component. $\endgroup$– Pete L. ClarkMar 25, 2010 at 14:43
4 Answers
The standard example I have seen is: $f(x,y)=\frac{2xy}{x^2+y^2}$.

$\begingroup$ But surely that's continuous on its domain of definition. $\endgroup$ Mar 25, 2010 at 14:23

5$\begingroup$ Define it to be 0 at (0,0) and it's discontinuous there, although the partial derivatives exist. $\endgroup$ Mar 25, 2010 at 14:25

3$\begingroup$ However you define f at the origin, it will be discontinuous since its limit along the coordinate axes is zero, whereas it is 1 along the diagonal of $\mathbb R^2$. You get wilder example by starting with any antisymmetric function on the unit circle (say nonmeasurable) and extending it linearly on all (vector)lines of the plane i.e. defining $f(ra)=rf(a)$ for $r \in \mathbb R$ and $a$ on the circle. $\endgroup$ Mar 25, 2010 at 15:58

$\begingroup$ In George's "wilder example", further conditions on f will be needed to make the partial derivatives exist everywhere (is that what the proposer wanted?) $\endgroup$ Mar 25, 2010 at 16:36

$\begingroup$ Bjorn is right, of course: the example was only meant to show that a function can be quite pathological and yet have directional derivatives in all directions at the origin. The construction is the source of a few amusing exercises: e.g. the extended function is continuous at the origin iff the function on the circle is bounded. On the other hand even if you start with a $C^{\infty}$ function on the circle (seen as submanifold of $\mathbb R^2$) the extended function on the plane will NOT be differentiable at the origin in general ( think bump function on the circle). $\endgroup$ Mar 25, 2010 at 18:13
I feel it's more informative to have the thought process that leads to the example rather than just be told some magic formula that works, however simple that formula might be.
Here is a way of explaining it. We'll decide that our function is going to be discontinuous at (0,0). In order to ensure that the partial derivatives there are defined we'll try the simplest thing and make the function zero on the two axes. How can we make sure that it is discontinuous at (0,0)? Well, a simple way might be to make the function equal to 1 on the line x=y. (If you object that that step was unmotivated, then read on  it will become clear that I could have chosen pretty well any function and the argument still works.) How are we going to make sure that the function has partial derivatives everywhere? We could do it by trying to give it a nice formula everywhere. We care particularly about how the function behaves when you keep x or y constant, so let's see what happens if we try to choose the nicest possible dependence on y for each fixed x. If we do that then we'll be tempted to make the function linear. Since f(x,0)=0 and f(x,x)=1, this would tell us to choose f(x,y)=y/x.
Unfortunately, that doesn't work: we also need the function to tend to zero for fixed y as x tends to zero. But at least this has given us the idea that we would like to write f as a quotient. What properties would we need of g and h if we tried f(x,y)=g(x,y)/h(x,y)? We would want g(x,0)=g(0,y)=0, g(x,x)=h(x,x), and h(x,y) is never 0 (except that we don't mind what happens at (0,0). We also want g and h to be nice so that the partial derivatives will obviously exist. The simplest function that vanishes only if (x,y)=(0,0) is $x^2+y^2$. The simplest function that vanishes when x=0 or y=0 but not when $x=y\ne 0$ is $xy$. Multiply that by 2 to get 1 down the line x=y and there we are.
Now suppose we had wanted the value to be, say, $e^{1/x}$ at (x,x), so that the function is wildly unbounded near (0,0). Then we could just multiply the previous function by $\exp((2/(x^2+y^2))^{1/2})$.
The main point I want to make is that we could just as easily have chosen many other functions. For example, $\sin(x)\sin(y)/(x^4+y^4)$ vanishes on the axes and clearly does not tend to zero down the line x=y (in fact it tends to infinity).
I was travelling when this came up.
With the same results as Georges Elencwajg's comment and Marco's recent answer, take $$ f(x,y) = \frac{2 x^2 y}{x^4 + y^2} $$ and set to $0$ at the origin $(0,0).$ Along any line through the origin $ x = a t, \; y = b t$ the limit is 0, as $$  f(a t, b t)  \leq a^2  t / b  . $$ However, along the parabola $y = x^2$ the value is 1, and along the parabola $y =  x^2$ the value is $1.$
To get "directional derivative" 0 in every direction through the origin switch to $$ g(x,y) = \frac{2 x^3 y}{x^6 + y^2} $$ as $$  g(a t, b t)  \; \leq \; t^2 \;  a^3 / b  $$ when $b \neq 0,$ but then if $y = \pm x^3$...the directional derivative generalizes to the Gateaux derivative in other settings.
Consider $f(x,y)=1$ on the set $\lbrace{(x,y):y=x^2}\rbrace\backslash\lbrace(0,0)\rbrace$ and $f(x,y)=0$ on any other point.