If the gradient of a function $f(x, y)$ is $\nabla f = (2xy - y)\hat{\bf i} + (x^2 - x)\hat{\bf j}$, what is $f(x, y)$? I have this gradient and I am suppose to find the original function it belongs to..Before this I always did it the other way; given a function find the gradient. Now working back is tougher for me because it probably involves some integration...

I know that $\dfrac{df}{dx} = 2xy-y$ and $\dfrac{df}{dy} = x^2-x$.
Now I am lost because I know I should integrate each equation with respect to the variable I differentiated it to but then what? I will have 2 integrated equations. 
 A: Instead of integrating both equations, the trick is to integrate one and then differentiate it (with respect to the other variable).
Suppose $\dfrac{\partial f}{\partial x}(x, y) = a(x, y)$ and $\dfrac{\partial f}{\partial y}(x, y) = b(x, y)$. Integrating the first equation with respect to $x$ we obtain $f(x, y) = A(x, y)$. Differentiating this equation with respect to $y$, we have $\dfrac{\partial f}{\partial y}(x, y) = \dfrac{\partial A}{\partial y}(x, y)$. The second equation from the beginning also involved $\dfrac{\partial f}{\partial y}$. Comparing the two equations for $\dfrac{\partial f}{\partial y}$ we find that $\dfrac{\partial A}{\partial y}(x, y) = b(x, y)$.
Using the above method you will be able to find $f(x, y)$ (up to a constant). Note this method works in any dimension.
A: If you integrate both parts independently you get
$f(x,y) = \int \frac{df(x,y)}{dx} dx = \int (2xy-y) dx  = yx^2 - yx + c_1(y) $
and 
$f(x,y) = \int \frac{df(x,y)}{dy} dy  = \int (x^2-x) dy  = yx^2 - yx + c_2(x) $
where $c_1,c_2$ terms may only contain $y$ or $x$, respectively. And they must be equal (because the right hand side of the upper and the lower equation must be the same, your solution). Therefore $c_1=c_2$ must be a constant.
$c_1(y) = c_2(x) = K$
