Work in Conservative and Non-Conservative Force Fields

Introduction

OBJECTIVE:  Visualize and evaluate work integrals along different paths, and observe the effect of following different paths through conservative and non-conservative force fields.

You will explore integration over vector fields and experiment with both conservative and non-conservative force functions along different paths. These explorations should help you understand line integrals, as well as better appreciate situations when the work done is independent of the path taken.

Technology Guidelines

NOTE:  If you have just finished a module, restart Mathematica or Quit Kernel under the Evaluation pull-down menu before executing a new module.
TO OPEN CELLS, click on the arrow to the left of the cell or put your cursor on the right cell bracket and double click. To open all cells, highlight the bracket on the far right and select Grouping under the Cell pull-down menu and select Open All Subgroups.
TO STOP AN EXECUTION
Select the Evaluation pull-down menu and click on Abort Evaluation.
ORDER OF EXECUTION
Execute cells in the order given. Do not skip any Input cells within a given notebook.
SAVING NOTEBOOKS
You can save anytime to any directory you choose, and it is wise to save often. However, before you do your final save to reduce the size of your file, it is a good idea to delete all your output by selecting the Delete All Output selection under the Cell pull-down menu.
EXPERIENCING MAJOR PROBLEMS
Save if appropriate, then shut down Mathematica and start it up again.

Part I: Examples in Two Dimensions

Conservative Force

Verifying That the Force Is Conservative

Consider the following force defined by {-x Cos[2y],(x^2)Sin[2y]}, and verify that it is conservative.

Clear[x,y,z,force] 
force:={-x Cos[2y],(x^2)Sin[2y]};
my=D[force[[1]],y]//Simplify
nx=D[force[[2]],x]//Simplify
If[my==nx,Print["The force is conservative."],Print["The force is not conservative."]]

\[MathematicaIcon] About Mathematica

Visualizing the Force Field and Different Paths

The force field is plotted together with three paths between (0, 0) and (1, 1): y = x, (Sqrt[x]),and  (x^3).

Clear[x,y]
pv=VectorPlot[force,{x,0,1},{y,0,1},VectorColorFunction->Hue,VectorPoints->15,VectorScale->{.1,.7}];pc=Plot[{x,(Sqrt[x]),(x^3)},{x,0,1}];Show[pv,pc]

Writing Parametrizations and Computing Work Integrals

Find the work done in traveling along the straight line y = x. Choose an appropriate parametrization. We write the position and velocity vector to assist in computing the work integral. Note that by setting x and y equal to particular functions of t, the force function will reflect that parametrization when it appears in the line integral.

Clear[x,y,t]
x=t;
y=t;
r1={x,y};
Print["velocity = ",v1=D[r1,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w1=Integrate[force.v1,{t,0,1}]//N ]

Now find the work done in traveling along the lower curve y = (x^3). Choose an appropriate parametrization.

Clear[x,y,t]
x=t;
y=(t^3);
r2={x,y};
Print["velocity = ",v2=D[r2,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w2=Integrate[force.v2,{t,0,1}]//N ]

Now find the work done in traveling along the upper curve y = (Sqrt[x]). As before, choose an appropriate parametrization.

Clear[x,y,t] 
x=t;
y=(Sqrt[t]);
r3={x,y};
Print["velocity = ",v3=D[r3,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w3=Integrate[force.v3,{t,0,1}]//N ]

Was the work done along each path the same?

w1==w2==w3

Non-Conservative Force

Defining and Visualizing the Force Field

Consider the a spinning force and verify that it is not conservative.

Clear[x,y,z,force] 
force={-y/(Sqrt[(x^2)+(y^2)]),x/(Sqrt[(x^2)+(y^2)])};
my=D[force[[1]],y]//Simplify
nx=D[force[[2]],x]//Simplify
my==nx//Simplify

You can see that for arbitrary values of x and y, this last equation will not be true. Therefore, by the definition provided in this Section of your text, the force is not conservative.

You will get an error message here since the force field is not defined at (0, 0), but just proceed. For this function, the work integrals will be improper, but they can still be found. The error messages that might occur remind us how difficult integration can be. We will use the same paths as above.

Clear[x,y]
pv=VectorPlot[force,{x,0.01,1},{y,0,1},VectorColorFunction->Hue];pc=Plot[{x,(Sqrt[x]),(x^3)},{x,0,1}];Show[pv,pc]

Writing Parametrizations and Computing Work Integrals

As you have learned from hand computation, line integrals can be difficult to evaluate. Even Mathematica has problems with some line integrals. When you experiment with your own force or path functions, sometimes you may have to use numerical integration (NIntegrate), and sometimes you may have to use symbolic integration (Integrate). You will also get error messages at times, warning you about problems associated with the convergence of the integration technique. In these cases, you will frequently, but not always, be given an answer that is reasonably accurate.

In this example, we have a problem at t=0, because the force function has a 0 denominator for the parametrizations given.

Find the work done in traveling along the straight line y = x. Choose an appropriate parametrization. We write the position and velocity vector to assist in computing the work integral. Note that by setting x and y equal to particular functions of t, the force function will reflect that parametrization when it appears in the line integral.

Clear[x,y,t]
x=t;
y=t;
r1={x,y};
Print["velocity = ",v1=D[r1,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w1=Integrate[force.v1,{t,0,1}]//N ]

Could you have predicted this answer by looking at the graph?

Now find the work done in traveling along the lower curve y = (x^3). Choose an appropriate parametrization.

Clear[x,y,t]
x=t;
y=(t^3);
r2={x,y};
Print["velocity = ",v2=D[r2,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w2=NIntegrate[force.v2,{t,0,1}]]

The result is very different from our previous value. Now find the work done in traveling along the upper curve y = (Sqrt[x]). As before, choose an appropriate parametrization.

Clear[x,y,t] 
x=t;
y=(Sqrt[t]);
r3={x,y};
Print["velocity = ",v3=D[r3,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w3=Integrate[force.v3,{t,0,1}]//N ]

What does it mean when our work done went from 0 on the first path to a positive number on the second path and now to a negative value? Could you have predicted that from the graph showing the force field? This example demonstrates how for non-conservative forces, the work done in getting from one point to another is not independent of the path taken.

You Try It: Part I

Try a different path in going from (0, 0) to (1, 1). Suppose you go from (0, 0) to (1, 0) and then to (1, 1), all along parallel and perpendicular lines. The following commands specify appropriate parameterizations. You can execute them for any two-dimensional force. Begin by entering any force you wish by replacing the terms in red.

Clear[x,y,t]
newforce:={Cos[5x],-3x y};

First, go from (0, 0) to (1, 0).

x=t;
y=0;
r1={x,y};
dr1=D[r1,t];
Print["work done along path = ",w4a=Integrate[newforce.dr1,{t,0,1}]//N ]

Next, go from (1, 0) to (1, 1).

Clear[x,y,t]
x=1
y=t;
r2={x,y};
dr2=D[r2,t];
Print["work done along path = ",w4b=Integrate[newforce.dr2,{t,0,1}]//N ]

Add your results, and contrast them to what you would get with the paths used earlier. Do this for both conservative and non-conservative forces.

w4=w4a+w4b

Compute the work done along the line y = x.

Clear[x,y,t]
x=t;
y=t;
r1={x,y};
Print["velocity = ",v1=D[r1,t]]
Print["force function along curve = ",newforce]
Print["work done along path = ",w1=Integrate[newforce.v1,{t,0,1}]//N ]

Compute the work done along the curve y = (x^3).

Clear[x,y,t]
x=t;
y=(t^3);
r2={x,y};
Print["velocity = ",v2=D[r2,t]]
Print["force function along curve = ",newforce]
Print["work done along path = ",w2=NIntegrate[newforce.v2,{t,0,1}]]

Compute the work done along the curve y =(Sqrt[ x]).

Clear[x,y,t] 
x=t;
y=(Sqrt[t]);
r3={x,y};
Print["velocity = ",v3=D[r3,t]]
Print["force function along curve = ",newforce]
Print["work done along path = ",w3=Integrate[newforce.v3,{t,0,1}]//N ]

Is the work done in going from (0, 0) to (1, 1)  the same for all the paths?

{w1,w2,w3,w4}//TableForm
w1==w2==w3==w4

Part II: Example in Three Dimensions

Given the force with components: {(e^(y z)),x z (e^(y z))+ z Cos(y),x y (e^(y z))+ Sin(y)}, find the work done in going from (1,0,1) to (1,π/2,0)  by traveling along three different paths. The parametrizations for these paths are detailed below and the work is computed for each. The results from the three paths are then compared and visualized.

Clear[x,y,z,force] 
force:={(E^(y z)),x z (E^(y z))+ z Cos[y],x y (E^(y z))+ Sin[y] };

Verifying That the Force Is Conservative

By computing and comparing the appropriate first partial derivatives, verify that the force defined is conservative.

my=D[force[[1]],y]//Simplify
nx=D[force[[2]],x]//Simplify
mz=D[force[[1]],z]//Simplify
px=D[force[[3]],x]//Simplify
nz=D[force[[2]],z]//Simplify
py=D[force[[3]],y]//Simplify
my==nx
mz==px
nz==py

Writing the Parameterization and Computing the Work Integral

Find the work done in traveling along the straight line from (1, 0, 1) to (1, π/2, 0), as specified in 13.30 a. Choose an appropriate parametrization. Write the position and velocity vector to assist in computing the work integral. When you set x, y, and z equal to particular functions of t, the force function will reflect that parametrization when it appears in the line integral.

Clear[x,y,t]
x=1;
y=π t/2;
z=1-t;
r1={x,y,z};
Print["velocity = ",v1=D[r1,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w1=Integrate[force.v1,{t,0,1}]//N ]

Writing Parametrizations and Computing Work Integrals

Find the work done in the two straight line paths specified in part b. Choose appropriate parametrizations. First, go from (1,0,1) to the origin.

Clear[x,y,t]
x=1-t;
y=0;
z=1-t;
r21={x,y,z};
Print["velocity = ",v2=D[r21,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w21=Integrate[force.v2,{t,0,1}]//N ]

Go from the origin to (1, π/2, 0).

Clear[x,y,t]
x=t;
y=π t/2;
z=0
r22={x,y,z};
Print["velocity = ",v2=D[r22,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w22=Integrate[force.v2,{t,0,1}]//N ]

So the total work done for part b is as follows

w2=w21+w22

Writing Parameterizations and Computing Work Integrals

Find the work done for the two straight line paths plus the parabolic path specified in part c. Choose appropriate parametrizations. 
Path A: 
First, go from (1, 0, 1) to (1, 0, 0).

Clear[x,y,t]
x=1;
y=0;
z=1-t;
r31={x,y,z};
Print["velocity = ",v3=D[r31,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w31=Integrate[force.v3,{t,0,1}]//N ]

Path B: 
Now follow the x axis in going from (1,0, 0) to the origin.

Clear[x,y,t]
x=1-t;
y=0;
z=0;
r32={x,y,z};
Print["velocity = ",v3=D[r32,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w32=Integrate[force.v3,{t,0,1}]//N ]

Path C: 
Now follow a parabola from the origin to (1, π/2, 0).

Clear[x,y,t]
x=t;
y=π (t^2)/2;
z=0
r33={x,y,z};
Print["velocity = ",v3=D[r33,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w33=Integrate[force.v3,{t,0,1}]//N ]

So the total work done for Path C is as follows.

w3=w31+w32+w33

Was the work done along each path the same?

w1==w2==w3

Visualizing the Force Field and Different Paths

The following set of commands will plot the force field, together with the paths in red (path A), green (path B), and aqua (path C).

pp1=ParametricPlot3D[Evaluate[r1],{t,0,1},ColorFunction->Function[{x,y,z},RGBColor[1,0,0]]];
pp21=ParametricPlot3D[Evaluate[r21],{t,0,1},ColorFunction->Function[{x,y,z},RGBColor[0,1,0]]];
pp22=ParametricPlot3D[Evaluate[r22],{t,0,1},ColorFunction->Function[{x,y,z},RGBColor[0,1,0]]];
pp31=ParametricPlot3D[Evaluate[r31],{t,0,1},ColorFunction->Function[{x,y,z},RGBColor[0,1,1]]];
pp32=ParametricPlot3D[Evaluate[r32],{t,0,1},ColorFunction->Function[{x,y,z},RGBColor[0,1,1]]];
pp33=ParametricPlot3D[Evaluate[r33],{t,0,1},ColorFunction->Function[{x,y,z},RGBColor[0,0,1]]];
Clear[x,y,z]
forceplot=VectorPlot3D[force,{x,0,1},{y,0,1.5},{z,0,1},VectorPoints->5];
Show[pp1,pp21,pp22,pp31,pp32,pp33,forceplot,AxesLabel->{x,y,z},PlotRange->{{0,1},{0,1.5},{0,1}}]

The paths are: red (path A), green (path B), and aqua (path C).

You Try It: Part II

Redefine your force in the previous example, and re-execute all the cells. Only the terms in red in the force function need to be changed. This time try a non-conservative force. You could begin by checking out the function given; we have followed the same paths as in Part II. Be careful to use correct terminolgy.

Clear[x,y,z,force]
force:={(x^2)Cos[y],(E^(y z))(1-x),x y  Sin[z] };

Is the Force Conservative or Not?

my=D[force[[1]],y]//Simplify;
nx=D[force[[2]],x]//Simplify;
mz=D[force[[1]],z]//Simplify;
px=D[force[[3]],x]//Simplify;
nz=D[force[[2]],z]//Simplify;
py=D[force[[3]],y]//Simplify;
my==nx
mz==px
nz==py

Are the corresponding partial derivatives equal to one another?

Writing the Parametrization and Computing the Work Integral - Path A

Find the work done in traveling along the straight line from (1, 0, 1) to (1, π/2, 0), as specified in part a). Choose an appropriate parametrization. Write the position and velocity vector to assist in computing the work integral. When you set x, y, and z equal to particular functions of t, the force function will reflect that parametrization when it appears in the line integral.

Clear[x,y,t]
x=1;
y=π t/2;
z=1-t;
r1={x,y,z};
Print["velocity = ",v1=D[r1,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w1=Integrate[force.v1,{t,0,1}]//N ]

Writing Parametrizations and Computing Work Integrals - Path B

Now find the work done in the two straight line paths specified in part b. Choose appropriate parametrizations. First we will go from (1, 0, 1) to the origin.

Clear[x,y,t]
x=1-t;
y=0;
z=1-t
r21={x,y,z};
Print["velocity = ",v2=D[r21,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w21=Integrate[force.v2,{t,0,1}]//N ]

Next, go from the origin to (1, π/2, 0).

Clear[x,y,t]
x=t;
y=π t/2;
z=0
r22={x,y,z};
Print["velocity = ",v2=D[r22,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w22=Integrate[force.v2,{t,0,1}]//N ]

So the total work done for part b is as follows

w2=w21+w22

Writing Parametrizations and Computing Work Integrals - Path C

Find the work done for the two straight line paths plus the parabolic path specified in part c. Choose appropriate parametrizations. First, go from (1, 0, 1) to (1, 0, 0).

Clear[x,y,t]
x=1;
y=0;
z=1-t;
r31={x,y,z};
Print["velocity = ",v3=D[r31,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w31=Integrate[force.v3,{t,0,1}]//N ]

Now follow the x axis in going from (1, 0, 0) to the origin.

Clear[x,y,t]
x=1-t;
y=0;
z=0;
r32={x,y,z};
Print["velocity = ",v3=D[r32,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w32=Integrate[force.v3,{t,0,1}]//N ]

Now follow a parabola from the origin to (1, π/2, 0).

Clear[x,y,t]
x=t;
y=π (t^2)/2;
z=0
r33={x,y,z};
Print["velocity = ",v3=D[r33,t]]
Print["force function along curve = ",force]
Print["work done along path = ",w33=Integrate[force.v3,{t,0,1}]//N ]

So the total work done for Path C is as follows

w3=w31+w32+w33

Was the work done along each path the same?

w1==w2==w3

Visualizing the Force Field and Different Paths

The following set of commands will plot the force field, together with the paths in red (path A), green (path B), and blue (path C).

pp1=ParametricPlot3D[Evaluate[r1],{t,0,1},ColorFunction->Function[{x,y,z},RGBColor[1,0,0]]];
pp21=ParametricPlot3D[Evaluate[r21],{t,0,1},ColorFunction->Function[{x,y,z},RGBColor[0,1,0]]];
pp22=ParametricPlot3D[Evaluate[r22],{t,0,1},ColorFunction->Function[{x,y,z},RGBColor[0,1,0]]];
pp31=ParametricPlot3D[Evaluate[r31],{t,0,1},ColorFunction->Function[{x,y,z},RGBColor[0,0,1]]];
pp32=ParametricPlot3D[Evaluate[r32],{t,0,1},ColorFunction->Function[{x,y,z},RGBColor[0,0,1]]];
pp33=ParametricPlot3D[Evaluate[r33],{t,0,1},ColorFunction->Function[{x,y,z},RGBColor[0,0,1]]];
Clear[x,y,z]
forceplot=VectorPlot3D[force,{x,0,1},{y,0,1},{z,0,1},VectorPoints->4];
Show[pp1,pp21,pp22,pp31,pp32,pp33,forceplot,AxesLabel->{x,y,z}]

\[MathematicaIcon] About Mathematica

The If statement used here is in standard programming format. If the statements in the first input is true, the second input is executed; if false, the third input is executed.
Go back.