If $\frac{\partial \varphi}{\partial x}=f(x,y),\frac{\partial\varphi}{\partial y}=g(x,y)$, what is $\varphi$? Suppose we have a real-valued function $\varphi(x,y)$ such that
$$
\frac{\partial \varphi}{\partial x}=f(x,y)\quad\text{and}\quad\frac{\partial\varphi}{\partial y}=g(x,y)
$$
for some functions $f$ and $g$. How can we recover the function $\varphi$? 
Using the chain rule, we have
$$
d\varphi=\frac{\partial\varphi}{\partial x}dx+\frac{\partial\varphi}{\partial y}dy=f(x,y)dx+g(x,y)dy
$$
So maybe $\varphi$ can be found by
$$\varphi(x,y)=\int f(x,y)dx+g(x,y)dy$$
but I am not sure what this integral means. It seems like a line integral, but over what curve? What is an indefinite line integral?
 A: *

*Let $(x,y) \in \text{dom}(\varphi)$ and integrate $f$ with respect to $x$. Get: $\displaystyle \varphi(x,y)=\int f(x,y)\,dx+\psi(y)$, for some differentiable function $\psi\colon I\to\Bbb R$, where $I\subseteq\Bbb R$ is an interval.

*Differentiate the equality you got above, with respect to $y$, to get both these equalities: $$g(x,y)=\frac{\partial \varphi}{\partial y}(x,y)=\frac{\partial }{\partial y}\left(\int f(x,y)\,dx\right)+\psi'(y)$$

*Now using the equality $\displaystyle g(x,y)=\frac{\partial }{\partial y}\left(\int f(x,y)\,dx\right)+\psi'(y)$ should get you somewhere.


Example: Let $\varphi :\Bbb R^2\to \Bbb R$ be such that for all $(x,y)\in \Bbb R^2$ the following equalities hold:
$$\frac{\partial \varphi}{\partial x}(x,y)=\underbrace{e^x\sin (y)}_{\displaystyle f(x,y)} \wedge \frac{\partial \varphi}{\partial y}(x,y)=\underbrace{e^x\cos (y)}_{\displaystyle g(x,y)}$$
Integrating $f$ with respect to $x$ we get $\displaystyle \varphi (x,y)=\int e^x\sin (y)dx=e^x\sin (y)+\psi (y)$, for some differentiable function $\psi\colon \Bbb R\to \Bbb R$.
Differentiating with respect to $y$ it follows that $e^x\cos (y)+\psi'(y)=g(x,y)=e^x\cos (y)$.
Therefore $\psi'$ is always $0$ and it follows that there exists $C\in \Bbb R$ such that for all $u \in \Bbb R$ we have $\psi (u)=C$, that is, $\psi$ is constant.
This gives you $\varphi (x,y)=e^x\sin (y)+C\in \Bbb R$, for some $C\in \Bbb R$.
Taking $C\in \Bbb R$ arbitrarily will give you a possible $\varphi$.
A: Under some conditions we can do this without a line integral. Let's assume that $\varphi$ is once continuously differentiable, so $f$ and $g$ are continuous as functions of $(x,y)$. Indefinite integration of $f(x,y)$ in $x$ gives $$\int f(x,y)dx = F(x,y)+\eta(y),$$ where $$\frac{\partial}{\partial x}F(x,y) = f(x,y).$$ Such $F$ exists by continuity of $f$ as a function of $(x,y)$. $\eta(y)$ is like the constant you get out in single-variable indefinite integration, but in multiple variables you need to account for the $y$. Differentiating $F+\eta$ in $x$ will yield $f(x,y)$ since $\eta$ is independent of $x$, so $\eta_x=0$. By a similar argument we conclude that $$\int g(x,y)dy = G(x,y)+\mu(x),$$ where $$\frac{\partial}{\partial y}G(x,y)=g(x,y).$$
$\varphi$ is an antiderivative of $f$ in the variable $x$, so it is equal to $F(x,y)+\eta(y)$ for some function $\eta$ in $y$. Similarly it is equal to $G(x,y)+\mu(x)$ for some function $\mu$ in $x$. Under some circumstances this is enough to describe $\varphi$. For example:
Suppose $\frac{\partial \varphi}{\partial x} = 2xy$, $\frac{\partial \varphi}{\partial y}=x^2$. Then $\varphi(x,y) = x^2y+\eta(y)$ for some function $\eta$ in $y$, and $\varphi(x,y)=x^2y+\mu(x)$ for some function $\mu$ in $x$. Subtracting these two equations, we find that $\eta(y)-\mu(x)=0$, and since these two functions are independent of each other this must mean $\eta$ and $\mu$ are constant and equal to one another. Therefore we conclude that $\varphi(x,y)=x^2y+C$ for some constant $C$. (This is a very simple example; this sort of problem is usually much harder.)
In general the nature of the $\mu$ and $\eta$ (and therefore $C$, if such a constant is involved) is determined by the value of $\varphi$ at particular points, much like an initial value problem. The procedure I outlined here generalizes to more than two variables - for instance, indefinitely integrating a sufficiently smooth $h(x,y,z)$ in $x$ gives us $$\int h(x,y,z) dx = H(x,y,z)+\xi(x,y),$$ i.e. an "antiderivative" and a "constant," i.e. an independent function.
Moral: indefinite integration of a real-valued function of several variables is just like single variables, but the "constants of integration" are "functions of integration" instead.
A: By knowing the partial derivatives, you know the gradient of this scalar field:
$$\nabla \varphi = f e_x + g e_y$$
You can then invert the gradient operator using the 2d Green's function.  Let $r = x e_x + y e_y$, and the Green's function is
$$G(r) = \frac{1}{2\pi |r|^2} r, \quad \nabla \cdot G(r) = \delta(r)$$
This integral then allows you to invert the gradient:
$$\begin{align*}\int_{\partial S} \varphi(r') \, [d\ell' \times G(r-r')] &= -\int_S e_z |dA'| \,[ \nabla'\varphi(r') \cdot  G(r-r') - \varphi(r') \nabla' \cdot G(r-r') ]\\
 &= -\int_S e_z |dA'| \,[ \nabla'\varphi(r') \cdot  G(r-r') - \varphi(r') \delta(r-r') ]\\
&= e_z \varphi(r) + \int_S e_z |dA'| \nabla' \varphi(r') \cdot G(r-r') \end{align*}$$
Or, more explicitly, we have
$$\varphi(r) = \int_{\partial S} \varphi(r') |d\ell' \times G(r-r')| - \int_S |dA'| \nabla' \varphi(r') \cdot G(r-r')$$
where the region $S$ and its boundary $\partial S$ need only contain the point $r$ and some neighborhood around it.  The choice is arbitrary.
You might notice the similarity to complex analysis.  In particular, if $\nabla \varphi = 0$, then $\varphi$ at a given point is entirely determined by its values on some curve that encloses the point.  You should also note that, without a proper boundary condition--that is, some curve around which you know the values of $\varphi$ already--the solution cannot be found. There will be many such functions with those derivatives in a region of interest if the boundary conditions are not given.
