%
\section{Path Independence}
We now introduce a fundamental concept for the line integrals of conservative vector fields: \textit{path independence}. 
We say that a vector field ${\bf F}$ has \textit{path-independent line integrals} on a domain $D\subset\rr^3$ if for any $P_1,P_2\in D$, and for any two piecewise smooth curves $C_1,C_2$ from $P_1$ to $P_2$, we have 
$\int_{C_1}{\bf F}\cdot d\bfr = \int_{C_1}{\bf F}\cdot d\bfr$. 




\begin{proposition}[Path Independence of Line Integrals]\label{24prop-pathindependence}
Suppose that $C$ is a smooth curve parametrized by $\mathbf{r}(t)$ for $t \in  [a,b]$,  and $D \subset \mathbb{R}^n$ is some domain containing $C$. Further suppose that $\mathbf{F} : D \rightarrow \mathbb{R}^n$ is a continuous vector field which satisfies $\mathbf{F} = \nabla \phi$ for some scalar function $\phi : D \rightarrow \mathbb{R}^n$.  

Then,
\begin{equation}\label{24eq-pathindependence}
\int_{C} \mathbf{F} \cdot d \mathbf{r} = \phi \big( \mathbf{r}(b) \big) - \phi \big( \mathbf{r}(a) \big)
\end{equation}
In particular, the line integral of $\mathbf{F}$ over $\mathbf{r}$ depends only upon the value of $\phi$ at the endpoints of the curve (which are $\mathbf{r}(a)$ and $\mathbf{r}(b)$). 
\end{proposition}

\begin{figure}[h]
\begin{minipage}{\linewidth}
\centering
\includegraphics[width = .75\linewidth]{figures/24fig1.png}
\caption{We refer to the conclusion \eqref{24eq-pathindependence} as \textit{path independence}.  This is because, regardless of which curve we take from $\mathbf{r}(a)$ to $\mathbf{r}(b)$, we will arrive at the same value for the line integral.}
\end{minipage}
\end{figure}

\begin{proof}[Proof of Proposition \ref{24prop-pathindependence}]
This conclusion follows from the Chain Rule:
\begin{eqnarray*}
\int_C \mathbf{F} \cdot d \mathbf{r} & = & \int_C \big(\nabla \phi \big) \cdot d \mathbf{r} = \int_a^b \bigg[\phi_x (t) x' (t) + \phi_y (t) y' (t) + \phi_z(t) z' (t) \bigg] dt \\
\quad &=&  \int_a^b \frac{d}{dt} \phi \big( \mathbf{r}(t) \big) dt \\
\quad & = & \phi \big( \mathbf{r}(b) \big) - \phi \big( \mathbf{r}(a) \big)
\end{eqnarray*}
\end{proof}



\begin{remark}
The conclusion of Proposition \ref{24prop-pathindependence} continues to hold  if $C$ is a {piecewise} smooth curve (the union of several smooth arcs joined at their endpoints to form a single curve).  To prove this, apply the proposition to each smooth arc, and sum up what you get!
\end{remark}


In general, there is no equivalent of Proposition \ref{24prop-pathindependence} for non-conservative vector fields, and line integrals may well depend on the shape of the curve rather than just on its endpoints.

\begin{example}\label{24-example1}
Suppose that $\mathbf{F} (x,y) = -y \mathbf{i} + x \mathbf{j}$ and let $C_1$ and $C_2$ be as in Figure 2.18.  Along $C_1$, we are travelling in the opposite direction as $\mathbf{F}$; hence, we have:
$$
\int_{C_1} \mathbf{F} \cdot d \mathbf{r} < 0.
$$
However, along $C_2$, we travel in the same direction as $\mathbf{F}$; hence, we have:
$$
\int_{C_2} \mathbf{F} \cdot d \mathbf{r} > 0.
$$
And yet, $C_1$ and $C_2$ have the same initial and terminal points. This shows that $\mathbf{F}$ does not have the path independence property.

\begin{figure}[h]
\begin{minipage}{\linewidth}
\centering
\includegraphics[width =0.5\linewidth]{figures/24fig3.png}
\caption{The vector field $\mathbf{F}$ (represented by green vectors) along with the two curves $C_1$ (in blue) and $C_2$ (in red). The large arrows represent the direction of travel along the curves $C_1$ and $C_2$.}
\end{minipage}
\end{figure}
\end{example}

The previous example leads us to ask the following foundational question for line integrals of vector fields on $\mathbb{R}^n$.

\begin{question}
Suppose that $\mathbf{F}$ has path-independent line integrals, in the sense that given any two points $P_1,P_2$ in the domain of ${\bf F}$, the integral $\int_{C} \mathbf{F} \cdot d \mathbf{r}$ has the same value for all paths $C$ from $P_1$ to $P_2$. 
Does this necessarily imply that $\mathbf{F}$ is conservative?
\end{question}

As we shall prove below, this is indeed true under reasonable assumptions on the domain.
We assume (for now) that $D \subset \mathbb{R}^n$ is open. We also need our domains to admit enough paths along which we can integrate our vector field.  This is the property below. 

\begin{definition}\label{24def-connected}
We say that $D \subset \mathbb{R}^n$ is \textbf{connected} if every pair of points in $D$ can be joined by a piecewise smooth curve \underline{contained in} $D$.
\end{definition}

It is very easy to think up/draw connected and not connected sets. The following picture gives you an idea of what they should intuitively look like. 



\begin{figure}[h]
\begin{minipage}{\linewidth}
\centering
\includegraphics[width=.7\linewidth]{figures/24fig4.png}
\end{minipage}
\end{figure}

\noindent
\textit{\underline{Caution:} the definition above is a little bit different from the topological concept of connectedness that you may see elsewhere. For example, a fractal curve like Koch's snowflake is connected in the topological sense, but is not connected in the sense of Definition \ref{24def-connected} because fractal curves are not piecewise smooth. For our purposes, the condition that we will use is the one in Definition \ref{24def-connected} and not the topological one.}


We can now give an answer to the question above.

\begin{theorem}\label{24thm-mainresult}
Let $D \subset \mathbb{R}^n$ be an open, connected domain, and let $\mathbf{F}$ be a smooth vector field on $D$. Then, the following statements are equivalent:
\begin{enumerate}[(a)]
\item $\mathbf{F}$ is conservative on $D$;

\medskip

\item $\oint_C \mathbf{F} \cdot d \mathbf{r} = 0$ for all piecewise smooth, closed curves in $D$;

\medskip

\item Given any two points $P_1,P_2 \in D$, the line integral $\int_C \mathbf{F} \cdot d \mathbf{r}$ has the same value for all piecewise smooth curves $C$ from $P_1$ to $P_2$.
\end{enumerate}
\end{theorem}


We use the symbol ``$\oint$'' to denote a line integral along a closed curve (that is, the initial and terminal points are the same).


In the remainder of this section, we prove Theorem \ref{24thm-mainresult}.

\begin{proof}[Proof of Theorem \ref{24thm-mainresult}]
We prove the following implications: (a) $\Rightarrow$ (b), (b) $\Rightarrow$ (c), then (c) $\Rightarrow$ (a).

\medskip

\noindent
\underline{(a) $\Rightarrow$ (b):} This is a special case of Proposition \ref{24prop-pathindependence}: for closed paths, we have $\bfr(a)=\bfr(b)$ so that $\oint_{C} \mathbf{F} \cdot d \mathbf{r} = \phi \big( \mathbf{r}(b) \big) - \phi \big( \mathbf{r}(a) \big)=0$.


\medskip
\noindent
\underline{(b) $\Rightarrow$ (c):} Let $C_1$ and $C_2$ be two curves from connecting $P_1$ to $P_2$, both entirely contained in $D$.  We then form a closed curve, by joining $C_1$ to $C_2$, and reversing the orientation of $C_1$.  This is shown in the two figures below.

\begin{figure}[h]
\begin{minipage}{\linewidth}
\centering
\includegraphics[width=.5\linewidth]{figures/24fig5.png}
\caption{The two curves $C_1$ and $C_2$.}
\end{minipage}
\end{figure}


\begin{figure}[h]
\begin{minipage}{\linewidth}
\centering
\includegraphics[width=.5\linewidth]{figures/24fig6.png}
\caption{The closed curve obtained by reversing the orientation of $C_1$.}
\end{minipage}
\end{figure}


Call this new curve $C$; notice that $C$ is a closed curve.  Recall that we are assuming (b) holds, so that
$$
0=\oint_C \mathbf{F} \cdot d \mathbf{r} = \int_{C_2} \mathbf{F} \cdot d \mathbf{r} - \int_{C_1} \mathbf{F} \cdot d \mathbf{r}.
$$
The minus sign on the second integral comes from reversing the orientation of $C_1$ to form $C$.  This proves (c).

\medskip

\underline{(c) $\Rightarrow$ (a):} We now assume that $\mathbf{F}$ has the path independence property on $D$. Fixing some $P_0 = (x_0,y_0,z_0)$, define a scalar valued function $\phi (x,y,z)$ as
\begin{equation}\label{24eq-constructingphi}
\phi (x,y,z) = \int_{C} \mathbf{F} \cdot d \mathbf{r},
\end{equation}
where $C$ is \underline{any} path connecting $P_0$ to $P =(x,y,z)$.  Notice that the value of $\phi$ does not depend upon the choice of path -- this follows since we assume the path independence property for $\mathbf{F}$.

\smallskip
Our goal is now to show that $\nabla \phi = \mathbf{F}$; in other words, we show that
\begin{equation}\label{24eq-conservancyequations}
\underbrace{\frac{\partial \phi}{\partial x} = F_1}_{(*)}, \, \frac{\partial \phi}{\partial y} = F_2, \, \frac{\partial \phi}{\partial z} = F_3.
\end{equation}
We will only prove $(*)$. The other two identities are proved in a similar fashion, with the $x,y,z$ coordinates interchanged as needed.

\begin{figure}[h]
\begin{minipage}{\linewidth}
\centering
\includegraphics[width =.8\linewidth]{figures/24fig7.png}
\end{minipage}
\end{figure}

Let's say we want to prove $(*)$ at some $P_1=(x_1,y_1,z_1)\in D$. This means that we want to evaluate 
\begin{equation}\label{24-partial}
\frac{\partial \phi}{\partial x}(P_1)=\lim_{x-x_1\to 0}\frac{ \phi(x,y_1,z_1)-\phi(x_1,y_1,z_1)}{x-x_1}.
\end{equation}
Let $P=(x,y_1,z_1)$, where $x$ is close enough to $x_1$ so that $P\in D$. 
(This is possible, because we assumed our domain $D$ was an open set so that it contains a neighbourhood of $P$!). 
Recalling the definition of $\phi$ in \eqref{24eq-constructingphi}, we now choose the paths we will use. We first fix a piecewise smooth path $C_1$ from $P_0$ to $P_1$, so that
$$
\phi(P_1)= \int_{C_1} \mathbf{F} \cdot d \mathbf{r}.
$$
For the variable point $P$ in (\ref{24-partial}), we let $C$ be the union of $C_1$ from $P_0$ to $P_1$ and the line segment $C_2$ from $P_1$ to $P$, so that
$$
\phi(P) : = \int_C \mathbf{F} \cdot d \mathbf{r} = \int_{C_1} \mathbf{F} \cdot d \mathbf{r}+ \int_{C_2} \mathbf{F} \cdot d \mathbf{r}.
$$
This gets us
$$
\phi(P)-\phi(P_1)= \int_{C_2} \mathbf{F} \cdot d \mathbf{r}.
$$
To evaluate the last integral, we parametrize $C_2$ using 
\begin{equation}\label{24eq-paraline}
\mathbf{r}(t) : = \langle x_1 + t, y_1, z_1\rangle,
\end{equation}
so that $\bfr(0)=P_1$, $\bfr(x-x_1)=P$, and $\mathbf{r}' (t) = \langle 1, 0,0 \rangle$.  Using our line integral formula from Section \ref{sec:lineIntegrals}, we see that
$$
\int_{C_2} \mathbf{F} \cdot d \mathbf{r} = \int_{0}^{x - x_1} F_1 (x_1 + t, y_1, z_1) d t.
$$
(Recall: if $a<0$, then $\int_0^a=-\int_a^0$!) Putting everything together, and using the Fundamental Theorem of Calculus, we get
$$
\lim_{x\to x_1}\frac{\phi(P)-\phi(P_1)}{x-x_1}=
 \frac{\partial}{\partial x} \int_{C_2} \mathbf{F} \cdot d \mathbf{r} \Big|_{x=x_1} = F_1 (x_1, y_1, z_1).
$$
Hence $\frac{\partial \phi}{\partial x}(P_1) = F_1(P_1)$, as claimed.

This proves the first identity in \eqref{24eq-conservancyequations}. The proofs of the remaining two identities are similar, but with the $y$ and $z$ variables playing the role of the $x$ variable in the above proof. The path independence assumption is used here in an important way: to prove the second and third identity in \eqref{24eq-conservancyequations}, we need to use paths that end in line segments parallel, respectively, to the $y$-axis and $z$-axis. Path independence guarantees that the integrals on these very different paths give us the same function $\phi$.
\end{proof}



The theorem can be extended in various ways. In many of our applications, $D \subset \mathbb{R}^n$ will be a set of the form $D = S \cup B$, where $S$ is an open set and $B$ is a set of some or all of the boundary points of $S$. The theorem extends to this case: define $\phi$ as above but on all of $D$, prove that $\phi$ is continuous on $D$ and that ${\bf F}=\nabla \phi$ on $S$. 
Additionally, (b)
could be replaced by the (formally weaker but actually equivalent) condition that 
$\oint_C \mathbf{F} \cdot d \mathbf{r} = 0$ for all piecewise smooth, closed, and \underline{simple} curves in $D$.
If the domain is not connected but instead consists of several connected parts, we may apply the theorem on each part separately.















\section*{Worked Problems}
\begin{enumerate}[1.]
\item
{\it Find a function $F_3(x,y,z)$ such that the vector field 
$${\bf F}(x,y,z)= (y\cos z-yz\cos x){\bf i}+(x\cos z - z\sin x) {\bf j} + F_3(x,y,z) {\bf k}
$$
is conservative on $\mathbb{R}^3$.
With that choice of $F_3$, find $\int_C {\bf F}\cdot d{\bf r}$, where $C$ is 
a smooth curve from $(0,1,\pi)$ to $(\pi/2, 4, 0)$.}


\medskip


Suppose ${\bf F}=\nabla f$. Then $f_x=F_1 = y\cos z - yz \cos x$, so that 
$$f(x,y,z)=
xy \cos z - yz \sin x + g(y,z).
$$
 Differentiating this in $y$, we get
$$f_y=x\cos z - z \sin x + g_y .$$
 This matches $F_3$ when $g_y=0$, so we can take $g(y,z)=h(z)$
for any function $h(z)$ independent of $y$. The simplest example is when $g\equiv 0$, in
which case $f(x,y,z)=xy \cos z - yz \sin x$ and 
$$F_3=f_z=-xy\sin z -y \sin x.$$

Finally,
\begin{align*}
\int_C {\bf F}\cdot d{\bf r}&= f(\pi/2, 4, 0)-f(0,1,\pi) 
\\
&= \frac{\pi}{2}\cdot 4\cos 0 - 4 \cdot 0 \cdot \sin\frac{\pi}{2} 
-0 -1\cdot \pi \cdot \sin 0 = 2\pi.
\end{align*}





\end{enumerate}



\section*{Practice Problems}
\begin{enumerate}[1.]

\bigskip

\item {
Let ${\bf F}(x,y,z)=e^{2y}{\bf i}+(axe^{2y}+be^z){\bf j}-3ye^z{\bf k}$.
Find the values of $a,b$ for which ${\bf F}$ is conservative, and the corresponding potential function. For these values of $a$ and $b$, evaluate $\int_\mathcal{C} {\bf F}\cdot d{\bf r}$,
where $\mathcal{C}$ is a piecewise smooth curve from $(1,1,0)$ to $(0,1,3)$.}

\bigskip



\item Find all values of the parameters $a,b,c$ 
such that the vector field 
$${\bf F}(x,y,z)=4xy^3 \,\ii+ (ax^2y^2+b\cos z)\jj+(y\sin z+c \cos z) \kk$$
 is conservative on $\mathbb{R}^3$. For all such $a,b,c$:
 
 \medskip
 
(a) find a potential function $f$ such that ${\bf F}=\nabla f$,

\medskip


(b) evaluate the integral $\int_C {\bf F}\cdot d{\bf r}$, if $C$ is the line segment from $(0,1,0)$ to $(1,1,\pi/2)$.


\bigskip


\item {  
Let ${\bf F}:\rr^2\to\rr^2$ be a $C^1$ vector field. Assume that the following holds: for any $P,Q\in \rr^2$, and for any two curves $C_1,C_2$ from $P$ to $Q$ {\bf that are unions of at most 5 line segments each}, we have 
$\int_{C_1}{\bf F}\cdot d\bfr = \int_{C_2}{\bf F}\cdot d\bfr$. Does it follow that ${\bf F}$ is conservative? Prove your answer.
}

\bigskip



\item { 
(8 marks) 
Let $f$ and $g$ be two $C^1$ functions on $D$. Let ${\bf F}=f\nabla g$ and ${\bf G}=g\nabla f$. Prove that 
${\bf F}$ has path-independent line integrals if and only if so does ${\bf G}$.}


\end{enumerate}

