$\dfrac{\partial^2 f}{\partial x \partial y} = 0 \nRightarrow f(x,y) = g(x) + h(y)$

I am working through Ted Shifrin's book Multivariable Mathematics. There is an exercise problem that is meant to demonstrate that one can have $\dfrac{\partial^2 f}{\partial x \partial y} = 0$ but$ f(x,y) \neq g(x) + h(y)$.

The question (3.6.11) is as follows: $$ \mathrm{Given} \; f(x, y) = \begin{cases} 0, \; x < 0\; \mathrm{or} \; y < 0 \\x^3, \; x \geq 0 \; \mathrm{and} \; y > 0 \end{cases} $$

  1. Show that $f$ is $C^2$

  2. Show that $\dfrac{\partial^2 f}{\partial x \partial y} = 0$

  3. Show that $f(x,y)$ cannot be written as $g(x) + h(y)$ for appropriate functions $g, h$.


I see that the domain is the entire plane except the x-axis, that is $\mathbb{R}^2 -\{y=0\}$. The function is then 0 in all quadrants except the first, where it is $x^3$.

I could show 1. and 2. above, but I am puzzled by two things.

Q1 What's wrong with writing $f(x,y) = g(x) + h(y)$ piecewise in each quadrant ?

Q2. Will anything change if the domain allows the line $y=0$ also ?

Q3. What is the takeaway from this problem ? I do not understand that.


For Q1; defining the quadrants requires both $x$ and $y$. For example, defining $$g(x):=\left\{\begin{array}{ll} 0 &\text{ if } x<0\ \text{ or } \; y < 0, \\ x^3 &\text{ if } x\geq0 \; \text{ and } \; y > 0. \end{array}\right.,$$ does not make sense as now $g(x)$ depends on $y$. More formally; if $f(x,y)=g(x)+h(y)$ then for all $(x_1,y_1),(x_2,y_2)\in\Bbb{R}^2$ we have $$f(x_1,y_1)+f(x_2,y_2)-f(x_1,y_2)-f(x_2,y_2)=0.$$ But this is clearly not the case, take for example $x_1=y_1=1$ and $x_2=y_2=-1$.


For Q2; the given function $f(x,y)$ does not extend to a function differentiable on $\Bbb{R}^2$. There are no functions with this property that are differentiable on all of $\Bbb{R}^2$. See also this excellent answer.


For Q3; the takeaway is that the implication $$\frac{\partial^2f}{\partial x\partial y}=0 \qquad\Rightarrow\qquad f(x,y)=g(x)+h(y),$$ depends crucially on the domain; it holds if the domain is $\Bbb{R}^2$, but not if the domain is, for example, a disconnected subset of $\Bbb{R}^2$.