Difference between revisions of "Modular arithmetic"

Line 37: Line 37:
 
* [[Number theory]]
 
* [[Number theory]]
 
* [[Quadratic residues]]
 
* [[Quadratic residues]]
 +
 +
== Miscellany ==
 +
 +
=== The binary operation "mod" ===
 +
 +
Related to the concept of congruence mod <math>n</math> is the binary operation '''<math>a</math> mod <math>n</math>''', which is used often in computer programming.
 +
 +
Recall that, by the [[Division Algorithm]], given any two integers <math>a</math> and <math>n</math>, with <math>n > 0</math>, we can find integers <math>q</math> and <math>r</math>, with <math>0 \leq r < n </math>, such that <math>a = nq + r</math>.  The number <math>q</math> is called the ''quotient'', and the number <math>r</math> is called the ''remainder''.  The operation ''<math>a</math> mod <math>n</math>'' returns the value of the remainder <math>r</math>.  For example:
 +
 +
<math>15</math> mod <math>6 = 3</math>, since <math>15 = 6 \cdot 2 + 3</math>.
 +
 +
<math>35</math> mod <math>7 = 0</math>, since <math>35 = 7 \cdot 5 + 0</math>.
 +
 +
<math>-10</math> mod <math>8 = 6</math>, since <math>-10 = 8 \cdot -2 + 6</math>.
 +
 +
Observe that if <math>a</math> mod <math>n = r</math>, then we also have <math>a \equiv r</math> (mod <math>n</math>).

Revision as of 14:05, 24 June 2006

Modular arithmetic is a special type of arithmetic that involves only integers. Given integers $a$, $b$, and $n$, with $n > 0$, we say that $a$ is congruent to $b$ modulo $n$, or $a \equiv b$ (mod $n$), if the difference ${a - b}$ is divisible by $n$.

For a given positive integer $n$, the relation $a \equiv b$ (mod $n$) is an equivalence relation on the set of integers. This relation gives rise to an algebraic structure called the integers modulo $n$ (usually known as "the integers mod $n$," or $\mathbb{Z}_n$ for short). This structure gives us a useful tool for solving a wide range of number-theoretic problems, including finding solutions to Diophantine equations, testing whether certain large numbers are prime, and even some problems in cryptology.


Introductory

Useful Facts

Consider four integers ${a},{b},{c},{d}$ and a positive integer ${m}$ such that $a\equiv b\pmod {m}$ and $c\equiv d\pmod {m}$. In modular arithmetic, the following identities hold:

  • Addition: $a+c\equiv b+d\pmod {m}$.
  • Substraction: $a-c\equiv b-d\pmod {m}$.
  • Multiplication: $ac\equiv bd\pmod {m}$.
  • Division: $\frac{a}{e}\equiv \frac{b}{e}\pmod {\frac{m}{\gcd(m,e)}}$, where $e$ is a positive integer that divides ${a}$ and $b$.
  • Exponentiation: $a^e\equiv b^e\pmod {m}$ where $e$ is a positive integer.

Examples

  • ${7}\equiv {1} \pmod {2}$
  • $49^2\equiv 7^4\equiv (1)^4\equiv 1 \pmod {6}$
  • $7a\equiv 14\pmod {49}\implies a\equiv 2\pmod {7}$

Applications

Modular arithmetic is an extremely useful tool in mathematics competitions. It enables us to easily solve Linear Diophantine equations, and it often helps with other Diophantine equations as well.

Intermediate

Topics

See also

Miscellany

The binary operation "mod"

Related to the concept of congruence mod $n$ is the binary operation $a$ mod $n$, which is used often in computer programming.

Recall that, by the Division Algorithm, given any two integers $a$ and $n$, with $n > 0$, we can find integers $q$ and $r$, with $0 \leq r < n$, such that $a = nq + r$. The number $q$ is called the quotient, and the number $r$ is called the remainder. The operation $a$ mod $n$ returns the value of the remainder $r$. For example:

$15$ mod $6 = 3$, since $15 = 6 \cdot 2 + 3$.

$35$ mod $7 = 0$, since $35 = 7 \cdot 5 + 0$.

$-10$ mod $8 = 6$, since $-10 = 8 \cdot -2 + 6$.

Observe that if $a$ mod $n = r$, then we also have $a \equiv r$ (mod $n$).