using the expression for the divergence in cylindrical coordinates.
Second, we may use Gauss's law for the cylinder:
Here
the surface integral for flux goes over the surface enclosing the
cylinder: that is, the surface including a cylindrical shell at s =
S (with normal
), a top circle at z=h (with normal
), and a bottom circle at z = -h (with normal
). Since
points radially outward (the
direction), the only part of the surface with nonzero
is the cylindrical shell, where
and the surface's normal vector align. Note that this surface is at
constant s, so
is constant over the surface, and may be
factored out of the integral. Thus Gauss' law gives
using the surface area for the cylinder (easily integrated, noting that
.) Plugging in the given
gives
in agreement with the direct integration above.
using the fact that
depends only on r and so is constant over the surface and can be factored out of the integral, and that the surface area of a sphere is
. We then set this equal to the charge enclosed
divided by
. For
,
is constant within the sphere, so
where we've used the fact that the volume of the sphere of radius r is
.
This gives
For
,
vanishes once r exceeds R so the volume integrand extends only to r=R, giving the volume of the charged sphere (alternately, precisely the full charge Q is enclosed). Thus
and
Note this is the expected result for the electric field outside a charge, and links continuously to the electric field value inside the charged sphere.
Since the electric field is radial, only radial elements of the path length contribute, giving
Here we just use our values for
above. For
,
as expected outside a charge. For
, this gives
which again links continuously to the value of V outside the sphere. We check that the gradient of V gives
:
exactly in agreement with problem 5. I leave the plotting of V to the reader.