0

I am trying to understand modular arithmetic using the article posted on Brilliant.org. Howeverver, I am having trouble understanding the first addition property when applied to the following examples:

$$\text{Property 1: If }\;a+b=c\text{, then }a\;(mod\;N)+b\;(mod\;N)\equiv c\;(mod\;N) $$

This holds for the following example:

$$3\;(mod\;10)+5\;(mod\;10)\equiv 8\;(mod\;10)=8 $$

However, it doesn't hold for the next example:

$$3\;(mod\;2)+5\;(mod\;2)\neq 8\;(mod\;2) $$

Please would someone mind to help me understand what am I doing wrong? Thank you in advance.

  • What you did wrong is to write the incorrect symbol $\ne$ instead of the correct symbol $=$ ... or, even better, $\equiv$. If you want more useful help, you should explain how you came to that $\ne$ conclusion. – Lee Mosher Nov 21 '21 at 14:19
  • If your objection is $1+1\ne0$, you need to stop thinking of modulo as giving remainders. It instead tells us $3+5$ has the same remainder as various other values. – J.G. Nov 21 '21 at 14:21
  • 1
    Is there really an article on brilliant.org that says $a;(mod;N)+b;(mod;N)\equiv c;(mod;N)$? The usual way to write addition modulo $N$ is like $a + b \equiv c \pmod N.$ The first way makes it look like you are applying a "remainder" operator to each number before you add and not after, which is not what we mean by "modular arithmetic". The second way means that the equivalence itself is "modulo $N$". – David K Nov 21 '21 at 14:25
  • Thank you very much for all your replies, @DavidK in that case you mean that if a=3, b=5, N=10 then it would mean that you first have to add 3 + 5 before applying the mod 10 operator ? You can't apply the mod 10 operator on 3 and 5 individually and the results together ? The Brilliant.org article is this one: https://brilliant.org/wiki/modular-arithmetic/ (look at the Addition -> Property 1) – Baldovín Cadena Mejía Nov 21 '21 at 14:34
  • Actually I would not really be surprised to find such an article on brilliant.org. My impression of that site is that it has a mix of useful and worse-than-useless articles with no real quality control. I'm not sufficiently interested in exploring those depths to actually set up an account there. We also have a mix of useful and worse-than-useless answers on MSE but at least there is some attempt at quality control. – David K Nov 21 '21 at 17:13
  • See here for more on mod as an operator vs. relation (congruence). – Bill Dubuque Nov 21 '21 at 17:32

3 Answers3

1

The topic of modular arithmetic is explained in many places. Some explain it well, some not so well.

Here is a good beginning of an explanation of what modular arithmetic is about. Also here.

When we do addition modular arithmetic we are not just adding individual integers. We are adding equivalence classes of integers. Another way of looking at it is, in arithmetic modulo $N$ we have $N$ distinct objects, to which we can give the convenient labels $0, 1, 2, \ldots, N-1$, along with facts such as that the sum of the objects named $N-1$ and $3$ is the object named $2$. In that context, the object named $2$ is the set of all the integers that you can get by adding any integer multiple of $N$ to $2.$

There is some variation in how we write such sums in modular arithmetic, but the typical notation for showing that the sum of two numbers in modular arithmetic is a third number is

$$ a + b \equiv c \pmod N, $$

where the $\equiv$ symbol is a reminder that we are dealing with equivalence classes (not just individual integers) and $(\mathrm{mod}\ N)$ tells us which collection of equivalence classes we are working with. In a context where we already know that we're working in arithmetic modulo $N$ the $(\mathrm{mod}\ N)$ part might be omitted and we would just write $a + b \equiv c.$

It's also customary that any member of an equivalence class is an acceptable name for that class. For example, we can write

$$ -1 \equiv 9 \pmod{10} $$

and this is true because $-1$ and $9$ are just two different names for the same equivalence class of integers modulo $10.$

All this stuff with "equivalence classes" may seem like a lot to get your head around just to understand modular arithmetic, and it is indeed a lot to think about; but that's how mathematicians typically define "modular arithmetic". Someone who tries to explain modular arithmetic while completely skipping the equivalence classes is usually not going to be giving you the whole story.


There is another notation that uses the symbol $\bmod$ that works a little differently. This is the binary modulo operator, for example,

$$ 12 \bmod 10 = 2. $$

This is just an ordinary equation involving ordinary integers and an operator that (like addition or multiplication) takes two integers as input and returns an integer as output.

This operator is useful in algorithms where you want the computation to proceed in a deterministic fashion and you want all results as integers, not equivalence classes.

Many computer languages have such an operator, for example a % n in the C-like languages. You will sometimes see the binary modulo operator in a mathematical setting, but (I think) usually when only positive numbers are involved, because there is some ambiguity about how it applies to negative numbers. For example, when you divide $-32$ by $10,$ is the quotient $-3$ with remainder $-2$, or is the quotient $-4$ with remainder $8$? Nowadays the trend seems to be toward taking the answer that gives a non-negative remainder, but in the past some languages (or even different implementations of the same language!) would go one way while other languages (or implementations) would go another.

In a mathematical context I would expect a $\bmod$ operator to return a non-negative value, for example,

$$ -53 \bmod 8 = 3 $$

because $-53 = -7(8) + 3,$ but I might want it see it defined unambiguously in the same document before it is used this way. Note that this is written without parentheses around the "$\mathrm{mod}\ 8$" part, because $\bmod$ is a binary operator and the number on its left is one of its operands. After all, would you write $5\ (\times\ 3) = 15$?

In the context of modular arithmetic there is (I think) not much use for a binary modulo operator. The binary modulo operator requires its operands both to be integers; what can it do with an equivalence class of integers? It's better to avoid mixing the two kinds of "mod" notation unless you have a very clear idea what you are trying to do and you can demonstrate a generally satisfactory reason why you cannot do the same thing with either pure modular arithmetic or just using the binary mod operator.

One generally useful application of the binary mod in the context of modular arithmetic is that as long as you are using the same $N$ in all your "mod $N$" notations, and you're really doing arithmetic modulo $N$, the binary operator will take any name of an equivalence class (interpreted as an integer) and tell you the name of that class among the names $0, 1, 2, \ldots, N-1.$ It can help you to avoid having to work with larger numbers while trying to solve a problem in modular arithmetic. But this is just a bookkeeping device; there is no need to actually write the binary mod operator for this purpose, because substituting a more convenient name for the equivalence class is something you are always allowed to do. On the other hand, if you start mixing (for example) "mod $7$" and "mod $9$" in the context of actual modular arithmetic, you'd better really know what you're doing.


While I don't advocate (much) writing the binary $\mathrm{mod}$ operator in modular arithmetic, translating a problem from ordinary integer arithmetic (with binary modulo operators) to modular arithmetic can be useful, for example as shown here.

David K
  • 98,388
0

Notice first that the two $+$ simbols in Property 1 represent two different operations, one represent the standard addition and the second the addition modulo $n$. For the last equality it is indeed true that $3(\mod 2)+5(\mod 2)=8(\mod 2) $. In fact $3\mod 2=1$ since dividing 3 by 2 we obtain 1 as reminder; again $5\mod 2=1$ since dividing 5 by 2 we obtain 1 as reminder and thus $3(\mod 2)+5(\mod 2)=(1+1)\mod 2=2\mod2=0\mod 2$ since $2$ divided by 2 leaves no reminder. On the other side $8(\mod 2)=0$ since $8$ divided by 2 leaves no reminder.

To make another example. Think now to a 12-hour clock. Suppose you start to look ad it at midnight when it marks $0$ then wait 3 times 6 hours so 18 hours and then other 5 times six hours (other 30 hours). You have waited 48 hours in total (2 days) at the end the clock marks again midnight (again $0$). So looking the clock

$$18(\mod 12)+30(\mod 12)=48 (\mod 12)=0(\mod 12)$$

coherently with the fact that $18(\mod 12)=6(\mod 12)$, $(30\mod 12)=6(\mod 12)$, hence $18(\mod 12)+(30\mod 12)=(6+6)(\mod 12) =12 (\mod 12)=0(\mod 12)$ and $48=0\mod 12$.

Remember that modular arithmetic is also called the clock-arithmetic.

Mathland
  • 526
0

The $\bmod$ symbol is used in two different way. First it is used as binary operator. $$a\bmod m$$ is the remainder that you get if you divide $a$ by $m.$ Second it is used to specify the binary relation $\equiv$. So $$a\equiv b \pmod m$$ means that $(a\bmod m) = (b\bmod m)$ or equivalently that $m|(a-b).$ One can omit the symbol $m$ if its value of $m$ is clear from the context.

So you property 1 should be more clearly written as $$a+b=c \implies (a \bmod N)+(b \bmod N)\equiv (c \bmod N) \pmod N \tag 1$$ The first three parentheses pairs are redundant because of the operator precedence rules an can be omitted. The last one you better leave for clarity. So you get $$a+b=c \implies a \bmod N+b \bmod N\equiv c \bmod N \pmod N \tag{1'}$$ Note that already the following holds if $(1)$ or $a+b=c$ holds $$a+b\equiv c \pmod N \tag{2}$$ because $a+b-c=0$ and so $m|a+b-c.$

But the following equation is not always not valid if $a+b=c$: $$(a \bmod N)+(b \bmod N)= (c \bmod N) \tag3$$

You already found a counterexample:

$$3\bmod +5\bmod2\neq 8\bmod 2$$

but of course the following holds

$$3\bmod +5\bmod2 \equiv 8\bmod 2 \pmod2$$

miracle173
  • 11,049
  • Better still, do not use the binary mod operator at all. It is redundant in this context. – David K Nov 21 '21 at 15:28
  • @DavidK No, I don't think so. If you want express a property of the binary mod operator as in $(1)$, than you have to use it. But I will add to the post that the relation will the even hold without the binary mod operator – miracle173 Nov 21 '21 at 15:34