I am reading Notes of Mathematics for Computer Science(MIT 6.042J). And I'm stuck in the Modular Arithmetic Section which I mark with a RED LINE.

I want to know what is trying to say. Is it trying to say that $(\operatorname{mod} 7)$ is neither associated with $29$ nor $15$? Here the Picture of that Equation

  • $\begingroup$ The author is probably trying to help their readers. People with programming background often associate mod with the remainder operation. That is more accurately called binary mod. That is a process that takes two integers as inputs and gives a third integer as an output. Such as $7\bmod 3 =1$. The congruence is semantically a comparison operator that takes two integers as inputs and gives a boolean (yes/no) output. Actually there is one comparison operator for each non-zero integer $m$. The $\pmod m$ just identifies which comparison operator is meant. $\endgroup$ – Jyrki Lahtonen Aug 29 '16 at 19:50
  • 1
    $\begingroup$ And, yes, he is trying to say that $\pmod 7$ is associated to neither $29$ nor $15$. If I need to make a pick I would say that it is associated to both $29$ and $15$ equally. If I remember C-notation correctly, then for positive integers we have $$a\equiv b\pmod m$$ if and only if $$(a\%m)==(b\%m)$$ Observe the double equality sign. This is a comparison operator. CAVEAT: Many programming languages and/or processors define $\%$ differently for negative inputs, and the above needs modifications. $\endgroup$ – Jyrki Lahtonen Aug 29 '16 at 20:01
  • 1
    $\begingroup$ @JyrkiLahtonen: This should be correct in all mainstream programming languages for integers $a,b,m$ where $m > 0$: $a \equiv b \pmod{m}$ iff $(a \% m + m) \% m == (b \% m + m) \% m$ iff $(a-b) \% m == 0$. $\endgroup$ – user21820 Aug 30 '16 at 6:29
  • $\begingroup$ Thanks @user21820. I vaguely recall using tricks like that when I was still coding (though I was using Pascal and its descendants, but the idea was the same). $\endgroup$ – Jyrki Lahtonen Aug 30 '16 at 6:51

This is largely a matter of finding whatever focus helps you to understand the process going on here. The $\pmod 7$ is describing what kind of equivalence ($\equiv$) we're using - so $\pmod 7$ is not "acting on" either of the numbers in reality. To bring the $\equiv$ and the $\pmod 7$ together, you could imagine that the comparator is written as $\color{red}{\underset{\bbox[2px]{\bmod 7}}{\equiv}}$ or even $\color{red}{\underset{\bbox[2px]{7}}{\equiv}}$ with reasonable clarity, if that is a useful way of understanding for you.

So what does $29 \equiv 15 \pmod 7$ (or in the above variant notation $29 \color{red}{\underset{\bbox[2px]7}{\equiv}} 15$) actually mean?

  • $29$ and $15$ sit in the same relation to the nearest respective multiples of $7$ - that is, $29$ is the same position in $(28, 35)$ as $15$ is in $(14,21)$
  • $(29-15)$ is divisible by $7$ (the two numbers are separated by an integer mulitple of $7$)
  • $29$ and $15$ have the same remainder when divided by $7$ (although for negative numbers this can be confusing/ambiguous).
  • $\begingroup$ Please Suggest some Books on Abstract Algebra and Number Theory or Modular Arithmetic. I am a beginner. I want to clear my Basic. $\endgroup$ – Bhaskar Aug 29 '16 at 21:43
  • 1
    $\begingroup$ @beast_f5 math.stackexchange.com/questions/837852/… $\endgroup$ – A---B Aug 29 '16 at 21:54
  • 1
    $\begingroup$ I specially like your first bullet point. In my imagination, that was the original meaning of modulo (namely, “with respect to the modulus”), and the modulus in question was the block of the first $7$ numbers. $\endgroup$ – Lubin Aug 30 '16 at 1:35
  • $\begingroup$ @Lubin Thanks, I put that one first to relate more strongly to the clock arithmetic idea. $\endgroup$ – Joffan Aug 30 '16 at 12:35

The author is talking about the placement of the phrase "(mod 7)". What the expression $29\equiv15$ (mod 7) is really saying is that 29 (mod 7) and 15 (mod 7) are equivalent. The placement of the "(mod 7)" after the 15 is not modifying the 15 alone, but the entire equivalent statement, i.e., $\left[29\equiv15\right]$ (mod 7). The author is really complaining about the way it is conventionally written, but is unable to do anything about it because the convention is "firmly entrenched."

In other words, don't worry about it. The author is just whining about the conventional notation, but it will not affect the overall mathematics.

  • $\begingroup$ When doing Arithmetic I can neglect the (mod 7) Suppose if we multiply something for eg:- (29 (mod 7)) * 5 = 29 * 5 (mod 7) $\endgroup$ – Bhaskar Aug 29 '16 at 19:47
  • $\begingroup$ @beast_f5 No. Here $\pmod 7$ means congruence. So $29\pmod7$ is syntactically wrong, i.e. gibberish. The formula is incomplete the same way, say $3+$, is. Parts are missing. $\endgroup$ – Jyrki Lahtonen Aug 29 '16 at 19:56
  • $\begingroup$ @JyrkiLahtonen Actully I am trying to say I can do Normal Airthmetic(Which are applicable in MOD. Airth.) And (Mod 7) or (Something under Mod is just act as symbol $\endgroup$ – Bhaskar Aug 29 '16 at 20:10
  • $\begingroup$ @beast_f5 In the language of congruences we do have rules like. IF $a\equiv b\pmod7$ THEN $5a\equiv5b\pmod7$ (et cetera). But in congruence notation $29\pmod 7$ is meaningless. It has no "value". A congruence is either true or false. Also it needs that other input integer. $29\equiv15\pmod7$ has value TRUE, $29\equiv14\pmod7$ has value FALSE. $29\pmod7$ alone is roughly like <blank>==0 in a piece of C-code. $\endgroup$ – Jyrki Lahtonen Aug 29 '16 at 20:16
  • $\begingroup$ @JyrkiLahtonen Will you Recommend any Book for Modular Arithmetic or In Number Theory. I want to Clear my basic. Please Recommend It will be very helpful for me. I am totally New in Modular Arithmetic $\endgroup$ – Bhaskar Aug 29 '16 at 20:20

It seems the point of the remark is to emphasize the symmetric property of the congruence relation i.e. $\,a\equiv b\iff b\equiv a\pmod m.\,$ This is not true for the operator mod, e.g we have $\,15\equiv 1\pmod 7\,$ and $\, (15\bmod 7) = 1\,$ and $\,1\equiv 15\pmod 7\,$ but $\ (1\bmod 7) \neq 15.\,$

The operational mod is antisymmetric since it converts its argument to normal form. The relational mod has no such preference, which often makes it more flexible in many contexts, e.g. $\,{\rm mod}\ 10\!:\,\ 9\equiv -1\,\Rightarrow\, 9^{2n}\equiv (-1)^{2n}\equiv ((-1)^2)^n\equiv 1^n\equiv 1,\,$ where we have used the flexibility of the congruence relation to choose a rep $\equiv 9\,$ which makes the power computation trivial.

Generally a congruence (to a fixed modulus) can be thought of as a generalized equality relation (i.e. an equivalence relation) that is, furthermore, consistent with the arithmetic operations (here obeys the Congruence Sum and Product Rules). This will be made more precise when you study quotient sets and algebras in abstract algebra.

  • $\begingroup$ I think the appropriate notation for $$\,a\equiv b\iff b\equiv a\pmod m.\,$$ is $$\,a\equiv b \pmod m \iff b\equiv a\pmod m\,$$ $\endgroup$ – miracle173 Aug 30 '16 at 17:42
  • $\begingroup$ @miracle One can use either. In fact it is not uncommon to omit $\,({\rm mod}\ m)\,$ if the modulus is fixed, e,g. many authors state "all congruences below are modulo $m$" $\ $ $\endgroup$ – Bill Dubuque Aug 30 '16 at 18:26

It is trying to say that we identify all numbers modulo $7$. So $15$ isn't any more equal (equivalent) to $7$ than $29$ is. In other words, $$29\equiv 15\equiv 1 \bmod 7, $$ so they are all equivalent to $1$. Perhaps the equal sign is clearer. In the ring $\mathbb{Z}/7\mathbb{Z}$, we really have equality: $29=15=1$. On the other hand, in the ring $\mathbb{Z}$, these numbers are not equal, but only equivalent modulo $7$.

  • $\begingroup$ It means modular arithmetic is just like normal Arithmetic $\endgroup$ – Bhaskar Aug 29 '16 at 19:37

In programming terms....

Because of some early programming languages and unfortunate choices of terminology, programmers often interpret "mod" as the remainder operator; e.g. 29%7 is the value 1.

But in mathematics, mod is an equivalence relation, which is, under a rather literal translation from mathematics to python:

def mod(n):
    return lambda x,y: (x-y) % n == 0

rel = mod(7) # Obtain the equivalence relation "mod 7"
rel(29, 15) # returns True

The text is trying to make sure you correctly interpret the phrase

$$ 29 \equiv 15 \pmod{7} $$



and not as

29 == 15 % 7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.