Say you have a solid sphere of radius R and of charge density $\rho(\vec{r})=\vec{r}\cdot \hat{z}$, then what is the electric field at the centre of the sphere.
My Attempt :
Now the standard method here would be to break it up into a simpler problem by first taking a hollow sphere of this charge distribution and find its electric field at the center and then integrate it to get the result for the solid sphere but I wanted to do it through a single triple integral as follows :
Take a volume element $d\tau = r^2\sin(\theta)dr d\theta d\phi$ in the sphere whose charge density will be $\rho(\vec{r})=r\cos(\theta)$. Now the electric field due to this volume charge at a distance say $z$ from the centre on the $z$-axis of the sphere will be
(taking a slight assumption that the electric field vector will be along z-axis due to symmetricity)
$$\vec{dE} = \frac{1}{4\pi\epsilon_{0}}\frac{\rho}{(\sqrt{z^2+r^2-2zr\cos(\theta)})^2}\frac{(\vec{z}-\vec{r})\cdot\vec{z}}{|\vec{z}-\vec{r}||\vec{z}|}\hat{z}d\tau$$ $$ \vec{dE}= \frac{1}{4\pi\epsilon_{0}}\cdot \frac{r\cos(\theta)}{z^2+r^2-2zr\cos(\theta)}\cdot\frac{z-r\cos(\theta)}{\sqrt{z^2+r^2-2zr\cos\theta}} \hat{z}\cdot r^2\sin(\theta)dr d\theta d\phi$$
$$\vec{E} = \frac{\hat{z}}{2\epsilon_{0}}\int_{0}^{\pi}\int_{0}^{R}\frac{r^3\sin(\theta)\cos(\theta)(z-r\cos(\theta))}{(z^2+r^2-2zr\cos(\theta))^{\frac{3}{2}}}drd\theta$$
Now how to calculate this integral, any ideas?
the integral is solvable and here is my method
take $u = z^2+r^2-2zr\cos(\theta) \implies du = 2zr\sin(\theta)d\theta $
so the $\theta$ integral converts to
$$-\frac{r}{8z^3}\int_{(R-z)^2}^{(R+z)^2} \frac{u^2-2ur^2+r^4-z^4}{u^{\frac{3}{2}}}du$$
which simplifies for $z-R<0$ to $$-\frac{2r}{3}$$
which perfectly gives us the answer to be
$$\vec{E} = -\frac{R^2}{6\epsilon_{0}}\hat{z}$$
Interestingly enough the vector $\vec{E}$ came out to be independent of $z$ after all.
Best Answer
Congrats on getting the right answer! Let me present the calculation in a way you might find useful: Coulomb's law tells us the electric field is
$$ \vec{E}=\frac{1}{4\pi\epsilon_0}\int d^3\vec{r}'\,\rho(\vec{r}')\,\frac{\vec{r}-\vec{r}'}{|\vec{r}-\vec{r}'|^3} $$
where $\vec{r}=0$ is the observation point; i.e. the centre of the sphere. And as you noted, $\rho(\vec{r}')=r'\cos\theta'$ is the charge density in spherical coordinates. Thus
$$ \vec{E}_0=-\frac{1}{4\pi\epsilon_0}\int d^3\vec{r}\,\rho(\vec{r}')\,\frac{\hat{r}'}{r'^2} $$
where $\vec{E}_0$ denotes the field at the centre, and
$$ \hat{r}' =\cos\phi'\sin\theta'\hat{x} +\sin\phi'\sin\theta'\hat{y} +\cos\theta'\hat{z} $$
is the spherical unit vector. Since $\rho$ is independent of $\phi'$, there will be no contribution to $\vec{E}_0$ from the $\hat{x},\hat{y}$ components of $\hat{r}'$. This is because
$$ \int_0^{2\pi}d\phi'\sin\phi' =\int_0^{2\pi}d\phi'\cos\phi' =0 $$
Hence $\vec{E}_0$ is oriented in the $\hat{z}$ direction only, and the integral becomes
$$ \vec{E}_0=-\frac{\hat{z}}{4\pi\epsilon_0} \underbrace{\int_0^Rr'dr'}_{\frac{R^2}{2}} \underbrace{\int_0^{\pi}d\theta'\sin\theta'\cos^2\theta'}_{\frac23} \underbrace{\int_0^{2\pi}d\phi'}_{2\pi} $$
or
$$ \vec{E}_0=-\frac{R^2\hat{z}}{6\epsilon_0} $$