# Conservative vector fields

Especially important for physics, conservative vector fields are ones in which integrating along two paths connecting the same two points are equal.

## What we're building to

At the end of this article, you will see how this paradoxical Escher drawing cuts to the heart of conservative vector fields.
• A vector field F, left parenthesis, x, comma, y, right parenthesis is called a conservative vector field if it satisfies any one of the following three properties (all of which are defined within the article):
• Line integrals of F are path independent.
• Line integrals of F over closed loops are always 0.
• F is the gradient of some scalar-valued function, i.e. F, equals, del, g for some function g.
• There is also another property equivalent to all these: F is irrotational, meaning its curl is zero everywhere (with a slight caveat). However, I'll discuss that in a separate article which defines curl in terms of line integrals.
• The key takeaway here is not just the definition of a conservative vector field, but the surprising fact that the seemingly different conditions listed above are equivalent to each other. Madness!

## Path independence

Imagine you have any ol' off-the-shelf vector field F, left parenthesis, x, comma, y, right parenthesis, and you consider the line integrals of F of two separate paths, C, start subscript, 1, end subscript and C, start subscript, 2, end subscript, each starting at a point A and ending at a point B
For almost all vector fields F, and almost all choices for the two paths C, start subscript, 1, end subscript and C, start subscript, 2, end subscript, these integrals will be different.
\begin{aligned} \int_{C_1} \textbf{F} \cdot d\textbf{s} \ne \int_{C_2} \textbf{F} \cdot d\textbf{s} \quad \leftarrow \text{Almost always true} \end{aligned}
And this makes sense! Each integral is adding up completely different values at completely different points in space. What's surprising is that there exist some vector fields where distinct paths connecting the same two points will always be equal, no matter the choice of paths (of which there are super-infinitely many).
In the last article, covering the gradient theorem we saw that in the special case of vector fields which are the gradient of some scalar-valued function, del, f, this magical property is true. The line integrals along distinct paths connecting the same two points A and B will always evaluate to the same thing:
Definition: This property is called path independence. Specifically, a line integral through a vector field F, left parenthesis, x, comma, y, right parenthesis is said to be path independent if the value of the integral only depends on the point where the path starts and the point where it ends, not the specific choice of path in between.
Actually, when you properly understand the gradient theorem, this statement isn't totally magical. This is because line integrals against the gradient of f measure the change in the value of f. Visualizing this with the graph of f, this says that any two paths bringing you from one point to another change your altitude by the same amount.
The takeaway from this result is that gradient fields are very special vector fields. Because this property of path independence is so rare, in a sense, "most" vector fields cannot be gradient fields.

## Path independence implies gradient field

Okay, so gradient fields are special due to this path independence property. But can you come up with a vector field F, left parenthesis, x, comma, y, right parenthesis in which all line integrals are path independent, but which is not the gradient of some scalar-valued function?
I guess I've spoiled the answer with the section title and the introduction: All vector fields in which line integrals are path independent must be the gradient of some function. By why?
Really, why would this be true? Consider an arbitrary vector field F, left parenthesis, x, comma, y, right parenthesis in which line integrals are path independent, meaning
\begin{aligned} \int_{C_1} \textbf{F} \cdot d\textbf{s} = \int_{C_2} \textbf{F} \cdot d\textbf{s} \end{aligned}
for all paths C, start subscript, 1, end subscript and C, start subscript, 2, end subscript which connect the same two points A and B. What is it about this property that ensures the existence of some function g such that del, g, equals, F?
Challenge question: Can you think of a way to construct such a function g in terms of F using the fact that F is path-independent?
This is a tricky question, but it might help to look back at the gradient theorem for inspiration.
I could just spit out the answer here, but it's more fun and enlightening to walk through how you might discover the answer yourself.

### Getting inspiration from the gradient theorem.

The gradient theorem relates the value of a function to the line integral of its gradient:
\begin{aligned} \int_{C} \nabla f \cdot d\textbf{s} = f(B) - f(A) \end{aligned}
where A and B are points in space, and C is some curve connecting them.
Suppose it just so happened to be the case that f, left parenthesis, A, right parenthesis, equals, 0, then this equation would look like
\begin{aligned} f(B) = \int_{C} \nabla f \cdot d\textbf{s} \end{aligned}
In other words, for any point B in space, you could compute f using just its gradient (along with a line integral).
Since our goal is to see how the vector field F can be seen as a gradient, this might spark the idea in your mind to replace del, f with F, producing a new scalar value function, which we'll call g:
\begin{aligned} g(B) = \int_{C} \textbf{F} \cdot d\textbf{s} \end{aligned}
Usually, we define functions using formulas with respect to the coordinates left parenthesis, x, comma, y, right parenthesis of a point, so this might feel like a wacky definition for g. To start, A is just some arbitrarily chosen point in space. Then the value of g at a point B is defined by taking an arbitrary curve connecting A to B, and evaluating the line integral of F along this curve. This is a very indirect definition, but it is a valid definition nevertheless. After all, it gives you a way to compute g, left parenthesis, x, comma, y, right parenthesis for any point left parenthesis, x, comma, y, right parenthesis, doesn't it?
Notice, this definition would not make sense for most vector fields F. The choice of which path connects A to B would change the value of the integral, leaving the defining value of g, left parenthesis, B, right parenthesis ambiguous. However, because line integrals are path independent in F, this is a real definition.
Defining g in this way, it turns out that
del, g, equals, F
This should not be too surprising, if you think about what the gradient theorem looks like for g. I will not cover the proper proof of this fact here, since I think the details​ would distract from the main point:
Key takeaway: If line integrals are path independent in a vector field F, you can use those line integrals to define a function g such that del, g, equals, F.

## Closed loops

Definition: A path is called closed if it starts and ends at the same point. Such paths are also commonly called closed loops.
For example, the path C pictured below starts and ends at A.
If we take a vector field F where all line integrals are path independent, the line integral of F on any closed loop will be 0. Why?
Let C be a closed path, starting at A and ending at A, and let $\tilde C$ be the reverse path. That is, C and $\tilde C$ cover the same points in space, but when you parameterize them you should be walking in opposite directions.
We know that reversing the orientation of a path flips the sign of the line integral:
\begin{aligned} \int_{C} \textbf{F} \cdot d\textbf{s} = -\int_{\tilde C} \textbf{F} \cdot d\textbf{s} \end{aligned}
This is a general statement about line integrals through a vector field, not specific to conservative vector fields. However, because F is path independent, and because both C and $\tilde C$ start at A and end at A, it must also be true that
\begin{aligned} \int_{C} \textbf{F} \cdot d\textbf{s} = \int_{\tilde C} \textbf{F} \cdot d\textbf{s} \end{aligned}
The only way both of these can be true is if the integral equals 0. You can apply this argument to any closed loop, so the line integral over any closed loop must be 0.
Take any closed path C, which starts and ends at the point A. Look at what the gradient theorem says about such a path for some scalar-valued function f:
\begin{aligned} \int_{C} \nabla f \cdot d\textbf{s} = f(A) - f(A) = 0 \end{aligned}
Therefore, integrals over closed loops in a gradient field must always be zero. Since we just saw that vector fields in which line integrals are path independent must also be gradient fields, this answers the question.
The converse of this fact is also true: If the line integrals of F on all closed loops evaluate to 0, then all line integrals must be path independent. Why?
Consider a two separate paths C, start subscript, 1, end subscript and C, start subscript, 2, end subscript, each going from point A to point B.
Now define a closed loop C, start subscript, 3, end subscript to be a certain combination of these two paths, where you walk from A to B along C, start subscript, 1, end subscript, then from B to A backwards along C, start subscript, 2, end subscript.
The line integral of F along this combined path will be
\begin{aligned} \int_{C_3} \textbf{F} \cdot d\textbf{s} = \int_{C_1} \textbf{F} \cdot d\textbf{s} - \int_{C_2} \textbf{F} \cdot d\textbf{s} \end{aligned}
The minus sign is because we are going backwards along C, start subscript, 2, end subscript. On the other hand, we are assuming that the line integral on all closed loops is 0, and C, start subscript, 3, end subscript is a closed loop, so
\begin{aligned} \int_{C_3} \textbf{F} \cdot d\textbf{s} = 0 \end{aligned}
Together, these equations imply
\begin{aligned} \int_{C_1} \textbf{F} \cdot d\textbf{s} &- \int_{C_2} \textbf{F} \cdot d\textbf{s} = 0 \\ &\Downarrow \\ \int_{C_1} \textbf{F} \cdot d\textbf{s} &= \int_{C_2} \textbf{F} \cdot d\textbf{s} \end{aligned}
Since C, start subscript, 1, end subscript and C, start subscript, 2, end subscript were arbitrarily chosen, this shows that all line integrals in F must be path independent.

### Funky notation for closed-loop integrals.

You will sometimes see a line integral over a closed loop C written as
\begin{aligned} \oint_C \textbf{F} \cdot d\textbf{r} \end{aligned}
Don't worry, this is not a new operation that needs to be learned. It is just a line integral, computed in just the same way as we have done before, but it is meant to emphasize to the reader that C is a closed loop.

## Potential energy

In the article introducing​ line integrals through a vector field, I mentioned briefly how in physics, the work done by a force on an object in motion is computed by taking a line integral of the force's vector field along the path of motion.
\begin{aligned} W = \int_C \textbf{F} \cdot d\textbf{s} \end{aligned}
A force is called conservative if the work it does on an object moving from any point A to another point B is always the same, no matter what path is taken. In other words, if this integral is always path-independent. Fundamental forces like gravity and the electric force are conservative, and the quintessential example of a non-conservative force is friction.
This has an interesting consequence based on our discussion above: If a force is conservative, it must be the gradient of some function.
F, equals, del, U
Moreover, according to the gradient theorem, the work done on an object by this force as it moves from point A to point B can be computed just by evaluating this function U at each point:
\begin{aligned} W &= \int_C \textbf{F} \cdot d\textbf{s} \\\\ &= \int_C \nabla U \cdot d\textbf{s} \\\\ &= U(B) - U(A) \end{aligned}
As the physics students among you have likely guessed, this function U is potential energy. For example, if you take the gradient of gravitational potential or electric potential, you will get the gravitational force or electric force respectively. This is why computing the work done by a conservative force can be simplified to comparing potential energies.
It also means you could never have a "potential friction energy" since friction force is non-conservative.

## Escher

Moving from physics to art, this classic drawing "Ascending and Descending" by M.S. Escher shows what the world would look like if gravity were a non-conservative force.
Closed loop perspective:
• Imagine walking clockwise on this staircase. With each step gravity would be doing negative work on you. So integrating the work along your full circular loop, the total work gravity does on you would be quite negative. However, that's an integral in a closed loop, so the fact that it's nonzero must mean the force acting on you cannot be conservative.
Path independence perspective
• Imagine walking from the tower on the right corner to the left corner. If you get there along the clockwise path, gravity does negative work on you. If you get there along the counterclockwise path, gravity does positive work on you. Since both paths start and end at the same point, path independence fails, so the gravity force field cannot be conservative.