10

(I've come here from this question.)

What's the difference between modulus and remainder?

(Bearing in mind until 5 minutes ago I thought they were the same :P )

ACarter
  • 238
  • 1
  • 2
  • 9

3 Answers3

6

Let's say we have integers $a $ and $b$. The $remainder$ of $a$ divided by $b$ is the number $r$ such that $a = qb +r$ for some $q\in\mathbb{Z}$ (here $\mathbb{Z}$ is the set of integers), and $0\leq r <b$. In this situation, $r$ is uniquely determined. That is, there is only one value of $r$ which satisfies these requirements, and so we say that $r$ is $the$ remainder of $a$ divided by $b$.

Modulus, in this situation, refers to the number $b$. However, given the context, I think what you meant to refer to was "$a$ mod $b$", or the class of $a$ modulo $b$, which is actually an infinite set of integers. Precisely, the class of $a$ modulo $b$ is the set \begin{equation*} a+b\mathbb{Z} = \left\{a+bn\;|\;n\in\mathbb{Z}\right\}.\end{equation*} Every number in this set yields the same remainder after division by $b$. So, for example, $5$ mod $7$ is the same as $12$ mod $7$, because we have the equality of sets \begin{equation*} 5+7\mathbb{Z} = 12 + 7\mathbb{Z}. \end{equation*} Often, people say "$12 $ mod $7 = 5$," which is technically incorrect. What we should say is "the class of 12 mod 7 is equal to the class of 5 mod 7", or "5 and 12 are equivalent modulo 7". When working modulo $n$, we have a preferred set of representatives for each class modulo $n$, which is usually \begin{equation*} \{0,1,...n-1\}.\end{equation*}That means that every number is equivalent to one of these numbers modulo $n$. When we use this particular set of class representatives, they just so happen to coincide with the usual notion of remainder.

  • Ok, thanks. Little bit confused, what exactly is $\mathbb{Z}$? – ACarter May 19 '14 at 20:26
  • @ACarter As I said in the post, $\mathbb{Z}$ is the set of all integers, so $\mathbb{Z} = ...-2,-1,0,1,2,3,...$ – ChocolateAndCheese May 19 '14 at 20:30
  • Ok. So when you say $5+7\mathbb{Z} = 12 + 7\mathbb{Z}$, is the 7 multiplying the set? Sorry, I'm very new to all this notation. – ACarter May 19 '14 at 20:33
  • @ACarter Yes, sorry if that wasn't clear. $5+7\mathbb{Z}$ is the set of all numbers which are $5$ plus a multiple of $7$, so all numbers like $...-9,-2,5,12,19,26,...$ In other words, start at $5$ and count by $7$'s. – ChocolateAndCheese May 19 '14 at 20:48
  • Notice how, starting at $5$ and counting by $7$'s, you get the same set of numbers as you would starting at $12$ and counting by $7$'s. That is why, as sets, $5+7\mathbb{Z} = 12+7\mathbb{Z}$. – ChocolateAndCheese May 19 '14 at 20:51
  • Ah I see, that makes sense! And that's becuase $12 - 5 = 7$ (or any multiple of 7), I see. – ACarter May 19 '14 at 20:56
  • Also, what is the | operator? (As in your first equation). Thanks for the help! – ACarter May 19 '14 at 20:58
  • To your first comment, Yes exactly! For your second comment, the symbol "|" is not division, rather it is set notation, and means "such that". See this page: http://www.mathsisfun.com/sets/set-builder-notation.html – ChocolateAndCheese May 19 '14 at 21:12
  • I'm still confused. You say that the numbers coincide (between modulo and remainder). Could you give an example where they don't? – SMBiggs Aug 25 '19 at 21:30
  • @ScottBiggs The class of $a$ mod $b$ is the set of all numbers that have remainder $a$ when divided by $b$. So, the class of 3 mod 7 is the infinite set of set of numbers ${...-18, -11, -4, 3, 10, 17, 24...} = { 3 + n7 ;|; n\in \mathbb{Z}}$. This is precisely the set of numbers that have remainder 3 when divided by 7. – ChocolateAndCheese Sep 20 '19 at 01:36
2

The modulus in a modular equation $\pmod{n}$ is the number $n$. That is exactly what "mod n" refers to.

The set of integers with the same remainder forms an equivalence class that's sometimes called "the residue modulo $n$."

For and integer $a$ and a positive integer $b$, the division algorithm says that there exists unique integers $q,r$ such that $a=bq+r$ and $0\leq r<b$.

They are related in the sense that $a\equiv a'\pmod b$ iff $a$ and $a'$ have the same remainder after division by the modulus $b$.

rschwieb
  • 153,510
  • Ok, thankyou. So $\pmod{n} = n$? Meaning $\pmod{n}$ in maths is not the same as $\pmod{n}$ in computing? – ACarter May 19 '14 at 20:17
  • @ACarter Don't most programming languages return the lowest nonnegative residue? I don't think they are very different... Maybe you can tell me why you think thy are different. – rschwieb May 19 '14 at 21:30
1

Modulus can refer to a couple of different things depending on the context. There is modulus in the sense of modular arithmetic (the base number under consideration), there is modulus of complex number (think absolute value) and there is a notion of modulus in algebraic number theory.