# Given $\nabla f(x,y)$, is it possible to solve for $f(x,y)$ in all cases?

$$\nabla f(x,y) = \begin{bmatrix} 2y \\ 2x+y \end{bmatrix}$$

I can solve for $f(x,y)$ as such by integrating each part of the vector:

$$2yx\ +\ c_1(y) \equiv 2xy\ +\ \frac{1}{2}y^2 + c_2(x) \\ \therefore\ f(x,y)=2xy+\frac{1}{2}y^2+c$$

$$\nabla g(x,y)=\begin{bmatrix} 2\cos(x) \\ 2x \end{bmatrix}$$

I derive $$\int{2\cos(x)dx}=2\sin(x)\ +\ c_1 \\ \int{2xdy}=2xy\ +\ c_2$$

But I find a problem whilst solving in the way that I did the first, given that $c_1$ must be in terms of $y$ and vice versa for $c_2$ and $x$:

$$2\sin(x)\ +\ c_1(y) \equiv 2xy\ +\ c_2(x)$$

Because that gives me $c_1(y)=2xy$, where there shouldn't be an $x$ term.

Does this mean that there's no solution for $g(x,y)$? Am I missing something here? And is there already a method for working out this 'antigrad'?

• Not all vector fields are gradients of a scalar field. Your "$\nabla g$" is one such example. – Rahul May 8 '16 at 18:54

Most vector fields in dimension greater than 1 are not the gradient of any scalar function. The fields that are the gradient of some scalar function are called "conservative". For differentiable vector fields in two or three dimensions, a necessary and usually sufficient condition to be conservative is that the curl is zero. You can use this condition to immediately see that your second vector field cannot be conservative, because its curl is $2 \mathbf{k} \neq \mathbf{0}$. More generally the condition is that $\frac{\partial F_i}{\partial x_j}=\frac{\partial F_j}{\partial x_i}$ for every $i,j$ (where $F$ is the vector field). This corresponds to $\frac{\partial^2 f}{\partial x_j \partial x_i}=\frac{\partial^2 f}{\partial x_i x_j}$ (where $f$ is the scalar field), that is, that mixed partial derivatives can be interchanged.
The Helmholtz decomposition states for twice continously differentiable vector fields $F$: $$\DeclareMathOperator{grad}{grad} \DeclareMathOperator{curl}{curl} F = -\grad \phi + \curl A$$ for some scalar potential $\phi$ and some vector potential $A$.