Sunday, May 3, 2026

A frog's path

A frog is hopping around a chessboard, always from the center of one square to the center of another square. Each square has side length 1, but the board itself is not necessarily $8$-by-$8$. Instead, it’s $N$-by-$N$, where $N$ is some large whole number.

Every jump the frog makes must be the same distance, which we’ll call $L.$ The frog wants to make four jumps such that:

  • After the fourth jump, the frog has returned to its starting square.
  • The frog visits a total of four distinct squares along the way, including the square on which it starts (and also stops).
  • The path the frog takes is not a square loop.
  • The frog is never on a square that is diagonal (i.e., a bishop’s move away) or horizontal/vertical (i.e., a rook’s move away) from the starting square.

What is the smallest jumping distance $L$ for which this is possible?

Let's first analyze what happens if we ignore the rook's move away condition that was somewhat late breaking. In this case, the frog can emulate a standard chess knight which makes a jump of length $\ell = \sqrt{5}.$ Let's assume the frog is at a standard white knights position, say $b1$. The following four step circuit only violates the horizontal/vertical condition:

1. Nc3
2. Nb5
3. Na3
4. Nb1

We see that the frog returns to its starting spot; it visits four distinct squares; the path is not a square (though it is a rhombus); and it does not not hit any square that is a bishop's move away from the starting square (those are a2, c2, d3, e4, etc.). Alas, the additional condition to avoid a rooks move from the starting square was added, so there goes that simplified idea.

Ok, so let's first generalize so that we can solve the problem. Let's assume that we are at some starting square that we will call $(0,0)$. Then the set of all positions that are a bishop's or rook's move away from $(0,0)$ is defined by $$\mathfrak{X} = \left( \mathbb{Z} \times \{0\} \right) \cup \left( \{ 0 \} \times \mathbb{Z} \right) \cup \{ (p,q) \in \mathbb{Z}^2 \mid |p| = |q| \}.$$ The simplest idea is to perhaps move to different types of knight like pieces, perhaps that move $m$ squares in one direction and then $n$ squares in some perpendicular direction, with $1 \leq m \lt n,$ such that the frog could first move to one of the following eight squares: $(m,n), (m,-n), (-m,n), (-m,-n), (n,m), (n,-m), (-n,m), (-n,-m),$ where none of them are in $\mathfrak{X}.$ Without loss of generality, let's assume that the frog went to $x_1 = (m,n).$ Since we want $x_2 \not\in \mathfrak{X},$ the frog can only make the following moves to arrive at $$x_2 \in \left\{ (2m,2n), (m+n, n-m), (m-n, m+n) \right\}.$$ We see that in order for the frog to be able to make it back to $(0,0)$ at the end of its 4th move it would have to arrive at one of the following seven possibilities: $$x_3 \in \{ (m,-n), (-m,n), (-m, -n), (n,m), (n,-m), (-n, m), (-n,m) \}.$$ In this case, we can just test each of the distances from the candidate $x_2$ positions and $x_3$ positions and check whether any of them has a distance of $L = \sqrt{m^2+n^2}:$ \begin{align*} d( (2m,2n), (m,-n) ) &= \sqrt{m^2 +9n^2} \gt L \\ d( (2m,2n), (-m, n) ) &= \sqrt{9m^2 + n^2} \gt L \\ d( (2m,2n), (-m,-n) ) &= \sqrt{9m^2 +9n^2} = 3L \gt L \\ d( (2m,2n), (n, m) ) &= \sqrt{m^2 + n^2 + 4(m-n)^2} \geq L\\ d( (2m,2n), (n,-m) ) &= \sqrt{m^2 +9n^2} \gt L \\ d( (2m,2n), (-n, m) ) &= \sqrt{9m^2 + n^2} \gt L \\ d( (2m,2n), (-n,-m) ) &= \sqrt{m^2 +n^2+4(m+n)^2} \gt L \\ d( (m+n, n-m), (m, -n)) &= \sqrt{m^2 -4mn + 5n^2} = \sqrt{ m^2 + n^2 - 4n(m-n)} \\ d( (m+n, n-m), (-m,n) ) &= \sqrt{5m^2 -4mn + n^2} = \sqrt{ m^2 + n^2 + 4m(m-n)} \\ d( (m+n, n-m), (-m,-n)) &= \sqrt{5m^2 + 5n^2 } = \sqrt{5}L \gt L \\ d( (m+n, n-m), (n, m) ) &= \sqrt{5m^2 - 4mn + n^2} = \sqrt{ m^2 + n^2 + 4m(m-n)} \\ d( (m+n, n-m), (n,-m) ) &= \sqrt{m^2 + n^2 } = L \\ d( (m+n, n-m), (-n,m) ) &= \sqrt{5m^2 - 4mn + n^2} = \sqrt{ m^2 + n^2 + 4m(m-n)} \\ d( (m+n, n-m), (-n,-m)) &= \sqrt{m^2 + n^2 } = L \\ d( (m-n, m+n), (m, -n)) &= \sqrt{m^2 + n^2 } = L \\ d( (m-n, m+n), (-m,n) ) &= \sqrt{5m^2 -4mn + n^2} = \sqrt{ m^2 + n^2 + 4m(m-n)} \\ d( (m-n, m+n), (-m,-n)) &= \sqrt{m^2 + n^2 } = L \\ d( (m-n, m+n), (n, m) ) &= \sqrt{m^2 - 4mn + 5n^2} = \sqrt{ m^2 + n^2 - 4n(m-n)} \\ d( (m-n, m+n), (n,-m) ) &= \sqrt{m^2 - 4mn + 5n^2} = \sqrt{ m^2 + n^2 - 4n(m-n)} \\ d( (m-n, m+n), (-n,m) ) &= \sqrt{m^2 - 4mn + 5n^2} = \sqrt{ m^2 + n^2 - 4n(m-n)} \\ d( (m-n, m+n), (-n,-m)) &= \sqrt{5m^2 + 5n^2 } = \sqrt{5}L \gt L \\ \end{align*}

We see that there are nince cases where the distance is always greater than or equal to $L,$ with equality only when $m=n$, which we can ignore because the frog would not be able to complete a circuit. Additionally, there are eight cases, where the distances can either be greater or less than $L$ depending on the values of $m$ and $n,$ with equality only when $m=n$. Since if $m=n$ then $(m,n) \in \mathfrak{X}$, we can ignore these cases too. Finally, there are also 4 cases where the distance is equal to $L$ for any value of $m$ and $n$:

  • $(0,0) \to (m,n) \to (m+n, n-m) \to (n, -m) \to (0,0)$
  • $(0,0) \to (m,n) \to (m+n, n-m) \to (-n, -m) \to (0,0)$
  • $(0,0) \to (m,n) \to (m-n, m+n) \to (-m, n) \to (0,0)$
  • $(0,0) \to (m,n) \to (m-n, m+n) \to (-m, -n) \to (0,0)$

In each of these cases, we see that diagonal lengths are equal, for instance in the case of the first potential path we have diagonal lengths $$d((0,0), (m+n,n-m)) = d((m,n), (n,-m)) = \sqrt{(m+n)^2 + (m-n)^2} = \sqrt{2}L,$$ so these must be in fact forbidden squares, which are not allowed in the frog's path. So we are left with no acceptable paths with just one type of step.

OK, so what next? Naturally, we need to look for length $L$ where we can find two distinct solutions, $1 \leq a \lt b,$ $1 \leq m \lt n$ with $a \ne m$ and $b \ne n,$ such that $L = \sqrt{a^2 + b^2} = \sqrt{m^2 + n^2}.$ If we do have two such independent solutions, then we can take the following path, say $$(0,0) \to (a,b) \to (a-m, b-n) \to (-m, -n) \to (0,0),$$ which will certainly satisfy conditions 1 and 2 of the frog's path, since $(a,b) \ne (m,n).$ Let's check the diagonal lengths $$\delta_1 = d((0,0), (a-m, b-n)) = \sqrt{ (a-m)^2 + (b-n)^2 } = \sqrt{ 2(L^2 - am -bn) }$$ and $$\delta_2 = d((a,b), (-m,-n)) = \sqrt{ (a+m)^2 + (b+n)^2 } = \sqrt{2(L^2 + am + bn)},$$ where we see that $\delta_1 = \delta_2$ if and only if $m=n=0,$ which would not make for a very large frog's jump. Therefore, we must have different diagonal lengths, so this path is a rhombus but not a square. Finally, by construction we have $(a,b), (-m,-n) \not\in \mathfrak{X}.$ Further, since $(a,b) \ne (m,n)$ we have $a-m \ne 0$ and we have $b-n = \sqrt{L - a^2} - \sqrt{L^2-m^2},$ so we see that we would have $|b-n| = |a-m|$ if and only if we have $$\left| \frac{\sqrt{L^2 -a^2} - \sqrt{L^2 - m^2} }{a-m} \right| = 1.$$ However, this would happen if and only if $m = \sqrt{L^2 - a^2} = b$ and hence we would arrive at $n = a = \sqrt{L^2 - b^2},$ one of our two assumptions that $1 \leq a \lt b$ and $1 \leq m \lt n$ is violated. Therefore, we see that $(a-m, b-n) \not\in \mathfrak{X}$ as well.

Now that we have proven that we can get a bona fide frog's path whenever there are two distinct positive solutions of $a^2 + b^2 = K = m^2 + n^2$ we simply need to find the smallest possible value of $K$ that has two such distinct solutions. To do this, let's first avail ourselves of Jacobi's two-square theorem, which states that if $r_2(n)$ is the number of ways to represent that positive integer $n$ as the sum of two squares of integers, then $_2(n) = 0$ if there is some prime divisor $p \mid n$ with $p^k \mid n$ for $k$ odd and $p \equiv 3 \mod 4,$ and $$r_2(n) = 4( d_1(n) - d_3(n) ),$$ where $d_1(n)$ is the number of divisors of $n$ that are congruent to $1 \mod 4$ and $d_3(n)$ is the number of divisors of $n$ that are congruent to $3 \mod 4.$ We see for instance that $r_2(1) = 4,$ since $1 = 1^2 + 0^2 = (-1)^2 + 0^2 = 0^2 + 1^2 = 0^2 + (-1)^2.$ Similarly $r_2(10) = 8$ since $(\pm 1)^2 + (\pm 3)^2 = (\pm 3)^2 + (\pm 1)^2 = 10.$ For our purposes, the four different combinations are not super interesting, so we just need to look for small values of $K$ for which $r_2(K) \gt 8.$ We see that the first such integer is $K=25,$ where $r_2(25) = 12$ since we have $$0^2 + (\pm 5)^2 = (\pm 5)^2 + 0^2 = (\pm 3)^2 + (\pm 4)^2 = (\pm 4)^2 + (\pm 3)^2 = 25.$$ Similarly, we have $r_2(50) = 12$ since $$(\pm 1)^2 + (\pm 7)^2 = (\pm 7)^2 + (\pm 1)^2 = (\pm 5)^2 + (\pm 5)^2 = 50.$$ In both of these cases, we cannot actually obtain two distinct solutions $1 \leq a \lt b$ and $1 \leq m \lt n$ with $a^2 + b^2 = m^2 + n^2 = K,$ since in the case of $K = 25$ one of the solutions is contains a zero and in the case of $K=50$ one of the solutions is on the diagonal.

This brings us to the case of $K = 65,$ where we finally see that we get $r_2(65) = 16$ because we have $(\pm 1)^2 + (\pm 8)^2 = (\pm 8)^2 + (\pm 1)^2 = (\pm 4)^2 + (\pm 7)^2 = (\pm 7)^2 + \pm 4)^2.$ So we see that we can distinctly choose the solutions $(a,b) = (1,8)$ and $(m,n) = (4,7)$ and arrive at a frog's path with a minimal distance of $L = \sqrt{65}.$

No comments:

Post a Comment