# Does there exist a function $f:\mathbb{R}^2\to\mathbb{R}$ that is discontinuous at a point but all of whose directional derivatives exist there?

Can such function exist whose all directional derivatives exist at a point but it isn't continuous at that point? Preferably give examples of $f: \Bbb R^2 \rightarrow \Bbb R$ . Our teacher said such a function can exist but the example he gave had one undefined directional derivative.

Yes.

Here is a simple and natural way to construct such a function, with the discontinuity at the origin. I don't see this method discussed elsewhere on MSE. There are other, plucked-out-of-a-hat examples, but this is surely the simplest.

You want the function to be smooth along every line into the origin; that'll guarantee the directional derivatives exist at the origin in any direction. But we can make it discontinuous at the origin by setting it to have a different value along a nonlinear curve through the origin.

This is easy! Just take $f(x,y)=0$ except when $y=x^2$ and $x\neq0$, in which case it is some other constant, say $1$. Symbolically:

$$f(x,y)=\begin{cases}1 & y=x^2, x\neq0\\ 0 & \text{otherwise}\end{cases}$$

The function isn't continuous at the origin because the value there is $0$ but approaching along the parabola yields a limit of $1$.

But the directional derivatives all exist because

$$\frac{f(hv_1,hv_2)}{h}=0$$

for all sufficiently small $h$.

The point of this sort of counterexample is that directional derivatives, which enforce a degree of smoothness along lines, are not sensitive enough to detect irregularity along nonlinear curves.

• So in this example, in the limit expression to get directional derivative, we have no option but to put $f(hv_1,hv_2)$ to be 0 . This is because supposing for a particular value of h and (v1,v2), $(hv_1,hv_2)$ does somehow lie on $y=x^2$, as we are taking limit $h \rightarrow 0$, $f(hv_1,hv_2)$ will change to 0. All this is happening because the slope of the line joining origin and y=x^2 is changing. Is this what you meant? – Red Floyd Nov 16 '17 at 5:52
• I can't make much sense of your comment. The expression we take the limit of to get the directional derivative must vanish when $h$ is sufficiently close to zero; that is why I said "for all sufficiently small $h$." If $h$ is too big, $h(v_1, v_2)$ might indeed intersect the parabola. But as we shrink $h$ we eventually avoid this problem. – symplectomorphic Nov 16 '17 at 5:55