Electric Field of a Continuous Ring

In this worksheet you will examine the electric field due to a continuous ring of charge with radius R=1 and with linear charge density given by (λ/(4π ϵ))=1.

The electric field is given by an elliptic integral, which Mathematica cannot do in general.

(OverVector[E])=(∫_0^(2π))(((r cos(ϕ)-cos(ϕ'))(OverHat[x]) + (r sin(ϕ)-sin(ϕ'))(OverHat[y]) + z(OverHat[z]))/((((r^2)+1-2r cos(ϕ-ϕ')+(z^2)))^(3/2)))dϕ'

Clear[r,z,ϕ]

Set ϕ=0 for simplicity.

(Subscript[E, x])=Integrate[(r-Cos[ϕ'])/(r^2+1-2r Cos[ϕ']+z^2)^(3/2),{ϕ',0,2π},Assumptions->{r>0,z>0}]

(Subscript[E, y])=Integrate[Sin[ϕ']/(r^2+1-2r Cos[ϕ']+z^2)^(3/2),{ϕ',0,2π},Assumptions->{r>0,z>0}]

(Subscript[E, z])=Integrate[z/(r^2+1-2r Cos[ϕ']+z^2)^(3/2),{ϕ',0,2π},Assumptions->{r>0,z>0}]

(Subscript[E, x])=(r/z)(Subscript[E, z])-Integrate[Cos[ϕ']/(r^2+1-2r Cos[ϕ']+z^2)^(3/2),{ϕ',0,2π},Assumptions->{r>0,z>0}]

?EllipticE

?EllipticK

Mathematica can "do" the integral for particular values of the coordinates r and z (and with ϕ=0).

Integrate[(r-Cos[ϕ'])/(r^2+1-2r Cos[ϕ']+z^2)^(3/2)/.{r->4,z->2},{ϕ',0,2π},Assumptions->{r>0,z>0}]

N[%]

Integrate[z/(r^2+1-2r Cos[ϕ']+z^2)^(3/2)/.{r->4,z->2},{ϕ',0,2π}]

N[%]

It can also use this numerical evaluation to plot the potential, but this is a slow process.  How can we speed it up?  Let's exploit the symmetries of the problem.  Since the value of the potential is independent of ϕ, we do not need to plot it for all values of ϕ.  Instead, we can choose ϕ=0 and plot (OverVector[E]) in the r and z plane, alongside the potential V.

We therefore compute V=(∫_0^(2π))(1/(Sqrt[(r^2)+1-2r cos(ϕ')+(z^2)]))dϕ'  and
(OverVector[E])=(∫_0^(2π))(((r-cos(ϕ'))(OverHat[x]) - sin(ϕ')(OverHat[y]) + z(OverHat[z]))/((((r^2)+1-2r cos(ϕ')+(z^2)))^(3/2)))dϕ'  
noting that the (OverHat[y]) component was shown above to be 0.

Clear[r,ϕ,z]
V=Integrate[1/Sqrt[r^2+1-2r Cos[ϕ']+z^2],{ϕ',0,2π}];

Plot3D[V,{r,0,3},{z,-1,1},AxesLabel->{r,z}, ColorFunction-> Hue,ViewPoint->{0,0,Infinity},MeshFunctions->{#3 &}]

vplot=ContourPlot[V,{r,0,3},{z,-1,1},Contours->10]

Kluge to help Mathematica evaluate?

Ex[rr_,zz_]:=Evaluate[(Subscript[E, x])/.{r->rr,z->zz}];
Ez[rr_,zz_]:=Evaluate[(Subscript[E, z])/.{r->rr,z->zz}];

Eplot=VectorPlot[{Ex[r,z],Ez[r,z]},{r,0,3},{z,-1,1},VectorScale->0.4,VectorStyle->Red,PlotRange->{{0,3},{-1,1}}]

Show[vplot,Eplot]

by Tevian Dray