1

Question:

Find a formula for the integer with smallest absolute value that is congruent to an integer $a \bmod m$, where $m$ is a positive integer.

My attempt:

I don't completely understand the question, I reckon, "smallest absolute value that is congruent to integer $a \bmod m$ is the Canonical representation of $a \bmod m$, such that the smallest absolute value $x$ is

$0 \leq x < m$

which is equal to $a \bmod m$.

Books answer:

The following is the answer I do not understand and request for explaination why:

$x \bmod m$ if $x \bmod m \leq \lceil m/2 \rceil$ and $(x \bmod m) - m$ if $x \bmod m > \lceil m/2 \rceil$

JoeyAndres
  • 1,279
  • 1
    The absolute value of $x$ is just the distance between $x$ and $0$ on the number line. So you're looking for the integer closest to zero which is congruent to $a$ modulo $m$. For instance, if $m=5$ and $a=18$, the integers congruent to $18$ modulo $5$ are $\dots,-12,-7,-2,+3,+8,+13,+18,+23,\dots$; among these, the one closest to zero (smallest in size) is $-2$, since $|-2|=2\lt3=|3|$; so in this case your formula should produce $-2$. – bof Jul 07 '14 at 07:09

1 Answers1

2

Take $7$ for example, and look for seven numbers to reflect the seven residue classes.

The least non-negative residues are $0,1,2,3,4,5,6$, which is what you are familiar with.

The residues with least absolute value are $-3,-2,-1,0,1,2,3$ - these are sometimes convenient. You will note that $3$ is the greatest integer less than $\frac 72$.

If you had $8$, you would get $-3,-2,-1,0,1,2,3,4$ - or you could choose $-4$ instead of $4$ and still satisfy the parameters you were given.


Two other ways of looking at residues come to mind - ways of creating a complete set which relate to different properties of the integers.

Note that $3$ is coprime to $7$ so you could choose $0,3,6,9,12,15,18$ as representatives of the classes.

It is also the case that $3$ is a primitive root modulo the prime $7$, so we pick out $0$ as one class and then $1,3,9,27,81,243$ complete a set of representatives, and we can use this observation to define a "discrete logarithm", which is again used in practical applications.

Mark Bennet
  • 101,769
  • Hi , @MarkBennet - I understand your explanation but how am I to arrive to arrive at the general form as given by the book's answer , according to OP ? Would be grateful ... – pranav Feb 21 '15 at 04:00
  • @pranav Your goal is to find the closest values of 0. Take 2 examples and let me know what you think

    a = 31 m = 5. The answer is 1 because 31 mod 5 = 1 a = 34 m = 5 The answer is -1 because 34 mod 5 = 4 - 5 = -1. Notice how when the value of a crosses that upper bound, we have to subtract it by the modulus again due to the opportunity to cross 0 and enter the negative numbers.

    – Neel Sandell Feb 08 '22 at 09:56
  • He just wants to know whether the answer is correct or wrong… – Eric Jan 05 '24 at 10:33