Exercise 5

Objective/Overview:

In today’s exercise, we will practice taking the Gradient of Scalar fields.  We will show that that Curl-free fields have path-independent line integrals of Electric field.

ClearAll[vxy,v1, e1, gradvxy, vxyz, gradvxyz, curlgradvxyz]

The Gradient

The final del-operation we cover in class is the Gradient.  The gradient operates on a scalar field, NOT a vector field.  The Gradient, however, returns a vector field that points in the direction which the scalar field is changing, with a magnitude telling us how fast the field is changing. Let’s define a scalar field:

vxy=Exp[-(x^2/.5^2)]*Exp[-(y^2/.5^2)]

Plot3D[vxy,{x,-1,1},{y,-1,1}, PlotRange->Full]

This is a 2D Gaussian distribution, but it basically gives us a hill, so we can fairly quickly imagine what the gradient of this function will look like.  Let’s see if we are right:

gradvxy=Grad[vxy,{x,y}]

VectorPlot[gradvxy,{x,-1,1},{y,-1,1}]

If we want to be super-cool, we can superimpose the vector field on the 2D surface from before...

Plot3D[vxy,{x,-1,1},{y,-1,1}, PlotRange->Full, PlotStyle->Texture[StreamPlot[gradvxy,{x,-1,1},{y,-1,1}]]]

You can see that the Gradient gives us us a vector field that points along the slope of our surface.  This is harder (if not impossible) to picture in three dimensions, of course, but the basic concepts are the same.

The Electrostatic Potential

We can think of the electrostatic potential “V” as the potential energy of a test charge of +1C in an electric field (OverVector[E])=-∇V.  In other words, the (negtive) gradient of the electrostatic potential gives us the Electric Field.
We have already found the electric field for our “vxy” above, since it is just the negative gradient of “vxy”.  Let’s make sure that this is, in fact a Curl-free field:

curlEgaussian=Curl[-gradvxy,{x,y}]

Remember, the curl of a vector field should be another vector field.  However, when we have a 2D vector field, like the one above, then the curl will ALWAYS be orthogonal to our field vectors.  So forthe field above, all vectors are in the xy plane, and therefore the curl is in z.  That is why Mathematica gives the curl of a 2D field as a scalar number...

Below, create a scalar potential in 3D!  Construct the Electric Field associated with this scalar potential (and plot it) and show that this is a Curl-free electric field:

For an Electrostatic Field, the Curl is always zero, and we can always write the electrostatic field as the Gradient of a scalar potential (as you just showed!).

Path Independence

One of the consequences of an Electrostatic field is that the line integral of the field between two points will always be the same, regardless of the path that you take between those two points.  This is related to conservation of energy, which we will get to later on.  For now, let’s create a new Electric Field from the gradient of a scalar:

v1=x^2*z-y^3*z

e1=-Grad[v1,{x,y,z}]

p1=VectorPlot3D[e1,{x,-2,2},{y,-2,2},{z,-2,2}]

OK.  Now we want to show that the line integral (∫_a^b)(OverVector[e1])·d(OverVector[ℓ]) is the same regardless of the path we take.  

Lets say our two points are:  a=(0,0,0) and b=(2,2,2).

We can try a number of paths, but let’s start by integrating along three lines: 
from (0,0,0)->(2,0,0), (2,0,0)->(2,2,0), and (2,2,0)->(2,2,2):

p2=Graphics3D[{Red,Thick,Line[{{0,0,0},{2,0,0},{2,2,0},{2,2,2}}]}];
Show[p1,p2]

Let’s write our vector field as a function:

fe1[x_,y_,z_]:={-2 x z,3 (y^2) z,-(x^2)+(y^3)}

Integrate[Dot[fe1[x,0,0],{1,0,0}],{x,0,2}]

Integrate[Dot[fe1[2,y,0],{0,1,0}],{y,0,2}]

Integrate[Dot[fe1[2,2,z],{0,0,z}],{z,0,2}]

So the line integral of the electric field over the three lines connecting {0,0,0} to {2,2,2} gives us “8”.  That means we have an 8 V voltage drop from  {0,0,0} to {2,2,2} --- that is, potential V is 8 V larger at a={0,0,0}  compared to b={2,2,2}. (this is what you confirm as an exercise at the end of this notebook!!).

I want to show you one more way of taking a line integral before you try it yourself.  
In the next section, we are going to parameterize the path.  
First we create a function to describe our electric field, then we design a path --- that is create a vector function of position with an independent variable t:

fe1[x_,y_,z_]:={-2 x z,3 (y^2) z,-(x^2)+(y^3)}  ;
path1[t_]:={2*t,2*Sin[5*t*Pi/2],2*t^2}  (*This clearly gives us, for t=0, {0,0,0] and for t=1, {2,2,2}*)

To plot this, we can use a Parametric Plot:

p3=ParametricPlot3D[path1[t],{t,0,1},PlotStyle->Red];

Show[p1,p3]

The line integral is then our function written in terms of “t”, dotted with path’, integrated between 0<t<1. 

Mathematically, what we have done here is:
(OverVector[E])={(Subscript[E, x])(x,y,z),(Subscript[E, y])(x,y,z),(Subscript[E, z])(x,y,z)},  path={x,y,z}={x(t),y(t),z(t)}, d(OverVector[l])= path’(t)dt

(∫_(0,0,0)^(2,2,2))(OverVector[E])·d(OverVector[l])=(∫_(t=0)^(t=1))(OverVector[E])(x(t),y(t),z(t))·(((dx(t))/dt),((dy(t))/dt),((dz(t))/dt)) dt

Please bear in mind that “t” does not necessarily stand for time (though I guess it could if you wanted to think of it that way)

Let’s see how this works:

Integrate[Dot[fe1[2*t,2*Sin[5*t*Pi/2],2*t^2],path1'[t]], {t,0,1}]

OK, now you describe a path from {0,0,0} to {2,2,2}, and take the line integral of this path through the vector field “e1”.  You can do this piecewise, with lines, or by creating a parameterized path.  What do you get?

Hopefully you also got “8”.  What happens if you go in the opposite direction?

Integrate[Dot[fe1[2*t,2*Sin[5*t*Pi/2],2*t^2],path1'[t]], {t,1,0}]

Integrate the path you created, but in the opposite direction:

This makes sense!  If you go from point “a” to “b” in a static Electric Field and your electrostatic potential increases by 8, then when you go back to point “a” from “b”, you would expect your electrostatic potential to decrease by 8!!  This tells us that the field is Conservative.  As you make a round trip, along any path, you will never gain (or lose) energy from the Electrostatic Field...total energy is conserved.
Let’s  create a round trip path:

path2[t_]:={Sin[2*Pi*t]*Cos[2*Pi*t],Sin[6*t*Pi],1-(2*t-1)^2}  (*This clearly gives us, for t=0, {0,0,0] and for t=1, {0,0,0}*)

To plot this, we can use a Parametric Plot:

p4=ParametricPlot3D[path2[t],{t,0,1},PlotStyle->Red];

p5=Animate[Graphics3D[Sphere[{Sin[2*Pi*t]*Cos[2*Pi*t],Sin[6*t*Pi],1-(2*t-1)^2},0.2],PlotRange->{{-2,2},{-2,2},{-2,2}}],{t,0,1},AnimationRepetitions->2,SynchronousUpdating->False] (*just for fun...*)

Show[p1,p4]

If we integrate along this entire path (essentially from t=0 to t=1), we get:

Integrate[Dot[fe1[Sin[2*Pi*t]*Cos[2*Pi*t],Sin[6*t*Pi],1-(2*t-1)^2],path2'[t]], {t,0,1}]

So we are able to create some totally crazy loop, integrate the dot product of the Electric Field and a differential element of the path over the entire path, and as long as the field is curl-free (conservative), we will always get zero!!

To hammer this home, let’s go back to our Elecrostatic Potential from which we obtained the Static Field discussed above:

fv1[x_,y_,z_]:=x^2*z-y^3*z

Solve for the Electrostatic Potential at {0,0,0} and {2,2,2}.  What do you notice? Can you expain these potential values in terms of an 8 volt voltage drop from  {0,0,0} and {2,2,2}?

fv1[0,0,0]

fv1[2,2,2]

Explanation: