# What is the average distance between two points on the perimeter of a rectangle?

Was just wondering, no special reason.

Someone asked the corresponding question about a square, so this question is a generalization of that question: What is the average distance of two points chosen uniformly on a unit square?

• Uniformly distributed along the perimeter, I assume? – Frpzzd Nov 13 '18 at 0:45
• With aid of Mathematica, the average distance between two independent points chosen unformly at random from the perimeter of a unit square is $$\frac{1}{12} \left(3+\sqrt{2}+5 \operatorname{arcsinh}(1)\right) \approx 0.73509012478923418125\cdots$$ – Sangchul Lee Nov 13 '18 at 0:59

I will show you how to do it with integrals, but I'll leave it up to you to evaluate the integrals.

Suppose the rectangle has length $$l$$ and width $$w$$, and that points $$X$$ and $$Y$$ are chosen uniformly along its perimeter. We have a total of $$5$$ cases:

• Both points are on the same side of length $$l$$, with probability $$p_1$$
• Both points are on different sides of length $$l$$, with probability $$p_2$$
• Both points are on the same side of length $$w$$, with probability $$p_3$$
• Both points are on different sides of length $$w$$, with probability $$p_4$$
• One point is on a side of length $$l$$ and one is on a side of length $$w$$, with probability $$p_5$$

Consider the first case. If $$x,y$$ are the respective distances of $$X$$ and $$Y$$ from a given vertex of the side they are on, then their distance is $$|x-y|$$, and so the average distance is $$I_1=\frac{1}{l^2}\iint_{[0,l]^2} |x-y|dxdy$$ Then consider the second case. Let $$x,y$$ be the respective distances of $$X$$ and $$Y$$ from a given side of length $$w$$ of the rectangle. Then the distance between $$x$$ and $$y$$ is given by $$\sqrt{(x-y)^2+w^2}$$, and so the integral for their average distance is $$I_2=\frac{1}{l^2}\iint_{[0,l]^2} \sqrt{(x-y)^2+w^2}dxdy$$ Because the sides of length $$l$$ and those of length $$w$$ are indistinguishable in the context of the problem, the respective averages for case 3 and case 4 are analogously $$I_3=\frac{1}{w^2}\iint_{[0,w]^2} |x-y|dxdy$$ $$I_4=\frac{1}{w^2}\iint_{[0,w]^2} \sqrt{(x-y)^2+l^2}dxdy$$ Finally, for the fifth case, let $$x$$ and $$y$$ be the respective distances of $$X$$ and $$Y$$ from the vertex in common between their sides. Then, by the pythagorean theorem, the distance between them is $$\sqrt{x^2+y^2}$$, so the integral is $$I_5=\frac{1}{lw}\int_0^l \int_0^w \sqrt{x^2+y^2}dxdy$$ Now, the expected distance is simply $$p_1 I_1+p_2I_2+p_3I_3+p_4I_4+p_5I_5$$ and so I'll leave it up to you to compute the integrals and the probabilities $$p_i.$$