# What is the value of $\frac{1}{2}\int_B\int_B\frac{\rho(x,y,z)\rho(x',y',z')}{4\pi\epsilon_0\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}dxdydzdx'dy'dz'$?

Suppose $$R$$ is a positive real number.
Suppose $$Q$$ is a positive real number.
Let $$B:=\{(x,y,z)\in\mathbb{R}^3:\sqrt{x^2+y^2+z^2}\leq R\}$$.
Let $$\rho(x,y,z):=\frac{Q}{\frac{4}{3}\pi R^3}$$ if $$(x,y,z)\in B$$ and $$\rho(x,y,z):=0$$ if $$(x,y,z)\notin B$$.
What is the value of $$U:=\frac{1}{2}\int_B\int_B\frac{\rho(x,y,z)\rho(x',y',z')}{4\pi\epsilon_0\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}dxdydzdx'dy'dz'$$ ?

The author calculated $$U=\frac{3Q^2}{20\pi\epsilon_0 R}$$.
The author calculated this value using the concept of potential, Gauss's law, etc..
I want to know how to calculate $$U$$ mathematically.

Changing to spherical coordinates, we have

$$\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}=\sqrt{r^2+r'^2-2\vec r\cdot\vec r' }$$

where $$\vec r\cdot\vec r'=rr'(\sin(\theta)\sin(\theta')\cos(\phi-\phi')+\cos(\theta)\cos(\theta'))=rr'\cos(\gamma)$$, where $$\gamma$$ is the angle between $$\vec r$$ and $$\vec r'$$.

Then, we can write

\begin{align} I&=\int_B\int_B \frac{\rho(x,y,z)\rho(x',y',z')}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}\,dx\,dy\,dz\,dx'\,dy'\,dz'\\\\ &=\int_0^{2\pi}\int_0^\pi\int_0^R \int_0^{2\pi}\int_0^\pi\int_0^R \frac{(Q/4\pi R^3/3)^2}{\sqrt{r^2+r'^2-2\vec r\cdot\vec r'}}\,r^2r'^2\,\sin(\theta)\sin(\theta')\,dr\,dr'\,d\theta\,d\theta'\,d\phi\,d\phi'\\\\ &=\int_0^{2\pi}\int_0^\pi\int_0^R \int_0^{2\pi}\int_0^\pi\int_0^R \frac{(Q/4\pi R^3/3)^2}{\sqrt{r^2+r'^2-2rr'\cos\gamma}}\,r^2r'^2\,\sin(\theta)\sin(\gamma)\,dr\,dr'\,d\theta\,d\gamma\,d\phi\,d\phi'\\\\ &=\frac{18Q^2}{R^6}\int_0^R\int_0^R rr' \left(r+r'-|r-r'|\right)\,dr'\,dr\\\\ &=\frac{18Q^2}{R^6}\int_0^R (R^2r^2-r^4/3)\,dr\\\\ &=\frac{18Q^2}{R^6} \frac{12}{45}R^5\\\\ &=\frac{24Q^2}{5R^5} \end{align}

Finally, dividing by $$8\pi \varepsilon_0$$ recovers the reported result as was to be shown!

• Mark Viola, Thank you very much for your answer! Jul 24, 2023 at 1:13
• @tchappyha You're welcome. My pleasure. Jul 24, 2023 at 19:34