# Average distance from a point in a ball to a point on its boundary

What variety of methods are readily available to find the average distance from a point in $\{ (x,y,z) : x^2+y^2+z^2 \le r^2 \}$ to the point $(0,0,r)$?

I just worked this out and got $6r/5$.

Later postscript:

I initially was going to do this in spherical coordinates. Someone told me he wanted a way that could be presented to students who don't know spherical coordinates. I've up-voted the answer posted below that uses spherical coordinates and I've added my own, which avoids them.

end of later postscript

There's an obvious way to write it as a triply iterated integral (then divide that by the volume of the sphere). The innermost integral ended up as that of $\sec^3\theta\,d\theta$ times a function of the two outer variables. I didn't pursue it beyond that.

I found a way to express it as $\dfrac{\int_0^{2a} u f(u)\,du}{\int_0^{2a} f(u)\,du}$ where the denominator ends up as the volume of a sphere. That that integral did in fact evaluate to $4\pi r^3/3$ told me I was probably doing this right. It didn't look to me like any argument for establishing the volume of a sphere that I'd ever seen before.

What methods would others use for this problem? Is there some argument from more-or-less intuitive geometry? Or from principles of physics? Or slick ways to evaluate integrals instead of brute force? (I confess I haven't even tried spherical coordinates on this yet.)

I'll post my own answer below later. Maybe. Now I've posted my answer.

• Based on what I wrote above, you can probably figure out what method I used, i.e. $f(u)=\text{what?}$ ${}\qquad{}$ – Michael Hardy Jul 22 '14 at 18:01
• The 'physics' route seems appropriate since that formula seems reminiscent of (for example) the expression for the moment of inertia. – Semiclassical Jul 22 '14 at 18:55
• @Semiclassical : The moment of inertia involves squares of distances, and those are easier to work with than distances. For example, suppose you want the point $P$ in the plane that minimizes $\sum_{k=1}^n d(P,Q_k)^2$ for given points $Q_1,\ldots,Q_n$. That's really easy to find. But try finding $P$ to minimize $\sum_{k=1}^n d(P,Q_k)$. Just trying finding, not just the point, but the minimum value. To make it easy, use $n=3$. It's a lot of work. – Michael Hardy Jul 22 '14 at 20:40
• True. About the only way I'd be willing to proceed in that case is with Lagrangian multipliers and that's not necessarily much more fun. (Though as noted in the answers below, the work for average distance in $\mathbb{R}^3$ isn't actually too bad to get by volume integration. $\mathbb{R}^4$, I don't know...) – Semiclassical Jul 22 '14 at 20:48

Wlog $r=1$. The average is independent of the direction of the special point, so take the average over all directions: the answer is the mean distance between a random point on a sphere and a random point inside it. That distance depends only on how far away the point is from the centre. To calculate the mean distance between a specific point inside and the sphere, split the sphere into thin wedges joined together at the axis on which the point lies; then the mean distance is independent of the wedge. For each wedge it is the same as the distance in the plane between $(a,0)$ and the upper half of the unit circle (parametrized by $t$), weighted by $\sin t$: $$\int_0^\pi \sqrt{(\cos t-a)^2+\sin^2t}\sin t\,dt = \frac23(3+a^2).$$

The answer is: $$\frac1{4\pi} \frac{1}{4\pi/3}\int_0^1da\, 4\pi a^2\times 2\pi\times\frac{2(3+a^2)}{3} = \frac65.$$

One may say of course that "WLOG" we may assume $r=1$. But leaving $r$ as just $r$ enables us to check that everything is dimensionally correct, i.e. an expression purporting to be a volume is homogeneous of degree $3$ in $r$ and one purporting to be a distance is homogeneous of degree $1$, and in fact we will need to find an area, so that should be homogeneous of degree $2$.

Of course, if one does the problem with $1$ instead of $r$, then one merely multiplies all expressions by $1$, $r$, $r^2$, or $r^3$ according as one is dealing with a dimensionless quantity (e.g. an Euler characteristic), a distance, an area, or a volume.

The above works fine if the shapes don't change. With a torus generated by revolving a circle of radius $1$ about an axis located $r$ units from the center of the circle, the shape changes as $r$ changes, and finding things like the slope of the bitangent plane to the torus can give you non-homogeneous functions of $r$.

So down to business:

Let $0\le u\le 2r$. Let $f(u)$ be the area of the surface \begin{align} \|(x,y,z)-(0,0,r)\| & = u, \\[4pt] \|(x,y,z)\| & \le r. \end{align} Then the sought average is $$\frac{\displaystyle\int_0^{2a} uf(u)\,du}{\displaystyle\int_0^{2a} f(u)\,du}, \tag 1$$ and if the denominator doesn't come to $\dfrac 4 3 \pi r^3$, you'll know there's a mistake.

So how do we find $f(u)$? I did that by realizing that it's a surface of revolution about the $z$-axis. That means finding an integral, so, in view of the fact that we then find integrals in $(1)$ above, this does come down to an iterated integral, but doubly rather than triply. The area is $$\int^{z\,:=\,\text{? ?}}_{z\,:=\,r-u} 2\pi x \sqrt{(dz)^2+(dx)^2}$$ where $x$ lies on a circle of radius $u$ centered at $(0,r)$ in the $xz$-plane. That means \begin{align} x^2+(z-r)^2 & = u^2, \tag 2 \\[6pt] \text{so that} \quad 2x\,dx + 2(z-r)\,dz & = 0. \tag 3 \end{align} Hence $$\sqrt{(dx)^2 + (dz)^2} = \sqrt{\frac{(z-r)^2}{x^2}\,(dz)^2 + (dz)^2} = \frac{u}{\sqrt{u^2-(z-r)^2}}\,dz = \frac u x \, dz$$ where the first equality follows from $(3)$ and the second from $(2)$. Now we have \begin{align} & \int^{z\,:=\,\text{? ?}}_{z\,:=\,r-u} 2\pi x \sqrt{(dz)^2+(dx)^2} \\[6pt] = {} & \int^{z\,:=\,\text{? ?}}_{z\,:=\,r-u} 2\pi x \frac u x \,dz \\[6pt] = {} & 2\pi u \int^{z\,:=\,\text{? ?}}_{z\,:=\,r-u} dz\qquad \text{(the Archimedes cancelation!)}. \tag 4 \end{align} Now the upper bound of integration: Do a bit of high-school geometry and you see that it is $r-(u^2/(2r))$. Hence $$[\text{the expression in }(4)] = 2\pi u\left( u - \frac{u^2}{2r} \right).$$ That, then, is $f(u)$.

Go back and evaluate $(1)$. The integrals are merely integrals of polynomials. You get $\dfrac{6r}5$.

• This seems like it mice generalize nicely to a sphere in $\mathbb{R}^d$ since the characterization as a surface of revolution should carry over nicely. – Semiclassical Jul 22 '14 at 22:02

The direct integration route isn't actually that bad, and obtains in fewer words the same triple integral computed by Kirill. We want to compute $\int_S dV \, |\hat{z}-\mathbf{r}|$ where $S$ is the sphere of radius $r$. By the law of cosines, we can write the separation as $$|\hat{z}-\mathbf{r}| = \sqrt{r^2-2r \rho \cos\theta+\rho^2}$$ where $\theta$ is the azimuthal angle to $\mathbf{r}$ and $\rho=|\mathbf{r}|$. This gives the iterated integral $$\int_S dV \, |\hat{z}-\mathbf{r}| = \int_{\rho=0}^r \int_{\phi=0}^{2\pi} \int_{\theta=0}^\pi d\rho \,d\phi \,d\theta\,\rho^2 \sin \theta \sqrt{r^2-2r \rho \cos\theta+\rho^2}.$$ But this is precisely the same integral performed by @Kirill in his answer.

• One dis-advantage of both calculations I should acknowledge is that neither seems suitable for working in $d>3$ dimensions. – Semiclassical Jul 22 '14 at 20:51