# Example of a function $f:\mathbb{R}^2\to\mathbb{R}$ not differentiable at $(0,0)$, but has a directional derivative at $(0,0)$ in all directions

Give an example of a function $f:\mathbb{R}^2\to\mathbb{R}$ such that $f'_u(0,0)$ exists in all directions $\|u\| = 1$, but $f$ is not differentiable at $(0,0)$. You have to show that your example satisfy the above requirement.

-

$$f(x,y) = \left\{\begin{array}{ll}0 & (x,y)=(0,0)\\0&y\neq x^2\\1 & y=x^2, (x,y) \neq (0,0) \end{array} \right.$$

In every direction the line spanned by $u$ can only intersect the parabola twice, so for $(x,y)$ close to the origin we have $y\neq x^2$ and $f(x,y)=0$, so $f'_u(0,0) = 0$. However, taking the path $f(x,x^2)$ we have that $f(x,x^2) \to 1$ as $x \to 0$. It follows that $f$ is not continuous at $(0,0)$ so it cannot be differentiable.

As a bonus, it is actually possible to construct a continuous function which has this property, but it is a little more complicated and not as easy to prove, so I leave thinking about that to you.

-

Define $f:\mathbb R^2\to\mathbb R$, by $$f(x,y)= \frac{x^2y}{x^4+y^2}, \text{when} (x,y)\neq (0,0)$$ and $$f(0,0)= 0$$ This function is not continuous at $(0,0)$. Hence not differentiable. But direction derivative exits for all $v$. This is not continuous because, if you approach to $(0,0)$ via line $y= mx$, we have different limit of $f$.

For $v= (v_1,v_2)$, $\|v\|=1$, we have direction derivative of $f$ in the direction $v$ at $(0,0)$ is $$D_vf(0,0)=\lim_{t\to 0}\frac{f[(0,0)+t(v_1,v_2)]-f(0,0)}{t}=0 \text{ if } v_2=0$$ and above limit equal to $\frac{v_1^2}{v_2}$ if $v_2\neq 0$. Hence limit exits for all $v$. Hence direction derivative exists for all $v$. But not continuous.

-

Define $f$ arbitrarily on the semicircle $x^2+y^2=1, x>0$. For example make it wildly discontinuous, or even non-Borel-measurable. Then define $f$ to be linear on each line through the origin.

-

Not an answer: See comment below:

$$f(x,y)=\frac{y}{|y|}\sqrt{x^2+y^2}\text{ if } y\neq 0$$ and $f(x,y)=0$ if $y=0$. It is continuous at $(0,0)$ but not differentiable. Though direction derivative exists for all $v$. Check it.

-
This function is not defined along an entire line in $\mathbb{R}^2$, and it can't be continuously extended over the line $y=0$ either. So I don't think this would count. I also think it's misleading to say that it's continuous at $(0,0)$. Maybe with respect to its true domain, but not if $\mathbb{R}^2$ is the input space. –  alex.jordan May 6 '12 at 17:00
Yes you are right... Thanks for pointing out.. Let me write this in answer itself... –  Junu May 6 '12 at 17:09
This is still an example worth thinking about. I did not downvote. –  alex.jordan May 6 '12 at 18:02
@alex.jordan this example works!! –  Neeraj Bhauryal Aug 28 '13 at 15:05
@Neeraj Making me think about a post that's over a year old, eh? This function is not even defined when $y=0$ (along the $x$-axis), so how can it have a directional derivative at $(0,0)$ in the direction of the $x$-axis? –  alex.jordan Aug 29 '13 at 0:59