I know that:
$F=\nabla f = \frac{\partial f}{\partial x}\hat{i}+\frac{\partial f}{\partial y}\hat{j}+\frac{\partial f}{\partial z}\hat{k}$
So in cases like:
$F=2x\hat{i}+2y\hat{j}$
I just integrate each term to get:
$f=x^2+y^2$
But when I do the same process for this:
$F=-y\hat{i}+x\hat{j}$
I get:
$f=-xy+xy = 0$
Which seems wrong.
I know that $F=-y\hat{i}+x\hat{j}$ is the vector field of a counter clockwise rotating vortex but I just can't seem to get its scalar field.
If $\hat F=-y\,\hat\imath+x\,\hat\jmath$ is a gradient field, then the corresponding scalar function $f$ satisfies
$$\frac{\partial f}{\partial x} = -y \\ \frac{\partial f}{\partial y}=x$$
Integrating both sides of the first equation with respect to $x$ gives
$$f(x,y) = -xy + g(y)$$
and differentiating this with respect to $y$ gives
$$\frac{\partial f}{\partial y} = -x +\frac{dg}{dy} = x$$
We assumed $g$ is independent of $x$, so its derivative should also be independent of $x$. Yet here $\frac{dg}{dy}=2x$ so no such scalar $g$ exists. $\hat F$ is not a gradient field.
In contrast to the first example, if $\hat F=2x\,\hat\imath+2y\,\hat\jmath$, the same procedure yields
$$\frac{\partial f}{\partial x} = 2x \implies f(x,y)=x^2+g(y) \implies \frac{\partial f}{\partial y}=\frac{dg}{dy}=2y \implies g(y)=y^2+C \\ \implies f(x,y)=x^2+y^2+C$$