
This problem is an excellent illustration of the superposition principle of electrostatic. The basic idea is to understand that the electric field due to the sphere with a displaced cavity can be represented as the sum of electric fields due to a solid sphere of positive charge density

and another displaced sphere with negative charge density of

(the negative and positive charge densities cancel each other in the volume of the displaced sphere thus creating the displaced cavity).
Now let us compute the electric filed inside a uniformly charged sphere at a distance
r from the center. As in case of problems
3.25-3.27, we can compute this electric field using a Spherical Gaussian surface concentric with the original sphere. The total charge contained within the Gaussian surface will be,

Now using Gauss Law we can write,

Further, since the electric field vector will in a direction radially outwards
(2) can be written in vector notation as,


A point located at

will be at a location

as seen from the center of the sphere displaced such that its center lies at

with respect to the center of the original sphere. Consequently, the electric fields due to each of the spheres based on
(2a) will be,

Hence, the net electric field inside the cavity will be,
