0% found this document useful (0 votes)
293 views70 pages

Modular Number

The document discusses modular arithmetic and clock arithmetic. Some key points: - Modular arithmetic involves calculating with integers modulo a number (called the modulus), such that numbers "wrap around" after reaching the modulus. - Clock arithmetic is a type of modular arithmetic where the modulus is 12 or 24, modeling the numbers on a 12-hour or 24-hour clock. - In clock arithmetic, addition and subtraction work by finding the remainder after dividing the sum or difference by the modulus. For example, 8 + 7 = 3 (mod 12) since 15 divided by 12 has remainder 3.

Uploaded by

PeiEnOng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
293 views70 pages

Modular Number

The document discusses modular arithmetic and clock arithmetic. Some key points: - Modular arithmetic involves calculating with integers modulo a number (called the modulus), such that numbers "wrap around" after reaching the modulus. - Clock arithmetic is a type of modular arithmetic where the modulus is 12 or 24, modeling the numbers on a 12-hour or 24-hour clock. - In clock arithmetic, addition and subtraction work by finding the remainder after dividing the sum or difference by the modulus. For example, 8 + 7 = 3 (mod 12) since 15 divided by 12 has remainder 3.

Uploaded by

PeiEnOng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 70

Lecture: Week 12

Modular Numbers and Magic Squares

Modular numbers
-Modular numbers up to mod 12

Formulae to determine the sum, difference


and product involving modular numbers: If a
= b(mod c), d = e(mod c), then
oa + d = b(mod c) + e(mod c),
oa d = b(mod c) - e(mod c),
a x d = b(mod c) x e(mod c).
Also known as clock arithmetic
* Suppose it is now 8 oclock in the morning and
you plan to study for 7 hours. What time will it
be when you have finished studying?
* Suppose it is now 8 oclock in the morning and
you plan to study for 7 hours. What time will it
be when you have finished studying?
* It will be 3 oclock in the evening, of course.
* In this setting, 8 + 7 = 3,
* Hence, 8 + 7 15 because the only numbers
on the clock are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
and 12.
* Suppose it is now 8 oclock in the morning and
we are in classroom. 9 hours before you were
sleeping in your bedroom. What time was it
you were in bedroom?
* Suppose it is now 8 oclock in the morning and
we are in classroom. 9 hours before you were
sleeping in your bedroom. What time was it
you were in bedroom?
* It will be 11 oclock, of course.
* In this setting, 8 - 9 = 11,
* Hence, 8 - 9 -1 because the only numbers on
the clock are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
and 12.
In mathematics,modular arithmetic
(sometimes calledclock arithmetic) is a system
ofarithmeticforintegers, where numbers
"wrap around" after they reach a certain value
- The modulus.
*The Swiss mathematician Leonhard Euler
pioneered the modern approach to congruence in
about 1750, when he explicitly introduced the
idea of congruencemoduloa numberN.
*Modular arithmetic was further advanced
byCarl Friedrich Gaussian
* For a positive integern, two integersaandb
are said to becongruentmodulon,
written:

* if their differenceabis an integermultiple


ofn, the numbernis called themodulusof the
congruence.
* For example, because
3814=24, which is a multiple of12.
* http://
www.artofproblemsolving.com/wiki/index.php/
Modular_arithmetic/Introduction
* Note that the answer is the remainder when the sum is divided by 12
8 + 7 = 15 and 15 12 = 1 remainder 3

Similarly,
* 9 + 7 = 16 and 16 12 = 1
remainder 4
* 3 + 15 = 18 and 18 12 = 1
remainder 6
* 2 + 9 = 11 and 11 12 = 0
remainder 11
* 12 + 15 = 27 and 27 12 = 2 remainder 3
Definition
*Two numbers a and b, are congruent modulo m
if the difference between them, a - b is divisible
by m.
*

a b (mod m)
* 27 is congruent to 3 modulo 12 since the
difference between 27 and 3 is 24, and 24 is
divisible by 12,
* 27 3 (mod 12)
* Similarly, 15 and 39
are also congruent to 3
modulo 12, 39 3 (mod 12)
* 15 3 (mod 12)
These are also true.
12 0 (mod 12)
14 2 (mod 12)
29 5 (mod 12)
59 ___(mod 12)
36 ___(mod 12)
* (a mod n) means the remainder
when a is divided by n.

* a mod n = r

* a = dn + r for some integer d
(a mod n) means the remainder
when a is divided by n.

a mod n = r

a = dn + r for some integer d


Definition: Modular equivalence
a b [mod n]
(a mod n) = (b mod n)
n | (a-b)

31 81 [mod 2] Written as a n b,
31 2 81
and spoken
a and b are
31 80 [mod 7] equivalent or
31 7 80 congruent modulo
n
n is an equivalence relation

In other words, it is

Reflexive: a n a

Symmetric: (a n b) (b n a)

Transitive: (a n b and b n c) (a n
c)
n induces a natural partition of the
integers into n residue classes.

(residue = what left over = remainder)

Define residue class


[k] = the set of all integers
that are congruent to k
modulo n.
Residue Classes Mod 3:

[0] = { , -6, -3, 0, 3, 6, ..}


[1] = { , -5, -2, 1, 4, 7, ..}
[2] = { , -4, -1, 2, 5, 8, ..}

[-6] = { , -6, -3, 0, 3, 6, ..} = [0]


[7] = { , -5, -2, 1, 4, 7, ..} = [1]
[-1] = { , -4, -1, 2, 5, 8, ..} = [2]
Why do we care about these
residue classes?
Because we can replace any member
of a residue class with another member
when doing addition or multiplication mod n
and the answer will not change

To calculate: 249 * 504 mod 251

just do -2 * 2 = -4 = 247

We also care about it because computers do


arithmetic modulo n, where n is 2^32 or 2^64.
Fundamental lemma of
plus and times mod n:

If (x n y) and (a n b). Then

1) x + a n y + b
2) x * a n y * b
Proof of 2: xa = yb (mod n)
(The other proof is similar)

xny iff x = i n + y for some integer i


anb iff a = j n + b for some integer j

xa = (i n + y)(j n + b) = n(ijn+ib+jy) + y
nyb
Another Simple Fact:
If (x n y) and (k|n), then: x k y

Example: 10 6 16 10 3 16

Proof:
x n y iff x = in + y for some integer i
Let j=n/k, or n=jk Then we have:
x = ijk + y

x = (ij)k + y therefore x k y
A Unique Representation System
Modulo n:

We pick one representative from


each residue class and do all our
calculations using these representatives.

Unsurprisingly, we use 0, 1, 2, , n-1


Unique representation system mod 3

Finite set S = {0, 1, 2}

+ and * defined on S:

+ 0 1 2 * 0 1 2
0 0 1 2 0 0 0 0
1 1 2 0 1 0 1 2
2 2 0 1 2 0 2 1
Unique representation system mod 4

Finite set S = {0, 1, 2, 3}

+ and * defined on S:
+ 0 1 2 3 * 0 1 2 3
0 0 1 2 3 0 0 0 0 0
1 1 2 3 0 1 0 1 2 3
2 2 3 0 1 2 0 2 0 2
3 3 0 1 2 3 0 3 2 1
Notation

Zn = {0, 1, 2, , n-1}

Define operations +n and *n:

a +n b = (a + b mod n)
a *n b = (a * b mod n)
Some properties of the operation +n

[Closed]
x, y Zn x +n y Zn

[Associative]
x, y, z Zn (x +n y) +n z = x +n (y +n z)

[Commutative]
x, y Zn x +n y = y +n x

Similar properties also hold for *n


Unique representation system mod 3

Finite set S = {0, 1, 2}

+ and * defined on S:

+ 0 1 2 * 0 1 2
0 0 1 2 0 0 0 0
1 1 2 0 1 0 1 2
2 2 0 1 2 0 2 1
Unique representation system mod 3

Finite set Z3 = {0, 1, 2}

two associative, commutative operators on Z3


Unique representation system mod 3

Finite set Z3 = {0, 1, 2}

two associative, commutative operators on Z3

+ 0 1 2 * 0 1 2
0 0 1 2 0 0 0 0
1 1 2 0 1 0 1 2
2 2 0 1 2 0 2 1
Unique representation system mod 2

Finite set Z2 = {0, 1}

two associative, commutative operators on Z2

+2 *2
0 1 0 1
XOR AND

0 0 1 0 0 0

1 1 0 1 0 1
Z5 = {0,1,2,3,4}

+ 0 1 2 3 4 * 0 1 2 3 4
0 0 1 2 3 4 0 0 0 0 0 0
1 1 2 3 4 0 1 0 1 2 3
2 2 3 4 0 1 2 0
3 3 4 0 1 2 3 0 3 1 4
4 4 0 1 2 3 4 0 4 3 2
Z6 = {0,1,2,3,4,5}

+ 0 1 2 3 4 5 * 0 1 2 3 4 5
0 0 1 2 3 4 5 0 0 0 0 0 0
1 1 2 3 4 5 0 1 0 1 2 3 4
2 2 3 4 5 0 1 2 0 2 4 0 2
3 3 4 5 0 1 2 3 0
4 4 5 0 1 2 3 4 0 4 2 0 4
5 5 0 1 2 3 4 5 0 5 4 3 2
For addition tables, rows and columns
always are a permutation of Zn
(A group as well see later in the course.)

+ 0 1 2 3 4 5
+ 0 1 2 3 4 0 0 1 2 3 4 5
0 0 1 2 3 4 1 1 2 3 4 5 0
1 1 2 3 4 0 2 2 3 4 5 0 1
2 2 3 4 0 1 3 3 4 5 0 1 2
3 3 4 0 1 2 4 4 5 0 1 2 3
4 4 0 1 2 3 5 5 0 1 2 3 4
For multiplication, some rows and columns
are permutation of Zn, while others arent
* 0 1 2 3 4 * 0 1 2 3 4 5

0 0 0 0 0 0 0 0 0 0 0 0 0

1 0 1 2 3 4 1 0 1 2 3 4 5

2 0 2 4 1 3 2 0 2 4 0 2 4

3 0 3 1 4 2 3 0 3 0 3 0 3

4 0 4 3 2 1 4 0 4 2 0 4 2
5 0 5 4 3 2 1
whats happening here?
For addition, the permutation property
means you can solve, say,
4 + ___ = 1 (mod 6)
4 + ___ = x (mod 6) for any x in Z6

Subtraction mod n is + 0 1 2 3 4 5
well-defined 0 0 1 2 3 4 5
1 1 2 3 4 5 0
Each row has a 0, 2 2 3 4 5 0 1
hence a is that element
3 3 4 5 0 1 2
such that a + (-a) = 0
4 4 5 0 1 2 3
a b = a + (-b) 5 5 0 1 2 3 4
For multiplication, if a row has a permutation
you can solve, say,
5 * ___ = 4 (mod 6)
or, 5 * ___ = 1 (mod 6)

* 0 1 2 3 4 5
0 0 0 0 0 0 0
1 0 1 2 3 4 5
2 0 2 4 0 2 4
3 0 3 0 3 0 3
4 0 4 2 0 4 2
5 0 5 4 3 2 1
But if the row does not have the permutation
property, how do you solve
no solutions! 3 * ___ = 4 (mod 6)
multiple solutions! 3 * ___ = 3 (mod 6)

* 0 1 2 3 4 5
0 0 0 0 0 0 0
1 0 1 2 3 4 5
3 * ___ = 1 (mod 6) 2 0 2 4 0 2 4
3 0 3 0 3 0 3
no multiplicative
4 0 4 2 0 4 2
inverse!
5 0 5 4 3 2 1
Division
If you define 1/a (mod n) = a-1 (mod n)
as the element b in Zn
such that a * b = 1 (mod n)

Then x/y (mod n)


=
x * 1/y (mod n)

Hence we can divide out by only the ys


for which 1/y is defined!
And which rows do have the permutation property?

* 0 1 2 3 4 5 6 7
0 0 0 0 0 0 0 0 0
1 0 1 2 3 4 5 6 7

2 0 2

3 0 3

4 0 4

5 0 5

6 0 6

7 0 7

consider *8 on Z8
A visual way to understand
multiplication
and the
permutation property.
There are exactly 8 distinct
multiples of 3 modulo 8.
0
7
1

6
2

5 3

hit all numbers row 3 has the permutation property


There are exactly 2 distinct
multiples of 4 modulo 8.
0
7
1

6
2

5 3

row 4 does not have permutation property for *8 on Z8


There are exactly 1 distinct
multiples of 8 modulo 8.
0
7
1

6
2

5 3

4
There are exactly 4 distinct
multiples of 6 modulo 8.
0
7
1

6
2

5 3

4
* exactly 8 distinct multiples of 3 modulo 8.
* exactly 2 distinct multiples of 4 modulo 8
* exactly 1 distinct multiple of 8 modulo 8
* exactly 4 distinct multiples of 6 modulo 8

* exactly __________________ distinct

multiples of x modulo y
Theorem: There are exactly
LCM(n,c)/c = n/GCD(c,n)
distinct multiples of c modulo n
Theorem: There are exactly k = n/GCD(c,n)
distinct multiples of c modulo n, and these
multiples are { c*i mod n | 0 i < k }

Proof:
Clearly, c/GCD(c,n) 1 is a whole number

ck = cn/GCD(c,n) = n(c/GCD(c,n)) n 0
There are k distinct multiples of c mod n:
c*0, c*1, c*2, , c*(k-1)

Also, k = factors of n missing from c


cx n cy n|c(x-y) k|(x-y) x-y k
There are k multiples of c.

Hence exactly k.
Theorem: There are exactly
LCM(n,c)/c = n/GCD(c,n)
distinct multiples of c modulo n

Hence,
only those values of c with GCD(c,n) = 1
have n distinct multiples
(i.e., the permutation property for *n on
Zn )
And remember, permutation property means
you can divide out by c (working mod n)
Fundamental lemma of division
modulo n:
if GCD(c,n)=1, then ca n cb a n b
Proof:
c*1, c*2, c*3, , c*(n-1) are all in distinct
residue classes modulo n.

Q E D.
If you want to extend to
general c and n

ca n cb a n/gcd(c,n) b
Fundamental lemmas mod n:

If (x n y) and (a n b). Then

1) x + a n y + b
2) x * a n y * b
3) x - a n y b
if gcd(c,n)=1
4) cx n cy a n b
New definition:

Zn* = {x Zn | GCD(x,n) =1}

Multiplication over this set Zn*


has the cancellation property.
Z6 = {0, 1,2,3,4,5}
Z6* = {1,5}

+ 0 1 2 3 4 5 * 0 1 2 3 4 5

0 0 1 2 3 4 5 0 0 0 0 0 0 0

1 1 2 3 4 5 0 1 0 1 2 3 4 5

2 2 3 4 5 0 1 2 0 2 4 0 2 4

3 3 4 5 0 1 2 3 0 3 0 3 0 3

4 4 5 0 1 2 3 4 0 4 2 0 4 2

5 5 0 1 2 3 4 5 0 5 4 3 2 1
Weve got closure
Recall we proved that Zn was closed
under addition and multiplication?

What about Zn* under multiplication?

Fact: if a,b Zn*, then ab (mod n) in Zn*

Proof: if gcd(a,n) = gcd(b,n) = 1,


then gcd(ab, n) = 1
then gcd(ab mod n, n) = 1
Z12* = {0 x < 12 | gcd(x,12) = 1}
= {1,5,7,11}

*12 1 5 7 11

1 1 5 7 11
5 5 1 11 7
7 7 11 1 5
11 11 7 5 1
Z15*

* 1 2 4 7 8 11 13 14

1 1 2 4 7 8 11 13 14
2 2 4 8 14 1 7 11 13
4 4 8 1 13 2 14 7 11
7 7 14 13 4 11 2 1 8
8 8 1 2 11 4 13 14 7
11 11 7 14 2 13 1 8 4
13 13 11 7 1 14 8 4 2
14 14 13 11 8 7 4 2 1
Z5* = {1,2,3,4} = Z5 \ {0}

*
1 2 3 4
5

1 1 2 3 4
2 2 4 1 3
3 3 1 4 2
4 4 3 2 1
Fact:
For prime p, the set Zp* = Zp \ {0}

Proof:
It just follows from the
definition!

For prime p, all 0 < x < p


satisfy
gcd(x,p) = 1

You might also like