Modular Arithmetic

Modular arithmetic is a fascinating branch of mathematics that deals with numbers “wrapping around” when they reach a certain value, known as the modulus. Here are the key concepts:
Definition:
In modular arithmetic, we work with integers and consider their remainders when divided by a fixed quantity (the modulus).
Think of it like a clock: after reaching 12 hours, the clock “wraps around” to 1.
The modern approach to modular arithmetic was developed by Carl Friedrich Gauss

The Modulus
If a  is an integer and n is a positive integer, we define amodn to be the remainder when a is divided by n . The integer is called the modulus. Thus, for any integer ,

a=qn+r0r<nq=a/n

r=aa/n.n
Example:
11mod7=4 and 11mod7=3

Two integers a and b are  said to congruent modulo n, if amodn=bmodn.This is written as

ab(modn)
Example:
516(mod11) and 25(mod3)

Note that if a0(modn), then n|a.

Properties of Congruences
Congruences have the following properties
1.ab(modn) if n|(ab)
Note: If n|(ab), then(ab)=kn for some k. So we can write a=b+knmodn. This implies abmodn
2.If ab(modn) implies ba(modn)
3.ab(modn)  and bc(modn) imply ac(modn)

Example:
238(mod5) implies 5|238 ie; 5|15


Modular Arithmetic Operations
Note that, by definition , the (mod ) operator maps all integers into the set of integers {0,1,,(n1)}.This suggests the question: Can we perform arithmetic operations within the confines of this set? It turns out that we can; this technique is known as modular arithmetic.

Modular Addition:
Rule for modular addition: (a+b)modm=((amodm)+(bmodm))modm

Example: 
(15+17)mod7=((15mod7)+(17mod7))mod7=(1+3)mod7=4mod7. This is same as 32mod7=4mod7
Proof:
Define amodn=ra and bmodn=rb.
Then we can write a=j.n+ra for some integer j  and b=k.n+rbfor some integer k.
.Then
(a+b)modn=j.n+ra+k.n+rbmodn
(a+b)modn=ra+rb+j.n+k.nmodn
(a+b)modn=ra+rbmodn
(a+b)modn=(amodn+bmodn)modn

Modular Subtraction:
Rule for modular addition: (ab)modm=((amodm)(bmodm))modm

Example: 
(1715)mod7=((17mod7)(15mod7))mod7=(31)mod7=2mod7. This is same as 2mod7
Proof:
Define amodn=ra and bmodn=rb.
Then we can write a=j.n+ra for some integer j  and b=k.n+rbfor some integer k.
.Then
(ab)modn=j.n+ra(k.n+rb)modn
(ab)modn=rarb+(j.nk.n)modn
(ab)modn=rarbmodn
(ab)modn=(amodnbmodn)modn

Modular Multiplication:
Rule for modular multiplication:  (ab)modm=((amodm)(bmodm))modm 

Example: 
((1213)mod5=((12mod5)(13mod5))mod5=(23)mod5=6mod5=1)
Proof:
Define amodn=ra and bmodn=rb.
Then we can write a=j.n+ra for some integer j  and b=k.n+rbfor some integer k.
.Then
(ab)modn=(j.n+ra)(k.n+rb)modn
(ab)modn=rarb+(j.nk.n+j.nrb+rak.n)modn
(ab)modn=rarbmodn
(ab)modn=(amodnbmodn)modn

Modular Exponentiation:
Finding (abmodm) is modular exponentiation.
It can be done recursively or iteratively.

Example: 
For a=15,b=2 , and m=7, (152)mod7=225mod7=1mod7
This is same as (15mod715mod7)mod7=11mod7=1mod7

To find To find 117mod13, we can proceed iteratively as follows:
112=1214(mod13)

114=(112)2423(mod13)

Thus,
117=11112114=11431322(mod13)

Thus, the rules for ordinary arithmetic involving addition, subtraction, and multiplication carry over into modular arithmetic.
Table below provides an illustration of modular addition and multiplication modulo 8. Looking at addition, the results are straightforward, and there is a regular pattern to the matrix. Both matrices are symmetric about the main diagonal in conformance to the commutative property of addition and multiplication. As in ordinary addition, there is an additive inverse, or negative, to each integer in modular arithmetic. In this case, the negative of an integer x is the integer y such that (x+y)mod8=0.
To find the additive inverse of an integer in the left-hand column,scan across the corresponding row of the matrix to find the value 0; the integer at the top of that column is the additive inverse; thus,(2+6)mod8=0

Similarly, the entries in the multiplication table are straightforward. In ordinary arithmetic, there is a multiplicative inverse, or reciprocal, to each integer. In modular arithmetic mod 8, the multiplicative inverse of x is the integer y such that .xymod8=1mod8.

Now, to find the multiplicative inverse of an integer from the multiplication table, scan across the matrix in the row for that integer to find the value 1; the integer at the top of that column is the multiplicative inverse; thus, 33=1mod8. Note that not all integers mod 8 have a multiplicative inverse.In general, an integer has a multiplicative inverse in Zn ,if that integer is relatively prime to n.Table below  shows that the integers 1, 3, 5, and 7 have a multiplicative inverse in ; but 2, 4, and 6 do not.


There is one peculiarity of modular arithmetic that sets it apart from ordinary arithmetic. First, observe that (as in ordinary arithmetic) we can write the following:
a+ba+c(modn)thenbc(modn)
Example:
5+235+7(mod8)then237(mod8)

The above equation  is consistent with the existence of an additive inverse. Adding the additive inverse of to both sides of Equation, we have
a+b+ba+a+c(modn)
bc(modn)
However, the following statement is true only with the attached condition:
If a×ba×cmodn then bcmodn. If a is relatively prime to n.

Recall that two integers are relatively prime if their only common positive integer factor is 1.ie;gcd(a,n)=1



Comments

Popular posts from this blog

Number Theory CST 292 KTU IV Semester Honors Course Notes Dr Binu V P 9847390760

Sum of Squares

Well Ordering Principle