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).
 A: 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}$$
A: 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.$$
A: 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.
