Counterexample second order mixed partial derivatives I know a few examples of functions $f:\mathbb{R}^2\to\mathbb{R}$ for which $\frac{\partial^2f}{\partial x\partial y}(0,0)$ and  $\frac{\partial^2f}{\partial y\partial x}(0,0)$ both exist and are different but I cannot find one where one exists and the other does not. See here for the case when they both exist. counterexample
One of my students asked me in class and I couldn’t come up with one. Has anyone seen one? If possible I would like one where both first order partial derivatives exist. Thanks!
 A: $$f(x,y)=|x|(y^2+1). {}{}{}{}$$
A: For $(x, s) \in \mathbb{R}^{2}$, define
$$
g(x, s) =
\begin{cases}
x - \frac{|s|}{2} & x > |s|
\\
\frac{x^{2}}{2|s|} & -|s| \leq x \leq |s|
\\
-x - \frac{|s|}{2} & x < -|s|.
\end{cases}
$$
Let $f(x, y) = \int_{0}^{y} g(x, s) \mathrm{d} s$. For $(x, y) \in \mathbb{R}^{2}$,
$$
\frac{\partial f}{\partial y}(x, y)
=\lim_{h \rightarrow 0} \frac{f(x, y + h) - f(x, y)}{h}
= \lim_{h \rightarrow 0} \frac{\int_{y}^{y + h} g(x, s) \mathrm{d} s}{h}
= g(x, y),
$$
since $g$ is continuous in $s$ for each fixed $x$. Along the line $y = 0$, $g(x, 0) = |x|$, so $\frac{\partial^{2} f}{\partial x \partial y}(0, 0)$ does not exist. Moreover, for $y \neq 0$,
$$
\frac{\partial f}{\partial x}(x, y)
= \lim_{h \rightarrow 0} \frac{f(x + h, y) - f(x, y)}{h}
= \lim_{h \rightarrow 0} \int_{0}^{y} \frac{g(x + h, s) - g(x, s)}{h} \mathrm{d} s.
$$
Since $g$ is Lipschitz in $x$ with constant at most 1 (independent of $s$), we can apply dominated convergence to get
$$
\frac{\partial f}{\partial x}(x, y)
= \int_{0}^{y} \frac{\partial g}{\partial x}(x, s) \mathrm{d} s.
$$
In the case $y = 0$, we have
$$
\frac{\partial f}{\partial x}(x, 0) = 0
$$
since $f \equiv 0$ along that line. Finally,
$$
\frac{\partial^{2} f}{\partial y \partial x}(0, 0)
= \lim_{h \rightarrow 0}
  \frac{\frac{\partial f}{\partial x}(0, h)
    - \frac{\partial f}{\partial x}(0, 0)}{h}
= \lim_{h \rightarrow 0} \frac{\int_{0}^{h} 0 \mathrm{d} s - 0}{h}
= 0,
$$
because $\frac{\partial g}{\partial x}(0, s) = 0$ for any $s \neq 0$.
