15

Divide the plane into unit squares. I would like to know the largest number of grid squares that can be touched by a path of (Euclidean) length $l$. Touching an edge or vertex o the square counts; e.g. the path in the diagram below has length $1 + \sqrt{5}$ and touches $10$ squares. The start and endpoint can be anywhere.

enter image description here

In particular, there is an upper bound that I am quite confident of, but which I have no idea how to prove: I think the optimal approach is to move diagonally, as shown below, achieving $3$ squares per $\sqrt{2}$ units of length, so I think the number of squares can be upper bounded as $\frac{3}{\sqrt{2}}l + 4$. My question is how to prove this upper bound.

enter image description here

This is motivated by another question, about the shortest path that touches every square in a $n \times n$ grid, where several people were able to find good approaches that might be optimal, but no one was able to prove anything was optimal. This would provide a lower bound, and first step towards a proof for that question.

Zoe Allen
  • 7,939
  • Do you restrict the path to 1) begin and end on vertices of the grid and 2) be made of straight segments? – Pranay Feb 18 '25 at 21:49
  • 1
    @Pranay I don't restrict either of those things, though I have now thought of a proof it has to be made of straight line segments. – Zoe Allen Feb 18 '25 at 21:50
  • 4
    Note that if they line segment is for example slightly less than $2\sqrt{2}$, moving only diagonally is not the best idea, since you can't quite touch 3 vertices. For such a length, it is better to move $\sqrt{2}$ diagonally and the remaining length along an edge, as now you can touch 3 vertices. – Anton V. Feb 18 '25 at 22:27
  • @AntonV. That doesn't make it possible to break the bound I conjecture, does it? – Zoe Allen Feb 18 '25 at 22:59
  • @ZoeAllen No, it just means you have to be careful how you phrase it. "The optimal approach is to move diagonally" is incorrect (for $l=1$ you can touch six squares with a horizontal line but only four with a diagonal), but "the number of squares touched is no more than $\frac{3}{\sqrt{2}}l + 4$" is correct. – Toph Feb 19 '25 at 08:45

2 Answers2

10

I believe I now have a proof. This proof takes the form of a series of changes that can be made to whatever path you start with that do not increase the length of the path, and do not decrease the number of squares touched, until you can calculate the ratio of squares to length.

We start with an arbitrary path, with arbitrary endpoints. First I will make it piecewise linear, then put all the breakpoints on vertices of the grid of unit squares, then I will rearrange it so the path is always moving upwards and rightwards.

enter image description here

Here is our path. First of all, we mark everywhere where it intersects the edges of the grid. Now we replace all the curved arcs connecting those points with straight lines.

enter image description here enter image description here

Clearly this doesn't increase path length. But because it only changes how the path moves within grid squares, it also doesn't change which grid squares the path touches.

Now focus on a particular breakpoint in our newly piecewise linear path. Find the breakpoints immediately before and after it- or the places where the path intersects grid vertices if that is closer. Now we straighten out the highlighted section.

enter image description here enter image description here

If in the course of straightening it out the line passes over a grid vertex we stop at that vertex, and let that be a new breakpoint. This guarantees we don't stop the path from touching any squares it was previously touching. Similarly, if our middle breakpoint passes over a grid edge, and both the adjacent breakpoints are on the same side of the edge, that will remove a square, so we stop there.

enter image description here enter image description here

This guarantees that all the breakpoints on the stretch we were considering are now a) grid vertices or b) points on grid edges, with both of the adjacent breakpoints on the same side of the edge. Again, we are making the path no longer. By repeatedly doing this, we can ensure all of the breakpoints except the endpoints are of these two types.

enter image description here

To deal with the endpoints, we now simply cut them off at the last point where they intersected a new square. The extra length wasn't touching any squares that the new endpoint isn't touching, so this doesn't reduce the number of squares touched. This guarantees the new endpoints are either a) a grid vertex or b) a point on an edge.

Now one by one we start reflecting each segment so that they are all moving (wlog) in the positive $x$ positive $y$ direction. This doesn't change the number of squares touched by any individual line segment, and can only ever decrease the amount of overlap, so can only ever increase the total amount of squares the path touches.

Our path is shown left, but an example which had an edge breakpoint is shown right. The path is reflected at the edge breakpoint so that the adjacent breakpoints are on opposite sides of the edge, ready to be straightened out again.

enter image description here enter image description here

We now straighten it out again by the same method as before. Now because the path is always travelling up and right it is impossible to end up with an edge breakpoint, as it is impossible to have two adjacent breakpoints on the same side of the edge. All the breakpoints except the endpoints are on grid vertices. The endpoints can then be shifted up and right or down and left respectively until they are on vertices too, potentially creating new vertex breakpoints, but no edge breakpoints.

enter image description here enter image description here

Now that finally all of the breakpoints are on grid vertices and moving up and right, there is a nice way we can add up how many grid squares the path touches.

It is the sum of the number of squares touched by each individual line segment subtract $4$ times the number of breakpoints (not counting endpoints). This is because at each breakpoint we double-count the $4$ squares around that breakpoint (and if a square is adjacent to $2$ breakpoints they get triple-counted, etc.).

We can alternatively express this as the sum, for each line segment, of the number of squares touched by the line segment but not by the bottom-left breakpoint, plus the original $4$ squares from the start point. You can see in the picture below that the green area below is the sum of the green area for each segment.

enter image description here

Hence to prove my inequality we just need to show that the number of squares touching a line segment- excluding the $4$ touching the first breakpoint- is $\le \frac{3}{\sqrt{2}}$ multiplied by the length of that line segment. Which is the same as showing the diagonal line segment is the most efficient one, by this metric. This is because if the ratio is $\le \frac{3}{\sqrt{2}}$ for each individual line segment, then because number of squares and the length are both additive, the ratio must be $\le \frac{3}{\sqrt{2}}$ for the full path (again, excluding the $4$ squares touching the start-point).

The number of squares touched by a line segment that goes right by $m$ and up by $n$, again excluding the squares touching the bottom-left breakpoint, is $m + n + a$ where $a$ is the number of grid vertices the segment passes through, including the top-right breakpoint but not the bottom-left breakpoint.

The number of grid vertices that the segment passes through is at most $\min \{ m, n\}$, as it can pass through at most one grid vertex for each horizontal grid line it passes through, and the same for vertical grid lines. So the 'efficiency' of a $(m,n)$ line segment is upper-bounded by

$$\frac{m + n + \min \{ m, n\}}{\sqrt{m^2 + n^2}}$$

Which is $\le \frac{3}{\sqrt{2}}$ for any $m, n$, so it is impossible to do better than the diagonal line. Proof:

Assuming wlog $m \le n$ and using the fact that both sides are positive so we can square them, this is equivalent to

$$\frac{(2m + n)^2}{m^2 + n^2} \le \frac92$$ $$2(2m + n)^2 \le 9(m^2 + n^2)$$ $$0 \le m^2 -8mn + 7n^2$$ $$0 \le (7n-m)(n-m)$$ Which is true by assumption that $n \ge m$. And these are all equivalences so the original inequality holds for all positive integers $m, n$.

Zoe Allen
  • 7,939
0

I will approach this from the viewpoint of efficiency and prove that the two most optimal "moves" are (1,1) and (1,0). This is necessary to answer the question that inspired this one.

The points that touch the most squares are the lattice points (LPs). In general, paths should touch as many LPs as possible per unit length.

The triangle inequality suffices to show that going straight from LP to LP is optimal. I will call these straight line segments "moves".

Assuming wlog that $x \ge y \ge 0$ and $(x_1,y_1)=(0,0)$, a move from $(x_1,y_1)$ to $(x_2,y_2)$ counts as a single move only if $m=x_2-x_1$ and $n=y_2-y_1$ are coprime ($\gcd{m,n}=1$). In case $m$ and $n$ do have a common divisor $d>1$, the straight line passes through $d-1$ intermediate LPs and must be treated as $d$ separate moves. I will call moves with coprime $(m,n)$ "elementary".

Without counting the $4$ starting squares, elementary moves only cross $1$ grid line at a time except for the end, where they touch an extra corner, from this we get $m+n+1$ squares touched. Their length is $\sqrt{m^2+n^2}$ by definition. The efficiency of elementary moves $(m,n)$ is thus: $$f(m,n)=\frac{m+n+1}{\sqrt{m^2+n^2}}$$

3d plot of the efficiency

In polar coordinates: $$m=r\cos{\theta}\text{, }n=r\sin{\theta}$$ $$f(r,\theta)=\frac{r\left(\cos{\theta}+\sin{\theta}\right)+1}{r}= \frac{1}{r}+\sqrt{2}\sin{\left(\theta+\frac{\pi}{4}\right)}$$ For any fixed $r$, the maximum of $\sqrt{2}\sin{\left(\theta+\frac{\pi}{4}\right)}$ in $\left[0,\frac{\pi}{4}\right]$ is $\sqrt{2}$ at $\theta=\frac{\pi}{4}$ or along the diagonal. $$(m,n)=(1,0)\text{ corresponds to }r=1\text{ and }f=2$$ $$(m,n)=(1,1)\text{ corresponds to }r=\sqrt{2}\text{ and }f=\frac{3}{\sqrt{2}}>2$$ $$\sqrt{2}+\frac{1}{\sqrt{3}}<2$$ $\frac{1}{r}$ decreases as $r$ increases so the two most optimal moves are $(1,1)$ and $(1,0)$. Q.E.D.