This procedure, while basic in execution, is nothing short of amazing if visualized. Imagine being given the fasted path of descent for a mountain and being asked to find a level path alongside it. Impossible? Not if you know this handy trick!

Let's assume you are given the gradient in form:

g(x,y)=(4x3y3 - 3x2)i + (3x4y2 + cos 2y)j

We know that the first partial derivatives of our original function f(x,y) are:

df/dx(x,y) = (4x3y3 - 3x2)
df/dy(x,y) = (3x4y2 + cos 2y)

Integrating df/dx in respect to x (leaving y as a constant) we find that:

f(x,y) = x4y3 - x3 + W(y)

Where W(y) is an unknown function of y. The function W plays the same role as the arbitrary constant C that arises when one integrates a function of one variable. Now, differentiation in respect to y gives:

df/dy(x,y) = 3x4y2 + W'(y)

We know have two equivalent statements for df/dy which we can use to solve for W(y).

3x4y2 + W'(y) = 3x4y2 + cos 2y

W'(y) = cos 2y, so W(y) = (1/2)sin y + C

This means that

f(x,y) = x4y3 - x3 + (1/2)sin 2y + C


It should be noted that the above procedure is symmetric in respect to x and y. Therefore, we could have just as well integrated df/dy and differentiated it in respect to x, setting it equal to the original partial derivative in respect to x of the gradient.