0

Find a formula for the integer with smallest absolute value that is congruent to an integer $a \pmod{m}$, where $m \in \mathbb{Z}$?

There is answer to this question here, but I will discuss a different solution.

Details:

  • $x \equiv y \pmod{m}$ is by definition equivalent to $m|(x−y)$.
  • $x \equiv y \pmod{m}$ , $x,y\in \mathbb{Z}, m \in \mathbb{Z^+}$ iff $a \pmod {m} = b \pmod{m}$.
  • if $a | b$ and $a|c$, then $a|(b+c)$.
  • if $a | b$ and $b|c$, then $a|c$.
  • if $a | b$ then $a|bc$, for all integers $c$.

Attempt: I found a solution to this questions as follows:

Use the division algorithm to express $a = km + b$ with $0 \le b \lt m$. Let $s$ denote the integer with smallest absolute value that is congruent to $a \pmod{m}$.

Then $\mid s \mid = min \{b, m − b\}, s = b − \lfloor \frac{2b}{m} \rfloor$; or equivalently $s = min \{ x − \lfloor \frac{x}{m} \rfloor\cdot m , \lceil \frac{x}{m} \rceil \cdot m - x \} $.

Justification of these formulas:

  • From the division algorithm and definitions of modular arithmetic we have that $b$ and $b − m$ are two integers congruent to a modulo $m$. And thus, the absolute value of s is the minimum of $\mid b \mid = b$ and $\mid b − m \mid = m − b$
  • If $2b < m$, then $s = b$ and $b2b/mc = 0$. If $2b > m$, then $m − b \lt b$ and so $s = b − m$; note that in this case $\lfloor \frac{2b}{m} \rfloor = 1 $. Finally, if $2b = m$ then $m$ is even and $m − b = b$. With this, we conclude that in any of the three cases, the formula $s = b − m \lfloor \frac{2b}{m} \rfloor$ gives the right answer.
  • If $b = 0$, then $\lfloor x/m \rfloor = k = \lceil \frac{x}{m} \rceil$ and $s = 0$. If $b \ne 0$, then $\lfloor \frac{x}{m} \rfloor = k$ and $\lceil \frac{x}{m} \rceil = k + 1$. It follows that $b = x − \lfloor \frac{x}{m} \rfloor$ and $b − m = \lceil \frac{x}{m} \rceil \cdot m - x$; which are the two possible values of $s$.

Questions:

  • I am not sure about those properties mentioned in the solution based on details I provided above: "From the division algorithm and definitions of modular arithmetic we have that $b$ and $b − m$ are two integers congruent to a modulo $m$. And thus, the absolute value of s is the minimum of $\mid b \mid = b$ and $\mid b − m \mid = m − b$". How if $ a = km + b$, then $b$ and $b-m$.
  • Why $b-m$ is there in $min \{b, m − b\}$?
  • I am not sure how $2b \lt m$ was brought up in the solution and where it came from?
  • Why $\lfloor \frac{2b}{m} \rfloor = 1 $ in the justification in case $2b \gt m$?
  • How that in any of the three cases, the formula $s = b − m \lfloor \frac{2b}{m} \rfloor$ gives the right answer.

Note: Comments about solution being invalid refers to this one before I edited it to the current attempt above.

Solution: Thanks to the people commented on this question. Based on the division algorithm, we can find out that $r$ is the residue of $a \pmod{m}$ iff $a \equiv r \pmod{m}$, then $a = m\cdot k +r$. We can see that this $r$ is the residue of $a \pmod{m}$. To find the formula for the integer with smallest absolute value that is congruent to $a \pmod{m}$ is as follows,

$$ \{-\lceil \frac{m}{2} \rceil, \cdots, -1, 0, 1, \cdots, \lceil \frac{m}{2}\rceil\}$$

Omit one of $\{ -\lceil \frac{m}{2} \rceil, \lceil \frac{m}{2} \rceil \}$ in case $ \lceil \frac{m}{2} \rceil\ $ is even.

Avv
  • 1,159
  • 2
    $-2 \equiv 3 \pmod 5$ and $|-2| < |3|$. – Steven Alexis Gregory Mar 17 '21 at 01:41
  • 4
    The cited "proof" from, this slater page is incorrect, You seek the remainder in the balanced (least magnitude) residue system. Beware of random web sites. – Bill Dubuque Mar 17 '21 at 01:45
  • I am just trying to discuss different solutions and see if I can get corrections to them so that other can see those as well. Thanks again. – Avv Mar 17 '21 at 01:51
  • 1
    The arguments here solve the closely related problem: Find a formula for the i̶n̶t̶e̶g̶e̶r̶ natural with smallest absolute value that is congruent to an integer $a \pmod{m}$, where $m \in \mathbb{Z}$? – Sammy Black Mar 17 '21 at 02:11
  • @BillDubuque. I will edit it to another solution. – Avv Mar 17 '21 at 02:12
  • 2
    The (standard) residue classes $\bmod{5}$ are ${0,1, 2, 3, 4}$, but a balanced system of residue classes is more like ${-2, -1, 0, 1, 2}$ and the negative classes have smaller absolute value: $-2 \equiv 3$ and $|-2|<|3|$, etc. – Sammy Black Mar 17 '21 at 02:14
  • @SammyBlack. Thank you for explaining the residue classes, they are clear for me now. I have edited the solution. – Avv Mar 17 '21 at 02:44
  • 1
    Please link to the source of the new proof you changed to in your edit. You shouldn't radically change a question like that once there are comments or answers since it usually invalidates them - which can greatly confuse subsequent readers. – Bill Dubuque Mar 17 '21 at 08:14
  • @BillDubuque. Thank you. I understand that could be solved using residue classes definition. We can see that the smallest absolute value that is congruent to an integer $a \pmod{m}$, where $m$ is a positive integer is found with residue classes. – Avv Mar 17 '21 at 20:21

0 Answers0