Not a full answer, just a clear statement of the problem. It is actually pretty interesting.
Create a set of integer denominators (what really matters) in a 2D space.
SeedRandom[1234]; den = Table[RandomInteger[{5, 25}], {2}];
1/den
(* {1/6, 1/25} *)
Find the least common multiplier lcm
, which is also your value of $Z$ when $\varepsilon=0$
lcm = LCM @@ den
(* 150 *)
Plot $Z$ as you vary it over the range {0, lcm}
ParametricPlot[z/den, {z, 0, lcm}, Frame -> True,
GridLines -> {Range[0, (lcm/den)[[1]]],
Range[0, (lcm/den)[[2]]]
}]
You can see that it almost hits the {4,1}
grid coord and others. We can plot that. Set $\varepsilon=0.1$
eps = 0.1;
Plot[Norm[z/den - Round[z/den], Infinity],
{z, 0, lcm},
Epilog -> Line[{{0, eps}, {lcm, eps}}]
]
So $Z$ about 24 or so (eyeballing it) is your value.
Around each grid crossing is a $D$-dimensional cube centered on the crossing with side lengths $\varepsilon$. The problem is to find the first cube intersected by the vector, knowing that it is bounded by when the vector length = lcm
.
It might be possible to brute force it, but lcm
can explode as the number of terms increases. Again, interesting problem!