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.