I'm trying to calculate the Electric Field over a thick spherical sphere with charge density $\rho = \frac{k}{r^2}$ for $a < r < b$, where $a$ is the radius of the inner surface and $b$ the radius of the outer surface.
From Gauss's Law I've got it to be $\vec{E} = \frac{k}{\epsilon_0}\frac{r-a}{r^2}$. But also tried to integrate the charge over the surface and I was hoping to get the same result but didn't. My attempt was, in spherical coordinates:
$$ \begin{equation} \begin{aligned} \vec{E} &= \frac{1}{4 \pi \epsilon_0}\int_a^r \int_0^\pi \int_0^{2\pi} \frac{\rho r^2 \sin \phi}{r^2} d\theta d\phi dr \vec{e_r}\\ &= \frac{1}{4 \pi \epsilon_0}\int_a^r \int_0^\pi \int_0^{2\pi} \frac{k \sin \phi}{r^2} d\theta d\phi dr \vec{e_r}\\ \\ &= -\frac{k}{\epsilon_0}(\frac{1}{r} - \frac{1}{a})\\ &= \frac{k}{\epsilon}\frac{r-a}{ra}\vec{e_r} \end{aligned} \end{equation} $$
Which are not the same. But they should be! I know that my Gauss method gave me the right expression, but I can't figure out why the integral method didn't.