In a square with unit side length, we randomly select a point on each of two opposite sides. What is the probability that the distance between the two points is less than a given segment $p$? $(1<p<\sqrt{2})$.
Let the distance of the chosen points from one side of the square be $x$ and $y$ ($0 \leq x \leq 1, 0 \leq y \leq 1$). The distance between the chosen points, based on the Pythagorean theorem, is $\sqrt{1+(x-y)^{2}}$. If this distance is less than the given $p$ distance, then

$$
1+(x-y)^{2} < p^{2}
$$

which simplifies to

$$
|x-y| < \sqrt{p^{2}-1}
$$

This can be broken down as follows:

| If $x > y$ | $y > x - \sqrt{p^{2}-1}$, |
| :--- | :--- |
| and if $x < y$ | $y < x + \sqrt{p^{2}-1}$. |

If we consider the value pairs $(x, y)$ as coordinates of a point in a Cartesian coordinate system, then the total "possible area" is the area of the unit square ( $T=1$ ), while the "favorable area" is the part of the strip formed by the lines $y=x-\sqrt{p^{2}-1}$ and $y=x+\sqrt{p^{2}-1}$ that lies within the square: $t$.

![](https://cdn.mathpix.com/cropped/2024_05_02_b6e7f9e6f49a6b28e2ecg-1.jpg?height=475&width=542&top_left_y=722&top_left_x=781)

(The hatched hexagon in the diagram.) The area of this latter part is

$$
t = T - \left(1 - \sqrt{p^{2}-1}\right)^{2} = 1 - \left(1 - 2\sqrt{p^{2}-1} + p^{2} - 1\right) = 1 - p^{2} + 2\sqrt{p^{2}-1}
$$

and thus the desired probability is

$$
v = \frac{t}{T} = 1 - p^{2} + 2\sqrt{p^{2}-1}
$$

(Indeed, the extreme cases are: if $p=1, v=0$, if $p=\sqrt{2}, v=1$).