# What's the electric field in a sphere with charge $Q$ and an inverse linear/square law density of charge?

In Classical Electrodynamics by Jackson problem 1.4 asks to find the electric field as a function of the radius of a sphere charged with a charge Q and with a spherically symmetric density that goes as $$r^n$$ with $$n > -3$$.

I found the expression of $$\rho$$ by normalizing it to the total charge Q. I can calculate the electric field via Gauss law when $$n \geq 0$$ but in the other cases the integral of $$\rho$$ diverges. I was thinking of trying to exclude the singularity by excluding a sphere of radius $$\epsilon$$ and then making epsilon go to zero but not sure.

As you write, the expression for the charge density can be found by considering that the total charge within the sphere is $$Q$$. Indeed, if we define $$\rho(r) = A r^n$$ we have

$$Q = 4 \pi A \int_0^{R_s} r^n r^2 dr = 4 \pi A \int_0^{R_s} r^{n+2} dr$$

where $$R_s$$ is the radius of the sphere.

The Gauss law in this case takes the form

$$4 \pi R^2 E(R) = \frac{4 \pi}{\epsilon_0} \int_0^R \rho(r) r^2 dr$$

from which we get

$$E(R) = \frac{1}{\epsilon_0 R^2} \int_0^R \rho(r) r^2 dr = \frac{A}{\epsilon_0 R^2} \int_0^R r^{n+2} dr$$

The integral on the right-hand side diverges only for $$n \leq -3$$, which is not a issue given the text of the problem to solve.

For instance, if $$\rho(r) = A r^{-2}$$ we obtain

$$E(R) = \frac{A}{\epsilon_0 R}$$

whereas if $$\rho(r) = A r^{-1}$$ the field is

$$E(R) = \frac{A}{2 \epsilon_0}$$