Is this piecewise function differentiable at the origin? Let $f: \mathbb{R}^2 \to \mathbb{R}$ be defined by:
$f(x,y) = \begin{cases}y - x^2, & y\geq x^2 \\0, & -x^2\leq y < x^2 \\ y + x^2, & y < -x^2\end{cases}$
(a) Is $f$ differentiable at the origin?
(b) Is f of class $C^1$ at the origin?
My attempt at a solution:
$\frac{\partial f}{\partial x}(0,0)$ = $\lim_{h\to0}\frac{f(h,0) - f(0,0)}{h} =$ $\lim_{h\to0}\frac{(0 - h^2) - (0-0)}{h} = -h^2/h =$$-h = 0$
$\frac{\partial f}{\partial y}(0,0)$ = $\lim_{h\to0}\frac{f(0,h) - f(0,0)}{h} =$ $\lim_{h\to0}\frac{(h - 0) - (0-0)}{h} = h/h = 1$
So the partial derivatives exist at $(0,0)$ and $\nabla f = (0,1)$
(b) I can see that $f$ is not $C^1$ since the partial derivatives of $f$ with respect to $y$ are not continuous at $(0,0)$
(a) If $f$ were differentiable at the origin, then:
$\lim_{(s,t) \to (0,0)} \frac{f(0+s,0+t) - f(0,0) - \langle 0,1 \rangle \cdot (s,t)}{|(s,t)|} \to 0$
which simplifies to:
$\lim_{(s,t) \to (0,0)} \frac{f(s,t)-t}{|(s,t)|} = 0$
If this were true then:
$(1) \qquad \lim_{(s,t) \to (0,0)} \frac{-s^2}{\sqrt{s^2+t^2}} = 0, \qquad \text{on the set where $t \ge s^2$}$
$(2) \qquad \lim_{(s,t) \to (0,0)} \frac{-t}{\sqrt{s^2+t^2}} = 0, \qquad \text{on the set where $-s^2 \leq t < s^2$}$
$(3) \qquad \lim_{(s,t) \to (0,0)} \frac{s^2}{\sqrt{s^2+t^2}} = 0, \qquad \text{on the set where $t < - s^2$}$
Approaching along the linear path $s = mt$ we see that $(1)$ and $(3)$ evaluate to $0$ but that $(2)$ evaluates to $\frac{-1}{\sqrt{m+1}}$
Thus the limit
$\lim_{(s,t) \to (0,0)} \frac{f(s,t)-t}{|(s,t)|}$ does not exist and $f$ is not differentiable at the origin.
Is this a correct solution?
The only other way I can think to do this question is by using the properties of direction derivatives.
Let $u = (sin (\theta), cos(\theta))$
Then the directional derivative of $f$ at $(0,0)$ in the direction of $u$ is defined to be
$\partial_u f(0,0)= lim_{t \to 0} \frac{f((0,0) +t(sin(\theta), cos(\theta)) - f(0,0)}{t}$
$= lim_{t \to 0} \frac{f(tsin(\theta), tcos(\theta))}{t}$
$= lim_{t \to 0} \frac{tcos(\theta) -t^2sin^2(\theta)}{t}$
$= cos(\theta)$
So the directional derivatives of $f(0,0)$ all exist and are given by:
$\partial f(0,0) = \nabla f(0,0)\bullet u = (0,1) \bullet (sin(\theta), cos(\theta)) =(0,cos(\theta))$
Wouldn't this imply that the f is differentiable at the origin?
Furthermore, since all of the partial derivatives at the origin exist and are continuous, $f$ is $C^1$ at the origin?
 A: Certainly $f$ is not of class $C^1$ at the origin: there is no neighborhood of $(0,0)$ in which $\partial f/\partial y$ exists and is continuous. To see why, in the region $-x^2 < y < x^2$ we have $\partial f/\partial y = 1$, whereas in the region $y \ge x^2$ we have $\partial f/\partial y = 0$. These do not match up continuously at any point of the parabola $y=x^2$, and yet every neighborhood of $(0,0)$ has points on that parabola.
Also, in your attempt to prove that $f$ is differentiable, perhaps you wanted to use the theorem which says that if $f$ is $C^1$ in a neighborhood of $(0,0)$ then $f$ is differentiable in that neighborhood. But, since $f$ is not $C^1$ in any neighborhood, this theorem gives no information about differentiability at $(0,0)$.
So it looks like you have to go back to the definition of the multivariable derivative. You already know that $\partial f/\partial x(0,0)=0$ and $\partial f/\partial x(0,0)=1$. So what you have to determine is whether
$$\lim_{(s,t) \to (0,0)} \frac{f(0+s,0+t) - f(0,0) - \langle 0,1 \rangle \cdot (s,t)}{|(s,t)|} \to 0
$$
which simplifies to
$$\lim_{(s,t) \to (0,0)} \frac{f(s,t)-t}{|(s,t)|} = 0
$$
This breaks into three separate limits, and you have to check whether each is true:
$$(1) \qquad \lim_{(s,t) \to (0,0)} \frac{-s^2}{\sqrt{s^2+t^2}} = 0, \qquad \text{on the set where $t \ge s^2$}
$$
$$(2) \qquad \lim_{(s,t) \to (0,0)} \frac{-t}{\sqrt{s^2+t^2}} = 0, \qquad \text{on the set where $-s^2 < t < s^2$}
$$
$$(3) \qquad \lim_{(s,t) \to (0,0)} \frac{s^2}{\sqrt{s^2+t^2}} = 0, \qquad \text{on the set where $t \le - s^2$}
$$
Are they true?
It's pretty easy to see that (1) is true, because the limit equation is true on the whole $(s,t)$ plane, since $f(x,y)=y-x^2$ is differentiable with partial derivatives equal to $0$ at $(0,0)$. So the limit is true when restricted to $t \ge s^2$. Similarly for (3).
The limit (2) is also true, although the proof is a bit trickier. If we divide the top and bottom by $s$ we'll get 
$$\frac{-\frac{t}{s}}{\sqrt{1 + \bigl(\frac{t}{s}\bigr)^2}}
$$
As $(s,t)$ approaches $(0,0)$ in the region $-s^2 \le t < s^2$, the ratio $\frac{t}{s}$ approaches $0$. So the limiting value is
$$\frac{-0}{\sqrt{1 + \bigl(0\bigr)^2}} = 0
$$
Notice, these limit arguments are not about "approaching $(0,0)$ along paths". Thinking about approaching $(0,0)$ along paths can be a useful argument for disproving a limit equation, but for proving a limit equation it's not a very useful way to think.
