Two points of a square $K$ determine a diagonal of another square that is contained in $K$

contest-mathgeometric-probabilityprobabilityrecreational-mathematics

Let $K:=[0,1]^2$ be a square on $\mathbb{R}^{2}$. We select 2 random points $A$, $B$ $\in [0,1]^{2}$ in this square. What is the probability that the square whose diagonal is the line segment $AB$, is contained in $K$?

I found that if we fix coordinates of $A=(x,y)\in [0,1]^{2}$, then the probability equals $$\int\limits_{0}^{1}\int\limits_{0}^{1}[1-(x-y)^{2}-(1-x-y)^{2}\times\textbf{1}(x+y<1)]dxdy \, ,$$
where: $\textbf{1}(x+y<1):=1$ if $x+y<1$ and $\textbf{1}(x+y<1):=0$ otherwise.

Some attempts(or some elements of stream of consciousness)

I tackled other problems from geometric probability, but this problem cannot be solved by standard methods(i.e. by finding dependency between given information in question, then making, at least, rough plot on cartesian coordinate system and integrate the area under the graph of detected dependencies within specific constraints). I have completely, even intuitively, idea how to come towards such solution.

The only thing, which comes to my mind, is that in this problem we should consider complement of given event, i.e. set of these points that determine square not contained completely in the square $K$. This may account for minus signs. So, presumably, the probability that we choose inapropriately is $$\int\limits_{0}^{1}\int\limits_{0}^{1}[(x-y)^{2} + (1-x-y)^{2}\times\textbf{1}(x+y<1)] dxdy $$

However, this is just intuition after solving hitherto plenty of problems from, let say, "elementary" probability…

Motivation for knowing method of solving this problem

I am very interested in getting to know how to derive quite rigorously solution to this problem. I would be very thankful for help.

Note: this question is neither from any current mathematical contest nor a part of any "homework"/"coursework".

Best Answer

This sort of problem is most efficiently solved by considering, instead of the two points, their midpoint and their displacement from the midpoint. By symmetry, we can restrict the midpoint to one of the eight octants of the square without loss of generality, say, to $0\le x\le y\le\frac12$. Then the constraint restricts the points to a square of side length $2x$ centred on the midpoint, whereas without the constraint they would be restricted to a rectangle of side lengths $2x$ and $2y$ centred on the midpoint.

Instead of working out the Jacobian and the factors of $2$, we can just form the ratio of the integrals with and without the constraint. We have

$$ \int_0^\frac12\mathrm dy\int_0^y\mathrm dxx^2=\frac13\int_0^\frac12\mathrm dyy^3 $$

and

$$ \int_0^\frac12\mathrm dy\int_0^y\mathrm dxxy=\frac12\int_0^\frac12\mathrm dyy^3\;, $$

so the desired probability is

$$ \frac13\div\frac12=\frac23\;. $$

Here's Java code that confirms the result with a simulation.