In a square grid, if we have a coloring of the form $c(x, y) = (x + ny) \bmod m$, what is the minimum (positive!) taxicab distance (i.e. sum of absolute value fo coordinates) between different cells of the same color?
(In this example I colored all values except for 0 the same color. We are interested in the distance between yellow cells.)
This is the same as minimizing the following function,
$$d(m, n) = |mk + n\ell| + |\ell|$$
for fixed $0 \leq m < n$, and $k, \ell$ are integers that can be chosen freely (not both 0).
Ideally, I would like a formula for the minimum value of $d$ in terms of $m$ and $n$.
For the example shown above, $m = 7, n = 3$, and we find the minimum of $d$ to be $3$ (with $k = -1$ and $\ell = 2$).
It looks like this should be very easy but I find it tricky in the general case.
Background: I came across this question: Minimum colors needed to color Z2 with connected subsets restriction, where a specific instance of this problem is used in the answer. This is also related to another question I asked: What is the minimum distance between vertices on an integer grid with the form $(m(m+2), 0)p + (m, 1)q$? (Although in that question the Euclidean distance rather than the taxicab distance is being minimized.)
Update: I wrote a program to calculate the value of $d(m, n)$. There are obviously patterns, although I have not worked out exactly what.
Here is the same data arranged in a triangle; obviously factors play a role.
One interesting observation: the maximum value in each row (for fixed $m$), is roughly $\sqrt{2m}$, and in fact exactly $\sqrt{2m}$ for $m = 2, 8, 18, 32, ...$ (whenever $m$ is double a perfect square).




I do not know very well about these type of problem but I think this link may help https://books.google.co.in/books?id=OIpZxK8naikC&pg=PA104&lpg=PA104&dq=How+close+are+the+closest+cells+of+the+same+color+in+a+periodically+colored+grid?&source=bl&ots=u9o1Z7ZF8G&sig=ACfU3U1ekJGse9l9ZzTU_z3GGOsCQ2hMow&hl=en&sa=X&ved=2ahUKEwi-pMH9lMzmAhVayzgGHdGtBgMQ6AEwAXoECAwQAQ#v=onepage&q=How%20close%20are%20the%20closest%20cells%20of%20the%20same%20color%20in%20a%20periodically%20colored%20grid%3F&f=false.
If this does not satisfy you,you can comment below and I will remove my answer.