Finding the potential function for path-independent vector fields

You are given a vector field, say,

F(x,y) = (y cos x + y2, sin x + 2xy - 2y).
You calculate
∂F2-
 ∂x = -∂-
∂x(sin x + 2xy - 2y) = cos x + 2y
∂F1
----
 ∂y =  ∂
---
∂y(y cos x + y2) = cos x + 2y
so that its curl is zero, i.e.,
∂F
--2-
∂x -∂F
--1-
∂y = 0.
F is defined on all of R2, so there are no tricks to worry about. The vector field F is path-independent.

Since F is path-independent, we know there exists some potential function f so that f = F. How do we go about finding f?

Well, f = F means that

( ∂f  ∂f )
  --, ---
  ∂x  ∂y = (F1,F2) = (y cos x + y2, sin x + 2xy - 2y).
So we need to find a function f(x,y) that satisfies the two conditions
∂f-
∂x(x,y) = y cos x + y2 (1)
and
∂f
---
∂y(x,y) = sin x + 2xy - 2y. (2)
Let’s take these conditions one by one and see if we can find an f(x,y) that satisfies both of them. (We know this is possible since F is path-independent. If F were path-dependent, the procedure that follows would hit a snag somewhere.)

Let’s start with condition (1). We can take the equation

∂f
---
∂x(x,y) = y cos x + y2,
and treat y as though it were a number. In other words, we pretend that the equation is
df-
dx(x) = a cos x + a2
for some number a. We can integrate the equation with respect to x and obtain that
f(x) = a sin x + a2x + C.
But, then we have to remember that a really was the variable y so that
f(x,y) = y sin x + y2x + C.
But actually, that’s not right yet either. Since we were viewing y as a constant, really C could be a function of y and it wouldn’t make a difference. We can replace C with any function of y, say g(y), and condition (1) will be satisfied
f(x,y) = y sin x + y2x + g(y). (3)
If you are still skeptical, try taking the partial derivative with respect to x of f(x,y) defined by equation (3). Since g(y) does not depend on x, we can conclude that -∂-
∂xg(y) = 0. Indeed, condition (1) is satisfied for the f(x,y) of equation (3).

Now, we need to satisfy condition (2). We can take the f(x,y) of equation (3) (so we know that condition (1) will be satisfied) and take its partial derivative with respect to y, obtaining

∂f-
∂y(x,y) = ∂--
∂y(                   )
 ysinx +  y2x + g(y) = sin x + 2yx + dg-
dy(y).
Comparing this to condition (2), we are in luck. We can easily make this f(x,y) satisfy condition (2) as long as
dg-
dy(y) = -2y.
(If the vector field F had been path-dependent, we would have found it impossible to satisfy both condition (1) and condition (2), and would have run into trouble at this point.)

If we let

g(y) = -y2 + k
for some constant k, then
∂f
---
∂y(x,y) = sin x + 2yx - 2y,
and we have satisfied both conditions.

Combining this definition of g(y) with equation (3), we conclude that the function

f(x,y) = y sin x + y2x - y2 + k
is a potential function for F. You can verify that indeed
f = (y cos x + y2, sin x + 2xy - 2y) = F(x,y).

With this in hand, calculating the integral

CF ds
is simple, no matter what path C is. The integral is simply f(q) - f(p), where p is the beginning point and q is the ending point of C. (For this reason, if C is a closed curve, the integral is zero.)

We might like to give a problem such as find

CF ds
where C is the curve given by the following graph.

PIC

The answer is simply

CF ds = f(π∕2,-1) - f(-π, 2)
= - sin π∕2 + π-
2 - 1 + k - (2 sin(-π) - 4π - 4 + k)
= - sin π∕2 + 9π
---
2 + 3 = 9 π
---
 2 + 2
(The constant k is always guaranteed to cancel, so you could just set k = 0.)

If the curve C is complicated, it’s a good hint that F is probably path-independent. It’s always a good idea to check if F is path-independent before computing its line integral

CF ds
You might save yourself a lot of work.