Subfield: Number Theory


Question: Let $a>b>1$ be relatively prime positive integers. Define the weight of an integer $c$, denoted by $w(c)$, to be the minimal possible value of $|x|+|y|$ taken over all pairs of integers $x$ and $y$ such that

$$
a x+b y=c .
$$

An integer $c$ is called a local champion if $w(c) \geq w(c \pm a)$ and $w(c) \geq w(c \pm b)$.

Find all local champions and determine their number.

Solution:
Call the pair of integers $(x, y)$ a representation of $c$ if $a x+b y=c$ and $|x|+|y|$ has the smallest possible value, i.e. $|x|+|y|=w(c)$.

We characterise the local champions by the following three observations.

Lemma 1. If $(x, y)$ a representation of a local champion $c$ then $x y<0$.

Proof. Suppose indirectly that $x \geq 0$ and $y \geq 0$ and consider the values $w(c)$ and $w(c+a)$. All representations of the numbers $c$ and $c+a$ in the form $a u+b v$ can be written as

$$
c=a(x-k b)+b(y+k a), \quad c+a=a(x+1-k b)+b(y+k a)
$$

where $k$ is an arbitrary integer.

Since $|x|+|y|$ is minimal, we have

$$
x+y=|x|+|y| \leq|x-k b|+|y+k a|
$$

for all $k$. On the other hand, $w(c+a) \leq w(c)$, so there exists a $k$ for which

$$
|x+1-k b|+|y+k a| \leq|x|+|y|=x+y .
$$

Then

$$
(x+1-k b)+(y+k a) \leq|x+1-k b|+|y+k a| \leq x+y \leq|x-k b|+|y+k a| \text {. }
$$

Comparing the first and the third expressions, we find $k(a-b)+1 \leq 0$ implying $k<0$. Comparing the second and fourth expressions, we get $|x+1-k b| \leq|x-k b|$, therefore $k b>x$; this is a contradiction.

If $x, y \leq 0$ then we can switch to $-c,-x$ and $-y$.

From this point, write $c=a x-b y$ instead of $c=a x+b y$ and consider only those cases where $x$ and $y$ are nonzero and have the same sign. By Lemma 1, there is no loss of generality in doing so.

Lemma 2. Let $c=a x-b y$ where $|x|+|y|$ is minimal and $x, y$ have the same sign. The number $c$ is a local champion if and only if $|x|<b$ and $|x|+|y|=\left\lfloor\frac{a+b}{2}\right\rfloor$.

Proof. Without loss of generality we may assume $x, y>0$.

The numbers $c-a$ and $c+b$ can be written as

$$
c-a=a(x-1)-b y \quad \text { and } \quad c+b=a x-b(y-1)
$$

and trivially $w(c-a) \leq(x-1)+y<w(c)$ and $w(c+b) \leq x+(y-1)<w(c)$ in all cases.

Now assume that $c$ is a local champion and consider $w(c+a)$. Since $w(c+a) \leq w(c)$, there exists an integer $k$ such that

$$
c+a=a(x+1-k b)-b(y-k a) \quad \text { and } \quad|x+1-k b|+|y-k a| \leq x+y .
$$



This inequality cannot hold if $k \leq 0$, therefore $k>0$. We prove that we can choose $k=1$.

Consider the function $f(t)=|x+1-b t|+|y-a t|-(x+y)$. This is a convex function and we have $f(0)=1$ and $f(k) \leq 0$. By Jensen's inequality, $f(1) \leq\left(1-\frac{1}{k}\right) f(0)+\frac{1}{k} f(k)<1$. But $f(1)$ is an integer. Therefore $f(1) \leq 0$ and

$$
|x+1-b|+|y-a| \leq x+y
$$

Knowing $c=a(x-b)-b(y-a)$, we also have

$$
x+y \leq|x-b|+|y-a| \text {. }
$$

Combining the two inequalities yields $|x+1-b| \leq|x-b|$ which is equivalent to $x<b$.

Considering $w(c-b)$, we obtain similarly that $y<a$.

Now $|x-b|=b-x,|x+1-b|=b-x-1$ and $|y-a|=a-y$, therefore we have

$$
\begin{gathered}
(b-x-1)+(a-y) \leq x+y \leq(b-x)+(a-y), \\
\frac{a+b-1}{2} \leq x+y \leq \frac{a+b}{2} .
\end{gathered}
$$

Hence $x+y=\left\lfloor\frac{a+b}{2}\right\rfloor$.

To prove the opposite direction, assume $0<x<b$ and $x+y=\left\lfloor\frac{a+b}{2}\right\rfloor$. Since $a>b$, we also have $0<y<a$. Then

$$
w(c+a) \leq|x+1-b|+|y-a|=a+b-1-(x+y) \leq x+y=w(c)
$$

and

$$
w(c-b) \leq|x-b|+|y+1-a|=a+b-1-(x+y) \leq x+y=w(c)
$$

therefore $c$ is a local champion indeed.

Lemma 3. Let $c=a x-b y$ and assume that $x$ and $y$ have the same sign, $|x|<b,|y|<a$ and $|x|+|y|=\left\lfloor\frac{a+b}{2}\right\rfloor$. Then $w(c)=x+y$.

Proof. By definition $w(c)=\min \{|x-k b|+|y-k a|: k \in \mathbb{Z}\}$. If $k \leq 0$ then obviously $|x-k b|+|y-k a| \geq x+y$. If $k \geq 1$ then

$$
|x-k b|+|y-k a|=(k b-x)+(k a-y)=k(a+b)-(x+y) \geq(2 k-1)(x+y) \geq x+y
$$

Therefore $w(c)=x+y$ indeed.

Lemmas 1, 2 and 3 together yield that the set of local champions is

$$
C=\left\{ \pm(a x-b y): 0<x<b, x+y=\left\lfloor\frac{a+b}{2}\right\rfloor\right\}
$$

Denote by $C^{+}$and $C^{-}$the two sets generated by the expressions $+(a x-b y)$ and $-(a x-b y)$, respectively. It is easy to see that both sets are arithmetic progressions of length $b-1$, with difference $a+b$.

If $a$ and $b$ are odd, then $C^{+}=C^{-}$, because $a(-x)-b(-y)=a(b-x)-b(a-y)$ and $x+y=\frac{a+b}{2}$ is equivalent to $(b-x)+(a-y)=\frac{a+b}{2}$. In this case there exist $b-1$ local champions.

If $a$ and $b$ have opposite parities then the answer is different. For any $c_{1} \in C^{+}$and $c_{2} \in C^{-}$,

$$
2 c_{1} \equiv-2 c_{2} \equiv 2\left(a \frac{a+b-1}{2}-b \cdot 0\right) \equiv-a \quad(\bmod a+b)
$$



and

$$
2 c_{1}-2 c_{2} \equiv-2 a \quad(\bmod a+b)
$$

The number $a+b$ is odd and relatively prime to $a$, therefore the elements of $C^{+}$and $C^{-}$belong to two different residue classes modulo $a+b$. Hence, the set $C$ is the union of two disjoint arithmetic progressions and the number of all local champions is $2(b-1)$.

So the number of local champions is $b-1$ if both $a$ and $b$ are odd and $2(b-1)$ otherwise.

Final answer: the number of local champions is $b-1$ if both $a$ and $b$ are odd and $2(b-1)$ otherwise