A recent trend for benchmarking AI performance is to have LLMs write code simulating a ball bouncing around a rotating polygon, which involves kinematics and collision detection. It turns out it’s fairly tricky for some LLMs to implement this, and has led to humorous failed attempts.
I won’t be asking you to code such a simulation this week, although you’re welcome to do so!
Instead, suppose you have a unit square that’s rotating about its center at a constant (nonzero) angular speed, and there’s a moving ball inside. The ball has a constant (nonzero) linear speed, and there’s no friction or gravity. When the ball hits an edge of the square, it simply reflects as though the square is momentarily stationary during the briefest of moments they’re in contact. Also, the ball is not allowed to hit a corner of the square—it would get jammed in that corner, a situation we prefer to avoid.
Suppose the ball travels on a periodic (i.e., repeating) path, and that it only ever makes contact with a single point on the unit square. What is the shortest distance the ball could travel in one complete loop of this path?
A ball bouncing back and forth in sync with half of a rotation seems to be the shortest periodic path.
If the ball collides with the center of an edge at $90^\circ$ and $$\frac{\text{linear speed}}{\text{angular speed}} = \frac{1}{180^\circ+n360^\circ}\text{,}$$ the total distance is $$\boxed{2}\text{.}$$
Again, you have a rotating unit square and bouncing ball inside.
By now, you’ve hopefully found the shortest repeating path for which the ball makes contact with a single point on the square. Let’s call this path length L1.
The next shortest repeating path for which the ball makes contact with a single point on the square has length L2. To be clear, L2 > L1.
What is the length L2?
A single point on a rotating square defines a circle. An equilateral triangle inscribed in a circle has the smallest perimeter of any inscribed regular polygon.
If the ball collides with the center of an edge at $60^\circ$ and $$\frac{\text{linear speed}}{\text{angular speed}} = \frac{\frac{\sqrt{3}}{2}}{120^\circ+n360^\circ} = \frac{\sqrt{3}}{240^\circ+n360^\circ}\text{,}$$ the total distance is $$\boxed{\frac{3\sqrt{3}}{2} \approx 2.598}\text{.}$$
Note: Convex regular polygons following this pattern approach a circle, and thus have a perimeter that approaches $\boxed{\pi}$.
Another Note: Not all viable solutions are convex polygons!
If the ball collides with the center of an edge at $36^\circ$ and $$\frac{\text{linear speed}}{\text{angular speed}} = \frac{\frac{\sqrt{10-2\sqrt{5}}}{4}}{72^\circ+n360^\circ} = \frac{\sqrt{10-2\sqrt{5}}}{288^\circ+n360^\circ}\text{,}$$ the total distance is $$\boxed{\frac{5\sqrt{10-2\sqrt{5}}}{4}\approx 2.939}\text{.}$$
If the ball collides with the center of an edge at $72^\circ$ and $$\frac{\text{linear speed}}{\text{angular speed}} = \frac{ \frac{1}{2} \sqrt{\frac{5+\sqrt{5}}{2}}}{144^\circ+n360^\circ} = \frac{\sqrt{\frac{5+\sqrt{5}}{2}}}{288^\circ+n360^\circ}\text{,}$$ the total distance is $$\boxed{\frac{5}{2}\sqrt{\frac{5+\sqrt{5}}{2}}\approx 4.755}\text{.}$$