Say I have a sphere of radius $R$, I would like to know the average distance between a point $M$ inside the ball and the sphere of radius $R$.
Because of the spherical symmetry, we can say without loss of generality that my point $M$ inside the ball is defined by the coordinates: $$ (x=r,y=0,z=0) $$, and the points on the sphere are defined by the coordinates: $$(x=R\cos(\phi)\cos(\theta),y=R\cos(\phi)\sin(\theta),z=R\cos(\theta))$$ then the average distance is :
\begin{equation} d = \frac{1}{4 \pi} \int_0^{\pi} \int_0^{2\pi} \sqrt{ (R \cdot \cos(\phi) \cdot \cos(\theta)-r)^2 + (R \cdot \cos(\phi) \cdot \sin(\theta) )^2 + ( R \cdot \sin(\theta) )^2 } \cdot \sin(\theta) d\theta d\phi \end{equation}
\begin{equation} d = \frac{1}{4 \pi } \int_0^{\pi} \int_0^{2\pi} \sqrt{ R^2 + r^2 - 2 R r \cos(\theta)\cos(\phi) } \sin(\theta) d\theta d\phi \end{equation}
does someone know how to solve this integral?
I computed it numerically (the mean distance between a point inside a ball and the surface) and the result should be: $$ d = \frac{r^2}{3R}+R $$
Thank you
It is best to choose point $M$ on the z-axis to best take advantage of spherical symmetry. Hence,
$$M(0, 0, r)$$
This is incorrect. The coordinate on the sphere should be
$$x=R\sin(\theta)\cos(\phi),y=R\sin(\theta)\sin(\phi),z=R\cos(\theta)$$
Your integral limits for $\theta$ and $\phi$ are reversed. As said above, if you set point $M$ on z-axis, then you will get the integral as
$$d = \frac{1}{4 \pi } \int_0^{2\pi} \int_0^{\pi} \sqrt{ R^2 + r^2 - 2 R r \cos(\theta) } \sin(\theta) d\theta d\phi$$
Do substitution, $u=\cos\theta$, then you get,
$$d = \frac{1}{2} \int_{-1}^1 \sqrt{ R^2 + r^2 - 2 R r u } ~du=\color{red}{\frac{r^2}{3R}+R}$$