What is the average length of 2 points on a circle, with generalizations

I have earlier seen the question about finding the average length of two points and $n$ points inside the unit disk. But what about the more simple question, what happens if the points lie exactly on the circle?

I did some basic algebra, assume that the radius of the circle is $r$. without loss of generalization we can fix the point $x_1(-a,0)$ and then vary $x_2$ over all the possibilities $$P_2(2) = \frac{2 \int_{-a}^{a} \sqrt{2r(r+x)\,}\,}{2 \pi r^2} = \frac{16}{3\pi}$$ I also tested the results through matlab, generating $10^9$ points, and measuring the avreage distance. My results for a unit circle was $$D \approx 1.1864$$ Which unfortunately did not yield any result wheter in Wolfram, OEIS, or a inverse symbolic generator. This contradicts my arithmetic, meaning I should be wrong. The code snippet can be found below, nothing terribly exciting.

a = 1;
N = 10^8;

x1= a.*(2*rand(N,1)-1);
y1 = a.*(2*rand(N,1)-1);

x2= -a;
y2 = 0;

P = mean(sqrt((y2-y1).^2 + (x2-x1).^2));


What is the correct answer to $P_2(2)$ (average distance of two points on a circle)? Can one make any generalizations to $P_n(2)$ (average distance of two points on the the $n$-dimensional sphere? What about $P_n(m)$ or $P_2(m)$ ? Where $n$ is the dimension of the sphere, and $m$ is the number of points.

• Puzzling calculation, if the radius is $r$ the answer will be a constant times $r$. So we can take the radius to be $1$. There are several ways to choose the second point "at random," which need not give the same answer. The most natural (?) is to choose the angle uniformly distributed. – André Nicolas Dec 18 '13 at 15:14
• @AxelKemper: It is (here) early in the morning, pre-coffee. But with angle uniformly distributed, I do not see an elliptic integral, get $\frac{4}{\pi}$. But OP chooses "$x$" uniformly distributed. – André Nicolas Dec 18 '13 at 15:45

I don't know how you arrived at your formula for "$P_2(2)$", whatever is meant by this.

At any rate you may assume your circle of radius $1$, the first point $z_1$ as $(1,0)$ and the second point $z_2$ as $(\cos\phi,\sin\phi)$ with $\phi$ equidistributed on $[0,\pi]$. Then $|z_2-z_1|=2\sin{\phi\over2}$ and therefore $${\mathbb E}\bigl[|z_1-z_2|\bigr]={1\over\pi}\int_0^\pi 2\sin{\phi\over2}\ d\phi={4\over\pi}\doteq1.273\ .$$

Your Matlab code generates points in a square, not on a circle. You should change it into something like this:

a = 1;
N = 10^8;

theta = 2*pi*rand(N,1);
x1 = a.*cos(theta);
y1 = a.*sin(theta);

x2 = -a;
y2 = 0;

P = mean(sqrt((y2-y1).^2 + (x2-x1).^2));


This gives about 1.274, which doesn't agree with 16/3/pi.