Minimum of $|az_x-bz_y|$
I am trying to minimize the following function: \begin{align} &f(z_x,z_y)=|az_x-bz_y| \\ &\text{ s.t. } z_x,z_y \in \mathbb{Z},1 \le z_x \le N_x \text{ and } 1 \le z_y \le N_y \text{ and } a,b \in \mathbb{R}^{+}. \end{align}
There reason I find this problem difficult is that it involves several areas of mathematics: number theory (Diophantine equations), optimization with constrains.
{ Edit:} I know the following: if $a<N_y$ and $b<N_x$ then minimum is attained at $z_x= \lceil b \rfloor$ and $z_y= \lceil a \rfloor$. But there are other cases which I don't see how to solve.
{ The above is wrong. Can show a counter example}
I have been also pursuing a direction with continued fractions. So far unsuccessful.:(
Partial answer:
if $a \ge bN_y$ or $b \ge a N_x$ then minimum value is is $\min(a,b)$.
First bounty Tony was able to answer it for specific $a$ and $b$ and gave a general procedure how to do it.
Second bounty This is second bounty question. Can one find a minimum solution or a tight lower bound that is a function of $a,b, N_x,N_y$?
First of all, we can assume that $b=1$ without loss of generality. For, if we define $\overline{a}=\frac{a}{b}$, then minimizing $|\overline{a}z_x-z_y|$ is the same as minimizing $|az_x-bz_y|$.
Now, we're really looking for $\frac{z_y}{z_x}$ to be a rational number close to $a$. The convergents of the continued fraction expansion of $a$ are precisely the rational numbers $\frac{z_y}{z_x}$ that minimize $|az_x-z_y|$ for bounded $z_x$. If any of those are in the region $1\leq z_x\leq N_x$, $a\leq z_y\leq N_y$, simply choose the last one that is. For example, let $N_x=N_y=20$ and let $a=\sqrt{2}$, which has for its first few convergents, $\{\frac11, \frac32, \frac75, \frac{17}{12}, \frac{41}{29},\ldots\}$. We would choose $z_x=12, z_y=17$ to find our minimum.
This actually applies to rational numbers as well as irrational ones. In that example, we would obtain the same solution for, say, $a=\frac{41}{29}$.
The case remains where no convergents of $a$ are in the desired region. Now we can simply think about the geometry of this situation. We've got a line through the origin with a slope of $a$, and a rectangular region defined by our inequalites on $z_x$ and $z_y$. Convergents are simply lattice points closer to the line than any (first quadrant) lattice point to their left. Thus, any line that misses the region entirely will either have its closest approach to the point $(1,N_y)$ or the point $(N_x,1)$, depending on whether the line misses the region because $a>N_y$ or because $a<\frac{1}{N_x}$, respectively.