© 2022 Horia Metiu

WorkBookT.8. Line integrals and their dependence on the path

Remove["Global`*"]; 
Needs["Utilities`CleanSlate`"];
CleanSlate[];

WorkBookT.8.1  An integral that depends on path.

Cell 1.  Define the question and the method to answer it.

• I will study integrals of the form
	(∫_(Subscript[σ, i])^(Subscript[σ, f]))(X(x,y)dx + Y(x,y)dy) 	 				(1)
where (Subscript[σ, i]) denotes { (Subscript[x, i]) , (Subscript[y, i]) } and (Subscript[σ, f]) denotes {(Subscript[x, f]), (Subscript[y, f])}.  
• The integral is defined  only if I specify a path
	y = f(x)								  	  (2)
• Once a path is given the integral becomes  
	(∫_(Subscript[x, i])^(Subscript[x, f]))  (X(x, f(x)) + Y(x, f(x)) ((df(x))/dx))  dx		   (3)		
This is now an ordinary integral with respect to x which I can evaluate if I know y = f[x].  
• I will describe in words an integral like this by saying that it is a line integral along the path 
	y = f(x), 
from the initial point 
	{(Subscript[x, i]), (Subscript[y, i]) = f((Subscript[x, i]))}
to the final point
	{(Subscript[x, f]), (Subscript[y, f])=f((Subscript[x, f]))}
• I want to know whether such an integral depends on the path.

Cell 2:  Two paths that start and end at the same points

• To work out an example I pick two paths:
	(Subscript[f, 1])(x)=5 x/3
and
	(Subscript[f, 2])(x)=5 (x^3)/27
• The paths were chosen so that 
	(Subscript[f, 1])(0) = (Subscript[f, 2])(0)
and 
	(Subscript[f, 1])(3) = (Subscript[f, 2])(3)
• This means that both paths start at x = 0 and end at x =3.  I do that so that the two line integral differ only through the path,  not through the end points.

Define the functions f1[x] and f2[x] that give the two paths:

Clear[f1,f2];
f1[x_]:=5  x/3  
f2[x_]:=  5 x^3/27

Test that they are equal at x = 0 and at x = 3

{f1[3]==f2[3],f1[0]==f2[0]}

Plot the paths

Plot[{f1[x],f2[x]},{x,0,3},
AxesLabel->{"x","(Subscript[f, 1]) and (Subscript[f, 2])"}, PlotLegends->{"5 x/3","5 (x^3)/27"},ImageSize->"Small"]

Cell 3:  Perform the integrals on the two paths

I will study a particular integral 
	(∫_(Subscript[σ, i])^(Subscript[σ, f]))x cos(y)dx + x y dy   						(1)
where (Subscript[σ, i]) denotes { (Subscript[x, i]) , (Subscript[y, i]) } and (Subscript[σ, f]) denotes {(Subscript[x, f]), (Subscript[y, f])}. I want to check whether I get different results when I integrate on different paths.

On the path 1, which is  y = 5 x/3,  the integral 
	(∫_(Subscript[σ, i])^(Subscript[σ, f]))x cos(y)dx + x y dy   	
becomes
	I1 =(∫_(x=0)^(x=3)) (x  cos(5 x/3) dx+ x 5 x/3  ((d(5 x/3))/dx)dx

On path 2, which is y = 5 (x^3)/27, the integral 
	(∫_(Subscript[σ, i])^(Subscript[σ, f]))x cos(y)dx + x y dy   	
becomes
	I2 = (∫_(x=0)^(x=3)) (x  cos(5 (x^3)/27) dx + x (5 (x^3)/27)  ((d(5 (x^3)/27))/dx)dx

Calculate the integral on path 1.   
	I1 =(∫_(x=0)^(x=3)) (x  cos(5 x/3) dx+ x 5 x/3  ((d(5 x/3))/dx)dx

I1=Integrate[x Cos[f1[x]]+x f1[x] D[f1[x],x],{x,0,3.}]//Chop

Calculate the integral on path 2:
	I2 = (∫_(x=0)^(x=3)) (x  cos(5 (x^3)/27) dx + x (5 (x^3)/27)  ((d(5 (x^3)/27))/dx)dx

I2=Integrate[x Cos[f2[x]]+x f2[x] D[f2[x],x],{x,0,3.},GenerateConditions->False]//Chop

Obviously the two integrals are different

{I1,I2}

The same integral gives different values when performed on different paths that have the same initial and the final points. This may seem obvious to you.  However, what follows may surprise you: there are integrands for which the integral is independent of path.

WorkBookT. 8.2 . A line integral that is path-independent.

Cell 1. Explanation

As an example, I will calculate the line integral 
	(∫_( i)^( f)) X(x,y)dx  + Y(x,y) dy						(1)
with
	X(x,y) = ((y^2)/(2(Sqrt[x y])))+ (x^2) y cos(x y) + 2 x sin (x y)		(2)
and 
	Y(x,y) = ((x  y)/(2(Sqrt[x y])))+(Sqrt[x y ]) + (x^3)cos(x y)				(3)

• I will calculate the integral along two paths given by 
	y = f1[x] = x
	y = f2[x] = ((x^3)/9)
• These paths were designed so that 
	f1[0] = f2[0]
and 
	f1[3] = f2[3]
• x = 0 and x = 3 are the end points for both paths.

I will show that the integrals along these paths are equal;  the integrals are path independent.  This is not a property of these particular paths;  the integral is the same, no matter what the path is, as long as it joins the same end points. If the paths start at the same point and end at the same point then the integral does not depend on path.

The integral along path 1 is
	(Subscript[I, 1])= (∫_0^3)X(x,(Subscript[f, 1])(x))dx  + Y(x,(Subscript[f, 1])(x))((d (Subscript[f, 1])(x))/dx) dx 		(6)
and the integral along path 2 is 
	(Subscript[I, 2]) =(∫_0^3)X(x,(Subscript[f, 2])(x))dx  + Y(x,(Subscript[f, 2])(x))((d (Subscript[f, 2])(x))/dx) dx 		(7)

Cell 2:  Create functions that give the two paths.

Clear[f1]
	f1[x_]:= x
Clear[f2]
	f2[x_]:= (x^3)/9

Plot the two paths:

Plot[{f1[x], f2[x]},{x,0,3},AxesLabel->{"x","f1[x] and f2[x]"},PlotLegends->{"x","(x^3)/9"},ImageSize->Small]

Cell 3:  Define the functions  X(x, y) and Y(x, y):

Define
	X(x,y) = ((y^2)/(2(Sqrt[x y])))+ (x^2) y cos(x y) + 2 x sin (x y)		(2)

X[x_,y_]:=y^2/(2 Sqrt[x y]) +x^2 y Cos[x y] +2 x Sin[x y]

Define
	Y(x,y) = ((x y)/(2(Sqrt[x y])))+(Sqrt[x y ]) + (x^3)cos(x y)

Y[x_,y_]:= x y/(2 Sqrt[x y]) +Sqrt[x y] +x^3 Cos[x y]

Cell 4:  Perform the integrals:

Calculate  the integral along path 1:
	(Subscript[I, 1])= (∫_0^3)X(x,(Subscript[f, 1])(x))dx  + Y(x,(Subscript[f, 1])(x))((d (Subscript[f, 1])(x))/dx) dx  , 
which is Eq.(6):

I1= Integrate[X[x,f1[x]] + Y[x,f1[x]] D[f1[x],x],{x,0,3}]//N

Calculate the integral along path 2:
	(Subscript[I, 2]) =(∫_0^3)X(x,(Subscript[f, 2])(x))dx  + Y(x,(Subscript[f, 2])(x))((d (Subscript[f, 2])(x))/dx) dx , 
which is Eq. 7:

I2= Integrate[X[x,f2[x]] + Y[x,f2[x]] D[f2[x],x],{x,0,3}]//N

Compare the two integrals:

{I1,I2}

The two integrals are equal, as advertised.

WorkBookT. 8.3.  How did I know that the integrals will be path independent?

Cell 1: Review

Let’s review what we have learned in WorkBookT.8.3. 
If X(x,y) and Y(x,y) are given by

X(x, y) = ((y^2)/(2(Sqrt[x y])))+ (x^2)y cos(x y) + 2 x sin (x y)		(2)
and 
	Y(x, y) = ((x y)/(2(Sqrt[x y])))+(Sqrt[x y ]) + (x^3)cos(x y)		   (3)
the integrals
	(Subscript[I, 1])= (∫_0^3)X(x,(Subscript[f, 1])(x))dx  + Y(x,(Subscript[f, 1])(x))((d (Subscript[f, 1])(x))/dx) dx 		(4)
and 
	(Subscript[I, 2])= (∫_0^3)X(x,(Subscript[f, 2])(x))dx  + Y(x,(Subscript[f, 2])(x))((d (Subscript[f, 2])(x))/dx) dx 		(5)
are path-independent.  That seems miraculous, but it isn’t.  To generate the functions X and Y, given in Eqs. 2 and 3,  I used 
	X(x,y) = ((∂ F(x, y))/(∂x))							(6)			
and 
	Y(x,y) = ((∂ F(x,y))/(∂y))								(7)
I used 
	F(x,y) = y (Sqrt[x y])+(x^2) Sin(x y)					(8)
and Eqs. 6 and 7 to generate the expressions Eqs. 2 and 3, for X and Y.

Theorem 2: The integral
	I= (∫_(Subscript[x, i])^(Subscript[x, f]))X(x,f(x))dx  + Y(x,f(x))((d f(x))/dx) dx 		(9)
 is path  independent if and only if there is a function F[x, y] such that 
	I = F[(Subscript[x, f]), (Subscript[y, f])]   - F[(Subscript[x, i]),(Subscript[y, i])]    						(10)
The integral depends on the end points only.

Theorem 3:  A necessary and sufficient condition for the path-independence of  the integral  
	I= (∫_a^b)X(x,y)dx  + Y(x,y)dy 
 is that 
	((∂X)/(∂y))= ((∂Y)/(∂x))
Let us check that these conditions are satisfied for X and Y used in the calculations performed in WorkBookT8.2.

Cell 2:  Test the conditions for path independence

I used the function
	F(x, y) = y (Sqrt[x y])+(x^2) Sin(x y)
to generate 
	X = ((∂ F[x,y])/(∂x))  and  Y[x, y] = ((∂ F[x,y])/(∂y))

Define 
	F(x,y) = y (Sqrt[x y])+(x^2) Sin(x y)

F[x_,y_]:=y Sqrt[x y] +x^2 Sin[x y]

Define 
	X(x,y) =  ((∂F(x,y))/(∂x))

Clear[X]
X[x_,y_]:=D[F[x,y],x]
X[x,y]

Define  
	Y(x,y) = ((∂F(x,y))/(∂y))

Clear[Y]
Y[x_,y_]:= D[F[x,y],y]
Y[x,y]

One of the conditions for path independence is 
	 ∂X/∂y=∂Y/∂x

Verify that X and Y defined as described satisfy this condition

D[X[x,y],y]===D[Y[x,y],x]

The other theorem says that the integral must be equal to the magnitude of F at the final point of the path minus the magnitude of F at the initial point of the path.  The initial point was 
	{x = 0, y = 0}
The final point was
	{x = 3, y = (3^3)/9}
The integral was 
	12.7091
According to the theorem we must have
	F[3,(3^3)/9] - F[0,0] = 12.7091
Verify this

F[3,3^3/9]-F[0,0]//N

I conclude that the calculations are in agreement with the theorems that I collected for you.