How to find an equation for the vector field $\vec{F}=-x\hat{i}+y\hat{j}$? I have represented the vector field $\vec{F}=-x\hat{i}+y\hat{j}$ as follows 

Now, what I need to do is find a function $\phi (x,y)$ such as $\triangledown\phi = \vec{F}$.
How do I must proceed to find such equation? Ideas, suggestions, etc.?
 A: You know that $\phi_x = -x$.  So $\phi = -x^2/2 +g(y)$, where $g(y)$ could be any function of $y$ alone.  So there are two versions of $\phi_y$.  First, differentiate with respect to y the expression for $\phi$ to get $\phi_y = g^{\prime}(y)$.  Second, from $F$ we know $\phi_y = y$, so $g^{\prime}(y) = y$.
Hence $g(y) = y^2/2$ and we have $\phi = -x^2/2 + y^2/2$.
A: Here is a general method to do so. $\nabla \phi = F$ so $\phi_x = -x$. Integrate this equation with respect to $x$ to find $\phi(x,y) = -x^2/2 + g(y)$, some unspecified function $g$ of $y$. Similarly, $\phi_y = y = g'(y)$, and upon integrating with respect to $y$, we find $\phi(x,y) = y^2/2 + h(x)$. However, we know what $h(x)$ has to be from our last step. Hence
$$
\phi(x,y) = -x^2/2 + y^2/2.
$$
A: In two dimensions, alternating integration and differentiation, as in two of the other answers, works very well, but it can get tedious in higher-dimensional spaces. If the vector field is conservative and defined in a star-shaped region centered on the origin, as this one is, you can find an antiderivative with a single integral: $$\phi(\vec r) = \int_0^1\vec F(t\vec r)\cdot\vec r\,dt.$$ The underlying idea is that the function $G$ given by the line integral $G(\vec r)=\int_{\Gamma(\vec r)} \vec F$, where $\Gamma(\vec r)$ is a smooth curve that connects the origin to the point $\vec r$, is an antiderivative of $\vec F$. For convenience, we integrate along line segments parametrized in the obvious way. This method can easily be adapted to other star-shaped regions.  
In your case, we would have $$\phi(x,y)=\int_0^1(-tx\vec i+ty\vec j)\cdot(x\vec i+y\vec j)\,dt = (y^2-x^2)\int_0^1t\,dt = \frac12(y^2-x^2).$$
The solution is not unique, of course, regardless of the method you use to find it, since if $\vec F=\nabla\phi$ for some scalar field $\phi$, then it’s also the case that $\vec F=\nabla(\phi+C)$, where $C$ is any scalar constant.
A: If $\nabla \phi = \vec{F}$, then
$$\phi_x = -x$$
$$\phi_y = y$$

Solution 1: 
From
$$\phi_x = -x$$
we have
$$\phi = \frac{-x^2}{2} + g_1(y)$$
$$\to \phi_y = g_1'(y)$$
$$\to g_1'(y) = y$$
$$\to g_1(y) = \frac{y^2}{2} + C$$
$$\to \phi = \frac{-x^2}{2} + \frac{y^2}{2} + C$$

Solution 2:
From
$$\phi_y = y$$
we have
$$\phi = \frac{y^2}{2} + g_2(x)$$
$$\to \phi_x = g_2'(x)$$
$$\to g_1'(x) = -x$$
$$\to g_1(x) = \frac{-x^2}{2} + C$$
$$\to \phi = \frac{y^2}{2} + \frac{-x^2}{2} +  C$$
