Finding V and E for a finite line charge along symmetry axis;  Extend to Infinite Line Charge

Problem:  Consider a finite line charge oriented along the x-axis with linear electric charge density λ  and total length L.  We are going to explore the electric potential and electric field along the z axis.  We will also look at the consequences of letting L → ∞.

(a) First, derive an appropriate differential of electric potential (dV[z]) at a point P1 positioned a distance z along the z axis from the origin as shown.   Assume that  z > 0.  [Symmetry argument:  if you move the point P1 in a circle (holding z constant) around the line charge, the charge distribution does not change.  The solution for negative values of z is exactly the same as solutions for positive values of z. There is no need to consider negative values of z separately.  In addition, if we rotate the line charge 180° about the z axis(holding P1 fixed), the resulting charge distribution is the same as the initial charge distribution.  If the electric field had an x or y component, this rotation should reverse the direction of these components; but the direction of the electric field can't be changed because the charge distribution has not changed. Therefore the electric field at P1 lies in the z-direction.]

For this exercise (a), you can do the derivation by hand and simply enter (type in) your result in the text cell below, OR you can type in your derivation.

(this is a text cell; type in your dV (with or without your derivation))

(b)  Using your derived differential of potential, dV, use M to find V at the point P1, i.e., V[z].  

A couple of reminders:

1.   (* This is a comment *) 

and 

2.  If you get some weird results at some point, try going back and re-executing all the previous cells to reset your functions and variables.

I have inserted in the input cell below

i) Some cleanup code

ii) A batch of assumptions [$Assumptions = ....] to get M to focus on determining a Real (as opposed to an Imaginary) V, etc.  There are more assumptions than we really need but including more does no harm.  

iii) M sometimes interprets the prime symbol (ʹ) as a derivative.  In code, it is safer to indicate the prime another way.  One way is to write out xprime for xʹ and dxprime for dxʹ.

Quit Kernal-> Local;  (* Big Time Cleanup  *)
ClearAll["Global`*"]  (*  Usual Cleanup  *)
$Assumptions = xprime ∈ Reals && -L/2 ≤ xprime≤ L/2 && z ∈ Reals && z >0  && L ∈ Reals && L >0 && zo∈ Reals && zo > 0 &&Re[L]>0 &&Im[L]==0;

(c) Now Plot V[z]  

Remember, we have to give k, λ, and L numerical values to Plot.  I picked the following:  k = 1; λ = 1; and L = 2.  (Note:  When we interpret the results, it is important to remember that we chose a positive λ.)

We also need to chose the range of z for the plot:  I use {z, 0, 5}.  ( Remember we are taking z > 0.)  I also have inserted a PlotRange → {0, 25} option, but it’s not essential to do so.

(*  INPUT CELL *)

(d)  Your plot of V[z] should look suspicious at z = 0.  Is V[z] finite at z = 0?  Look at your resulting function for V[z], and state in the text cell below your guess for V[0].

(This is a text cell -- type in your “guess”):

(e) Use M to confirm the expected limits: V[z → 0]  and Log[z → 0].   First, evaluate V[0] and Log[0]:

(*  INPUT CELL  just run it*)

(f) We can also test our V[z] by taking the limit of V[z] as z → 0.  

Add this line of code before taking the limit:  
		$Assumptions = L > 0 && L ∈ Reals;  

It helps M find the Limit.

What the heck; here’s the whole deal:

(*  INPUT CELL *)
Clear[k,λ,L]
V[z]  (* just checking -- after clearing k, λ, and L,V[z] should look like first V[z] you obtained *)
$Assumptions = L >0 && L ∈ Reals;  (* to help in the Limit step -- you write it!"  *)
Limit[V[z],z-> 0]//Simplify

(g)  Comment on your Limit result:

(This is a text cell -- type in your comment):

(h) What else about the results?  Perhaps you see in your plot that as z gets larger, V gets smaller and smaller.  Check this out by finding Limit of V[z] as z -> ∞:

(*  INPUT CELL *)

(i)  Let's continue to check V[z] by comparing plots of V[z]  and k ((Q )/z), for very large z.  Here k ((Q )/z) is the potential of a point charge Q, where Q = L λ is the total charge of the finite line charge.   

M:  Recall that to plot two functions of z simultaneously you enter:  Plot[ {f1[z], f2[z]},{z, zmin, zmax}]; note the curly brackets:   {f1[z], f2[z]}.

Don’t forget to give values to your constants (e.g., k = 1; L = 2; λ = 1; )

(*  INPUT CELL *)

(j)  Comment on your result (compare the two curves):

(This is a text cell -- type in your Comment:)

(k) Now let’s look at V[z] for an infinite line charge.  Taking the limit of our finite line charge V (currently V[z]) as L → ∞ should give us (Subscript[V, infinite line charge])[z].  For now, call it VV[z]

Do it:

(*  INPUT CELL *)
Clear[k,λ,L]

(l)  Comment on this result:

(This is a text cell -- type in your Comment:)

(m)  So we are in trouble.  The finite line charge gave us a zero as z → ∞.  Not so for the infinite line charge.  

The fix:  We Need a Reference Point, say 0 < zo < ∞, and we set V[zo] = constant (e.g., 0).  We define a new potential as 

			Vnew[z_] = V[z] - V[zo]
			
Enter Vnew[z] in an input cell and then take Limit[Vnew[z], L-> ∞]  
	(I called it (Subscript[V, infinite])[z]; i.e., (Subscript[V, infinite])[z_]=Limit[Vnew[z],L-> ∞]).      Here, infinite means infinite line charge (L-> ∞)

(*  INPUT CELL *)

You can manipulate the Logs if needed to get a single Log term.  (Skip if you wish; M does not care)

If you wish to redefine (Subscript[V, infinite])[z_], simply write it in the input cell below,  

 OR if you want it unchanged, simply enter (Subscript[V, infinite])[z_] =   (Subscript[V, infinite])[z ]  .

 NOTE: In any decent programming language we can redefine a function and use it’s name on both sides of the equation. On the RHS is the OLD function, say f[x]. On the LHS is the NEW function with the same name f[x_].  When executed, f[x] is the NEW function.

Here is (Subscript[V, infinite])[z]written like you probably have seen (e.g., derived from Gauss’s Law

(*  INPUT CELL *)
(Subscript[V, infinite])[z_] = 2 k λ Log[(zo/z)]

(* Repeat:   SOMETHING has to go here; see above.  ALSO:  Don't forget to execute the cell when ready  

 BE SURE TO type in a RHS — you have to put something on the RHS! 
I have redefined (Subscript[V, infinite])[z]. You can leave it the same by entering  (Subscript[V, infinite])[z_] = (Subscript[V, infinite])[z] *)

To determine what happens to (Subscript[V, infinite])[z] at z = zo,  just run this input cell:

(Subscript[V, infinite])[zo]

You should get a result consistent with (Subscript[V, infinite])[zo] = V[zo] - V[zo] which is zero! This trick does not improve the behavior of (Subscript[V, infinite])[z] as z approaches zero and infinity (As z → 0, (Subscript[V, infinite])[z] →  ∞. As z → ∞,  (Subscript[V, infinite])[z] → –∞.) but it yields finite potentials for every z in between.  

If the sign of the z → ∞ limit seems unnatural (one might hope that positive charges yield positive potentials), remember that the added term +2 k λ Log[((2 zo)/(L+(Sqrt[(L^2)+4 (zo^2)])))] approaches –∞ as z → ∞.  This is legal because we never let z = ∞ as we take the limit.  For all 0 < z < ∞, the added term is well behaved, and we are allowed to add such constants to our potentials.  

Bottom Line:  By introducing the Reference Point zo, where V[zo] = 0 and THEN letting L-> ∞, we derive V for an infinite line charge consistent with the more traditional approach (deriving E using Gauss’s Law and integrating to any z FROM some arbitrary reference point zo where you set V[zo] = 0).

(n) So, we stumbled our way into finding an acceptable  (Subscript[V, infinite])[z]. from our V[z] of a finite line charge.

NOW:   Use (Subscript[V, infinite])[z] to find the Electric Field at z.

Some useful hints:

Applying Simplify[ expression] to your first whack at determining the E field will clean up your result a great deal.  (Alternatively, you can use the PostFix   //Simplify.)

We can use -Grad[(Subscript[V, infinite])[z]] OR use -D[(Subscript[V, infinite])[z], z] (the first derivative of V wrt z).  We’ll do both.  Heads up:  If you define your E field as (OverVector[E])[z], you will keep getting this message:  ... Set:  Tag e in e[z] is Protected.  M interprets E as e (the base for the Natural Logs).  

Way out: use something like (OverVector[EE])[z] for (OverVector[E])[z].  Remember, (OverVector[EE])[z] is a vector.

First, I used the Grad operator to generate (OverVector[EE])[z]; then I applied the Simplify function to get a cleaner answer using // (PostFix).  (More conventional form:  Simplify[- Grad[V[z],{x,y,z}]]).  In the code I dropped the vector (arrow) over the EE and simply used EE[z].

(*  INPUT CELL *)
Clear[k, λ, L]
V[z]  (*  Check Up time *)
EE[z_]= - Grad[(Subscript[V, infinite])[z],{x,y,z}]//Simplify  
(* THIS IS A VECTOR; Note the 3 components
The //Simplify on the end says 
find -Grad[V[z] and then try to simplify that result.  // is called PostFix  *)
EEzinfinite[z]= EE[z][[3]]   (*  This grabs the z component EEz[z] (which is a scalar) of the vector (OverVector[EE])[z]  *)

Since the only non-zero term is EEzinfinite[z] (the zth component) = – ((dVinfinite[z])/dz), we can also find EE[z] by a simple derivative.  Again, apply Simplify to get a clean solution.  Should be consistent with using –Grad.

(*  INPUT CELL *)
EEzinfinite[z_] = -D[(Subscript[V, infinite])[z],z]//Simplify

To obtain (OverVector[EE]) in (perhaps) a more familiar form substitute k = (1/(4 π (Subscript[ϵ, o]))).
Easiest way:   type this in the input cell and execute:

(Subscript[(OverVector[EE]), infinite line charge])[z_]= (Subscript[(OverVector[EE]), infinite line charge])[z]/.k-> (1/(4 π (Subscript[ϵ, o])))    
Reminder: we can redefine a function and use it's name on both sides of the equation; the one on the RHS is the OLD (Subscript[(OverVector[EE]), infinite line charge])[z] and the one on the LHS is the NEW (Subscript[(OverVector[EE]), infinite line charge])[z].

(*  INPUT CELL *)
EEzinfinite[z_]= EEzinfinite[z]/.k-> (1/(4 π (Subscript[ϵ, o])))

Of course the vector version is 

		 (Subscript[(OverVector[EE]), infinite line charge])[z]  = (λ/(2 π z (Subscript[ϵ, o])))  (OverHat[z])

This is exactly the same result we get from applying Gauss’s Law to an infinite line charge (where we apply symmetry arguments to justify that (OverVector[EE]) depends only on z AND points in the + (OverHat[z]) direction for λ > 0.)

Here is a rehash of this process for finding the potential of the infinite line charge.  All the code is given; go through it carefully.

We can generate (Subscript[V, infinite line charge])[z] by letting (Subscript[V, finite])[z] = V[z] - V[zo] (usually 0) and then take the limit as L -> ∞.  

 I give you some assumptions — more than you need — to help M take the Limit:

(*  INPUT CELL *)
$Assumptions = x ∈ Reals && -L/2 ≤ x≤ L/2 && z ∈ Reals && z > 0; L ∈ Reals && L >0 && (Subscript[z, o ])∈ Reals && zo > 0 &&Re[L]>0&&Im[L]==0;

(*  INPUT CELL *)
V[z ] (*  V[z], our original V, is (Subscript[V, finite])[z].  Just Checking to see that it is healthy *)

(*  INPUT CELL *)
Clear[zo]
(* We give zo a value below--we want to make sure M interprets zo as a variable here*)
V[zo] (* To show that we can substitute in any variable for z into V[z], e.g., zo *)

So set up and execute the Limit:

(*  INPUT CELL *)
(Subscript[V, infinite line charge])[z_] = Limit[V[z] - V[zo], L -> ∞]
(* This will be well behaved for 0 < z < ∞.  *)

Then letting k = (1/(4 π (Subscript[ϵ, o]))):

(*  INPUT CELL *)
(Subscript[V, infinite line charge])[z]/.k-> (1/(4 π (Subscript[ϵ, o])))

(Subscript[V, infinite line charge])[z] is exactly what we get from integrating the electric field z component, EEz[z] from zo to z. (This integral is proportional to the work done per unit charge to move that charge from zo (our zero of potential) to the point z.)  Note that both zo and z are on the z-axis) and NORMAL to the line charge.  

Let’s show that this integration works:  

Here is V using  (Subscript[(OverVector[EE]), infinite line charge])[z] = (λ/(2 π z (Subscript[ϵ, o])));  We write (Subscript[V, infinite line charge]) = -(∫_zo^z)(λ/(2 π zprime  (Subscript[ϵ, o])))dzprime where zprime is a dummy variable

(*  INPUT CELL *)
$Assumptions = z ∈ Reals && z > 0&& (Subscript[zo,  ])∈ Reals && zo >0 &&  z >zo && zprime ∈ Reals && zprime >0;
-(∫_zo^z)(λ/(2 π zprime  (Subscript[ϵ, o])))\[DifferentialD]zprime

Since - Log[(z/zo)] = Log[(zo/z)]  , we see that this V agrees with the expression we obtained above (which we labeled (Subscript[V, infinite ])[z] ).

BIG PUNCH LINE FOLLOWS:

Using this (Subscript[V, infinite line charge])[z] = ((λ Log[(zo/z)])/(2 π (Subscript[ϵ, o]))), we can regenerate (Subscript[(OverVector[EE]), infinite line charge])[z] (...you’re correct that this is circular) from (Subscript[V, infinite line charge])[z] by simply taking -Grad[(Subscript[V, infinite line charge])[z]]

(*  INPUT CELL *)
(Subscript[(OverVector[EE]), infinite line charge])[z_] = -Grad[((λ Log[(zo/z)])/(2 π (Subscript[ϵ, o]))),{x,y,z}]

As expected.

We therefore conclude that WITH  CARE (e.g., introducing a reference point z = zo, where V[zo] = 0 or a constant), we can derive from our finite line charge potential, (Subscript[V, finite line charge])[z], both (Subscript[V, infinite line charge])[z] and  (Subscript[(OverVector[E]), infinite line charge])[z] by taking the limit L -> ∞ .

	e.g., (Subscript[V, infinite line charge])[z_] = Limit[(Subscript[V, finite line charge])[z] - V[zo], L -> ∞]
	
	and
	
		(Subscript[(OverVector[E]), infinite line charge])[z] = Limit[(Subscript[(OverVector[E]), finite line charge])[z], L -> ∞]
	
	OR using the above (Subscript[V, infinite line charge])[z_]:    (Subscript[(OverVector[E]), infinite line charge])[z] = –Grad[(Subscript[V, infinite line charge])[z_], L -> ∞]
	
Beating the poor old dead horse:  (Subscript[V, infinite line charge])[z] is the potential we derived by introducing V[zo] = a constant  (e.g., = 0).

As a grand finale, I plot for you (for comparison) {Vfinite[z], Vinfinite[z]}  and {EEzfinite[z], EEzinfinite[z]}.  Just compare shapes.  To make a fair comparison of the potentials, I have shifted Vfinite[z] so that it also is zero at z = z0.  With this choice of reference potential, both Vfinite[z] and Vinfinite[z] will equal zero at z = zo.

(*  INPUT CELL *)
k = 1; λ = 1; L = 2; zo =12;
Plot[{V[z]-V[zo],(Subscript[V, infinite line charge])[z]},{z,0, 15},PlotRange-> {-5,15},PlotLegends->{"\!\(\*SubscriptBox[\(V\), \(finite\\ line\\ charge\)]\)[z]","\!\(\*SubscriptBox[\(V\), \(infinite\\ line\\ charge\)]\)[z]"}]

For z < 12 (our reference point), Vinfinite[z] appears to be greater than Vfinite[z].  Because the reference potential for Vinfinite[z] diverges as z -> 0, weird things can happen with Plot.  With the above choice of reference potentials, both potentials are negative for z > zo = 12.

(*  INPUT CELL *)
EEzfinite[z_] = -D[V[z],z]//Simplify;
Plot[{EEzfinite[z],EEzinfinite[z]},{z,0, 10},PlotRange-> {0,5},PlotLegends->{"(Subscript[EEz, finite])[z]","(Subscript[EEz, infinite])[z]"}]

We expect that for z >> L, the E-field for the finite line charge to fall as 1/z^2 (like a point charge), while the E-field for the infinite line charge should fall as 1/z.  The eye is not always good at detecting this kind of difference, but the different curvatures are apparent.  We expect the E-field due to the infinite line charge to be stronger than the E-field due to the finite line charge, which is certainly the case.  As one would expect on the basis of the potential curves above, the slope of EEzinfinite[z] is always more negative than the slope of EEzfinite[z] over this range of z values.