Gauss's law states that the electric flux through any closed surface equals the net charge enclosed within the surface. This law is beneficial for determining the expressions for the electric field for a particular charge distribution if the electric flux is known.
Consider a non-uniformly charged sphere, for which the density of charge depends only on the distance from a point in space and not on the direction. Such a sphere has a spherically symmetrical charge distribution. Here, the electric field at any point is radially directed because of the charge; hence, the field is invariant under rotation. The electric field at point P at a distance r from the center of a spherically symmetrical charge distribution is given by,
To determine the electric field inside and outside the non-uniformly charged sphere, first, the charge enclosed within an infinitesimal shell is determined. The charge enclosed in such a shell is the product of the charge density and volume of the shell. The entire sphere can be considered to be made up of combinations of these shells.
A Gaussian surface with the same symmetry as the charge distribution is considered to find the electric field for a point outside the sphere. The Gaussian surface's radius equals the distance to the field point. The net charge inside the Gaussian surface is then calculated by integrating the charge enclosed in the shell over the entire charge distribution. Here, since the observation point is outside the charge distribution, the region between the sphere and the Gaussian surface has no charge and does not contribute to the net charge. The obtained value of the net charge is substituted into the electric field equation to obtain the electric field outside the sphere, which is given by,
If the point of observation lies within the sphere, the Gaussian surface lies within the sphere, and hence, the net charge enclosed in it contributes to the electric field. The electric field at a point inside the non-uniformly charged sphere is given by,