Converse of interchanging order for derivatives We know that for a twice-differentiable function $f$, $$\dfrac{\partial}{\partial x}\dfrac{\partial}{\partial y}f(x,y)=\dfrac{\partial}{\partial y}\dfrac{\partial}{\partial x}f(x,y).$$
Suppose there are functions $g,h:\mathbb{R}^2\rightarrow\mathbb{R}$ such that $$\dfrac{\partial}{\partial y}g(x,y)=\dfrac{\partial}{\partial x}h(x,y)$$ for all $x,y\in\mathbb{R}$. Is it necessary that there exists a function $f:\mathbb{R}^2\rightarrow\mathbb{R}$ such that $$\dfrac{\partial}{\partial x}f(x,y)=g(x,y)$$ and $$\dfrac{\partial}{\partial y}f(x,y)=h(x,y)$$ for all $x,y\in\mathbb{R}$?
 A: Let $f(x,y) = \int_0^x g(\xi,0) d\xi + \int_0^y h(x,\eta) d\eta$.  Then 
$$ \frac\partial{\partial x} f(x,y) = g(x,0) + \int_0^y \frac\partial{\partial x} h(x,\eta) \, dy \\
= g(x,0) + \int_0^y \frac\partial{\partial y} g(x,\eta) \, dy \\
= g(x,0) + g(x,y) - g(x,0) = g(x,y) .$$
Also
$$ \frac\partial{\partial y} f(x,y) = h(x,y) .$$
A: This is related to Poincare lemma, which states if $X$ is a contractible open subset of $\mathbb R^n$, any smooth closed $p$-form $α$ defined on $X$ is exact.
Define a one-form $\omega=gdx+hdy$ on $X$, obviously $\omega$ is closed since
$$d\omega=\left(\frac{\partial h}{\partial x}-\frac{\partial g}{\partial y}\right)dx\wedge dy=0$$
Poincare lemma states $\omega$ is exact, or there exists a 0-form (smooth) function $f$ such that
$$df=\omega=gdx+hdy$$
which is equivalent to
$$\frac{\partial f}{\partial x}=g,~\frac{\partial f}{\partial y}=h$$
A: Consider $g(x,y) = \frac\partial{\partial x} \tan^{-1}(y/x) = -\frac{y}{x^2+y^2}$ and $h(x,y) = \frac\partial{\partial y} \tan^{-1}(y/x) = \frac{x}{x^2+y^2}$.  This is defined on $\mathbb R^2 \setminus \{(0,0)\}$.  Now suppose that there exists a function $f(x,y)$ satisfying the properties you asked for.  (We cannot use $\tan^{-1}(y/x)$ because that is only defined up to a multiple of $\pi$.)
Now consider $\int g(x,y) dx + h(x,y) dy$ along any curve.  This is the work done by the force field generated by the potential $f(x,y)$, that is, it will evaluate to $f(x_1,y_1) - f(x_0,y_0)$ where $(x_0,y_0)$ and $(x_1,y_1)$ are the beginning and the end of the curve.
So in particular, if we compute $\oint g(x,y) dx + h(x,y) dy$ around a circle of radius $1$ counterclockwise around the origin, then using polar coordinates you will find that it is $2\pi$.  This contradicts the previous paragraph which says it should be zero.
Hence your conjecture is not true on $\mathbb R^2 \setminus \{(0,0)\}$.
