# Lecture 024

## Modular Arithmetic

$a \equiv b \pmod m \iff m | a-b$ congruence modulo m is equivalence relation $\mathbb{Z} /m \mathbb{Z} = \{[a]_m | a \in \mathbb{Z}\}$

For $m \in \mathbb{N}^+$: we have following theorems

### Same Remainder Theorem

$a \equiv b \pmod m \iff \text{a,b have same remainder when divided by m}$ TODO: proof

### Complete Residue System modulo m (Same Remainder Corollary)

Every integer is congruent to exactly one element in $\{{0, 1, ..., m-1}\}=\text{complete residue system modulo m}$

• definition: $\{a_1, ... a_m\}$ is CSRM iff every integer is congruent to exactly one element in the set under modulo m. (not necessarily from 0)

• there are infinite number of CSRM

• examples:

• The Least Non-negative Residues modulo m: $\{{0, 1, ..., m-1}\}$
• The Least Positive Residues modulo m: $\{1, 2, ..., m\}$
• The Least Absolute Residues modulo m:
• if m is odd: $\{0, 1, -1, ..., \frac{m-1}{2}, -\frac{m-1}{2}\}$
• if m is even: $\{0, 1, -1, ..., \frac{m-2}{2}, -\frac{m-2}{2}, \frac{m}{2}\}$

$\mathbb{Z} /m \mathbb{Z} = \{_m, _m, ..., [m-1]_m\}$

Why do we use: addition, subtraction, multiplication obey modulo math (not division)

### Modular Arithmetic Lemma

$a \equiv b \pmod m \land c \equiv d \pmod m \implies$

1. $a+c \equiv b+d \pmod m$
2. $ac \equiv bd \pmod m$

TODO: proof

Using Set Theory:

1. $[a]_m + [b]_m = [a+b]_m$
2. $[a]_m \times [b]_m = [ab]_m$

Examples

• Reduce constant: $x+10 \equiv x+3 \pmod 7 \implies 10 \equiv 3 \pmod 7$

• Add both side: $x\equiv y \pmod 7 \implies x+3 \equiv y+3 \pmod 7$

• Make a ring: $x\equiv y-3 \implies x \equiv y+4 \pmod 7$

• Multiply both side: $10 \equiv 3 \pmod 7 \implies 20 \equiv 6 \pmod 7$ because $10 \equiv 3 \pmod 7 \implies 10*2 \equiv 3*2 (\text{mod} 7/gcd(10*2, 3*2))$

• Substitution...

• Subtraction

### Corollary to Modular Arithmetic Lemma (power)

$a \equiv b \pmod m \implies a^n \equiv b^n \pmod m$ for $n \in \mathbb{Z}^+$

Counter Example:

• division something into fraction

• any division in general, except

### Division Theorem

$ac \equiv bc \pmod m \implies a \equiv b \pmod {\frac{m}{gcd(c, m)}}$

• observe that the remainder for ac, bc, a, b under these mod are the same.

TODO: proof

For multiplication, its like we have: $a \equiv b \pmod m \implies ac \equiv bc \pmod {mc}$ we know this fundamentally

• since $c | mc$, we can restrict above to simpler form

• $ac \equiv bc \pmod m$ TODO: need to check validity

For division, its like we have: $a \equiv b \pmod m \implies a/c \equiv b/c \pmod {m/c}$

• but m/c can be even smaller so that we can have bigger ring

• the furthest we can do is to make c and m coprime, since therefore any division TODO: need more thinkings here

### Multiplicative Inverse (MIRP)

$\text{a and m are relatively prime} \iff ab\equiv 1 \pmod m)$

### Unique Inverse Corollary

Inverse are unique under mod m

### Existence of Inverse Corollary

$(\exists m \in \mathbb{Z})(ax \equiv b \pmod m) \iff gcd(a, m) | b$

### Finding a inverse

$ax \equiv 1 \pmod m$

1. guess and check

2. guess x for all x up to m in which gcd(m, x) = 1

3. or perhaps the negative of the first half of result above

## Summary

To find a solution to equivalence (or 50x+71y=1 thing)

• first find if has an inverse gcd(a,b)=1

• then gcd(big, small) to =1

• then write 1=big-small*(multiple)

• then expand the smaller value

• then you find inverse of x

• use what you given to find equivalence by x*x^-1=1

Table of Content