# Is there a simple formula for this simple question about a circle?

What is the average distance of the points within a circle of radius $r$ from a point a distance $d$ from the centre of the circle (with $d>r$, though a general solution without this constraint would be nice)?

The question arose as an operational research simplification of a real problem in telecoms networks and is easy to approximate for any particular case. But several of my colleagues thought that such a simple problem should have a simple formula as the solution, but our combined brains never found one despite titanic effort. It looks like it might involve calculus.

I'm interested in both how to approach the problem, but also a final algebraic solution that could be used in a spreadsheet (that is, I don't want to have to integrate anything).

-
Perhaps not simple; but, taking the center of the circle $C$ (with interior) to be the origin and the point to be $(a,b)$ it's ${1\over \pi r^2}\int\kern-2pt\int_C \sqrt{(x-a)^2 +(y-b)^2 }\,dx\,dy$. –  David Mitra Jan 11 '12 at 18:09
@DavidMitra I may need to clarify what I mean by formula. This is useful but only a halfway house if you need to use it in a spreadsheet. Is there a simple algebraic solution? –  matt_black Jan 11 '12 at 18:13
Perhaps it will simply things a bit to note that WLOG we can take the point to be $(d,0)$. –  Zev Chonoles Jan 11 '12 at 18:13
You would think there is a simple expression for the perimiter of an ellipse, but there isn't one. Again it falls into elliptic integrals category as is your question. –  ja72 Jan 12 '12 at 2:26

I guess it involves calculus. Let $(x,y)$ be a point within the circle of radius $R$ and $(d,0)$ the coordinates of the point a distance $d$ away from the origin (because of the symmetry we can choose it to lie on the $x$-axis). Then the distance between the two points is given by $$\ell = \sqrt{(x-d)^2 + y^2}.$$

Averaging over the circle is best done in polar coordinates with $x=r \cos \phi$ and $y=r \sin\phi$. We have \begin{align} \langle \ell \rangle &= \frac{1}{\pi R^2} \int_0^R dr \int_0^{2\pi} d\phi\, r \sqrt{(r\cos \phi -d)^2 + r^2\sin^2 \phi}\\ &= \frac{1}{\pi R^2} \int_0^R dr \int_0^{2\pi} d\phi\, r \sqrt{r^2 + d^2 -2 d r\cos\phi}. \end{align}

I am not sure it the integral has a simple analytic solution. Thus, I calculate it in three simple limits.

(a) $d\gg R$: we can expand the $\sqrt{}$ and have $$\langle \ell \rangle = \frac{1}{\pi R^2} \int_0^R dr \int_0^{2\pi} d\phi\, [r d- r^2 \cos \phi + \frac{r^3}{2d} \sin^2 \phi] = d + \frac{R^2}{8d}$$

(b) for $d \approx R$, we have $$\langle \ell \rangle = \frac{1}{\pi R^2} \int_0^R dr \int_0^{2\pi} d\phi\, r^2 \sqrt{2 (1-\cos \phi)} = \frac{8 R}{3\pi}$$

(c) for $d\ll R$ [joriki's comment] $$\langle \ell \rangle = \frac{1}{\pi R^2} \int_0^R dr \int_0^{2\pi} d\phi\, \left[r^2 -rd\cos\phi + \frac{d^2}{2} \cos^2\phi\right] = \frac{2 R}{3} + \frac{d^2}{2R}$$

-
This is also valid for $d\lt R$, and for $d\ll R$ we can again expand the root to obtain $$\langle\ell\rangle\approx\frac{1}{\pi R^2} \int_0^R\mathrm dr \int_0^{2\pi}\mathrm d\phi\left(r^2+\frac{d^2}2\sin^2\phi\right)=\frac{2R}3+\frac{d^2}{2R}\;.$$ (The error we make in using the expansion where $r\not\gg d$ is only quartic in $d$.) It's interesting to compare these three results. –  joriki Jan 11 '12 at 19:02
Sorry, I'd temporarily removed the comment because I suddenly worried that using the expansion where it's not valid might invalidate the result. –  joriki Jan 11 '12 at 19:13
@joriki: np. The exact result is a function of only $R/d$, i.e., $\langle \ell \rangle = R f(d/R)$. It would be nice to see how well the function is approximated by the approximate results. (If I have time I will do it some time) –  Fabian Jan 11 '12 at 19:20
Yes, I tried to include that in the comparison plot, but unfortunately Wolfram|Alpha tends to get confused when too many operations are nested... The plots are all for $R=1$ so they show approximations to $f(d)$. –  joriki Jan 11 '12 at 19:37
At the very least, the inner integral with respect to $\phi$ is expressible in terms of the complete elliptic integral of the second kind. Integrating that expression with respect to $r$, however, results in a bit of a mess... –  Guess who it is. Jan 12 '12 at 0:36

This solution definitely seems to have problem(s), but perhaps even though it's wrong, it'll help get someone to a complete/correct solution.

First, suppose that the point is outside the circle. For each secant from the point through the circle, the distance from the given point to the midpoint of the part of the secant that is inside the circle is equal to the average of the distances to all of the points in the circle through which that secant passes. The locus of these midpoints is an arc of the circle that has a diameter with endpoints at the given point and the center of the given circle.

If we place the given point at the origin and the center of the given circle at $d$ on the positive horizontal axis, the locus of points described above has polar equation $r=\frac{d}{2}\cos\theta$ for $-\arcsin\frac{r}{d}\le\theta\le\arcsin\frac{r}{d}$. For each $\theta$, the length of the line segment on the secant and inside the circle is $2\sqrt{r^2-d^2\sin^2\theta}$.

So, the average distance should be: $$\frac{1}{2\arcsin\frac{r}{d}}\int_{-\arcsin\frac{r}{d}}^{\arcsin\frac{r}{d}}\left(2\sqrt{r^2-d^2\sin^2\theta}\cdot\frac{d}{2}\cos\theta\right)d\theta,$$ which I let Mathematica work on for a bit and it's telling me is 0, so I probably screwed something up.

Now, if the point is inside the circle, then we have the entirety of the circle with diameter with endpoints at the given point and the center of the circle. Placing the given point and the circle as above, the locus-circle has the same equation, $r=\frac{d}{2}\cos\theta$, the length of the secant line segments inside the circle (now just chords) is the same $2\sqrt{r^2-d^2\sin^2\theta}$, but the limits of integration change to encompass the whole circle: $$\frac{1}{\pi}\int_{-\frac{\pi}{2}}^{\frac{\pi}{2}}\left(2\sqrt{r^2-d^2\sin^2\theta}\cdot\frac{d}{2}\cos\theta\right)d\theta.$$

-

By scaling, we may assume $d=1$. Note that $J(r) = \int_0^{2\pi} \sqrt{1-2r\cos(\theta) + r^2}\ d\theta$ is an elliptic integral, in Maple's notation $4 (1+r) \text{EllipticE}\left(\frac{2\sqrt{r}}{1+r}\right)$. Now you want $\frac{1}{\pi R^2} \int_0^R r J(r)\ dr$. It appears that for $0 < R < 1$ this can be written using a hypergeometric function as $(1-R^2)^3 {}_2F_1(5/2,5/2; 2; R^2)$. For $R > 1$ I think you have to take the real part of that.

-
I'll only note that Gaussian hypergeometric functions with half-integer parameters can be expressed in terms of complete elliptic integrals. –  Guess who it is. Jan 12 '12 at 0:29
Yes. In this case you can write it as $\frac{4}{9 \pi R^2} \left((7R^2+1) \text{EllipticE}(R) + (3 R^4 - 2 R^2 - 1) \text{EllipticK}(R)\right)$. Again, for $R > 1$ take the real part. –  Robert Israel Jan 12 '12 at 1:00