Electric field of a nonconducting sphere with a spherical cavity

Question: A sphere of radius a is made of a nonconducting material that has a uniform volume charge density \rho. A spherical cavity of radius b is removed from sphere which is a distance z from the center of the sphere. Assume that a > z + b. What is the electric field in the cavity?

Answer: The electric field inside the cavity is going to be the superposition of the field due to the uncut sphere plus the field due to a sphere the size of the cavity with a uniform charge density of -\rho. The key to solve this problem is to calculate the electric field of each sphere in a different coordinate systems.

First, lets deal with the electric field of the large sphere of charge density \rho. To simplify Gauss’s Law, I am going to use a spherical coordinate system with the origin at the center of the sphere. The coordinate system is going to defined as:

\vec{r} = x \hat{i} + y \hat{j} + z \hat{k} = r \hat{r}

We can now use Gauss’s Law to calculate the electric field of the sphere.

\oint {\vec{E} \cdot dA = } \frac{1}{{\varepsilon _0 }}Q_{inside}

\oint {E dA = } \frac{1}{{\varepsilon _0 }}  \frac{4}{3}\pi r^{3}\rho

E 4 \pi r^{2} =  \frac{1}{{\varepsilon _0 }}  \frac{4}{3}\pi r^{3}\rho

E  =  \frac{\rho}{{3 \varepsilon _0 }}  r

Since the electric field is radial:

\vec{E}  =  \frac{\rho}{{3 \varepsilon _0 }}  r \hat{r}

Now that we have calculated the electric field for the big sphere, we can calculate the field of the small sphere of charge density -\rho. We will, again, use a spherical coordinate system with the origin at the center of the sphere. The coordinate system is going to defined as:

\vec{r^{\prime}} = x^{\prime} \hat{i}^{\prime} + y^{\prime} \hat{j}^{\prime} + z^{\prime} \hat{k}^{\prime} = r^{\prime} \hat{r}^{\prime}

When we apply Gauss’s Law to the small sphere, we will get \vec{E^{\prime}}  =  \frac{-\rho}{{3 \varepsilon _0 }}  r^{\prime} \hat{r^{\prime}}

Next we need to take the superposition of both the electric fields. In order to do so, we will need to relate the follow coordinate systems.


Using simple vector addition, we find that \vec{r^{\prime}} + z \hat{j} = \vec{r}. Also because \vec{r} = r \hat{r}, we can reduce this formula to: r^{\prime} \hat{r}^{\prime} = r \hat{r} -z \hat{j}

Summing the electric field of the two spheres we will get:

\vec{E} = \frac{\rho}{{3 \varepsilon _0 }}  r \hat{r} -\frac{\rho}{{3 \varepsilon _0 }}  r^{\prime} \hat{r^{\prime}}

\vec{E} = \frac{\rho}{{3 \varepsilon _0 }}  r \hat{r} -\frac{\rho}{{3 \varepsilon _0 }}  (r \hat{r} -z \hat{j})

\vec{E} =  \frac{\rho}{{3 \varepsilon _0 }} z \hat{j}