CH 01 B Modular Arithmetic
CH 01 B Modular Arithmetic
21-Jan-22
Set of Integers (z)
21-Jan-22
Modulo Operator
⚫ Find the result of the following operations:
a) 27 mod 5
b) 36 mod 12
c) −18 mod 14
d) −7 mod 10
21-Jan-22
Modulo Operator
a) 27 mod 5 27/5 gives remainder =2
21-Jan-22
Set of Residues
⚫ The modulo operation creates a set, which in
modular arithmetic is referred to as the set of least
residues modulo n, or Zn.
21-Jan-22
Congruence (≡ operator)
⚫ To show that two integers are congruent, we use
the congruence operator ( ≡ ).
⚫ It indicates equality in modulus.
⚫ 2 mod 10= 2
⚫ 12 mod 10=2
⚫ 3 mod 5=3
⚫ 8 mod 5=3
21-Jan-22
Residue Classes
⚫ A residue class [a] or [a]n is the set of integers
congruent modulo n.
⚫ For example n=5
⚫ Z5={0, 1, 2, 3, 4}
⚫ Then we have 5 residue classes.
21-Jan-22
Comparison of Z and Zn using graphs
21-Jan-22
Operation in Zn
21-Jan-22
Operation in Zn
Perform the following operations (the inputs
come from Zn):
1. Add 7 to 14 in Z15.
2. Subtract 11 from 7 in Z13.
3. Multiply 11 by 7 in Z20.
21-Jan-22
Zn Operation properties
21-Jan-22
Zn Operation properties
21-Jan-22
Additive Inverse
⚫ In Zn, two numbers a and b are additive
inverses of each other if
21-Jan-22
Additive Inverse
⚫ Find all additive inverse pairs in Z10.
21-Jan-22
Multiplicative Inverse
⚫ In Zn, two numbers a and b are the multiplicative
inverse of each other if
⚫ gcd(36,10)=gcd(10,6)=gcd(6,4)=gcd(4,2)=gcd(2,0)=2
21-Jan-22
Euclidean Algorithm to find GCD
21-Jan-22
Extended Euclidean Algorithm
⚫ Given two integers a and b, we often need to find other
two integers, s and t, such that
21-Jan-22
Extended Euclidean Algorithm
21-Jan-22
Extended Euclidean Algorithm
21-Jan-22
Extended Euclidean Algorithm
⚫ Example 1:
⚫ Given a = 161 and b = 28, find gcd (a, b) and the
values of s and t.
21-Jan-22
Extended Euclidean Algorithm
⚫ Example 2:
⚫ Given a = 17 and b = 0, find gcd (a, b) and the values of s
and t.
21-Jan-22
Extended Euclidean Algorithm
⚫ Example 2:
⚫ Given a = 17 and b = 0, find gcd (a, b) and the values of s
and t.
21-Jan-22
Multiplicative Inverse using Extended
Euclidean Algorithm
⚫ The extended Euclidean algorithm finds the
multiplicative inverses of ‘b’ in Zn when n and a are
given and gcd (n, b) = 1.
⚫ The multiplicative inverse of ‘b’ is the value of t after
21-Jan-22
Multiplicative Inverse using Extended
Euclidean Algorithm
21-Jan-22
Multiplicative Inverse using Extended
Euclidean Algorithm
⚫ Find the multiplicative inverse of 11 in Z26.
⚫ n=r1=26
⚫ B=r2=11
21-Jan-22
Multiplicative Inverse using Extended
Euclidean Algorithm
⚫ Find the multiplicative inverse of 23 in Z100.
⚫ n=r1=100
⚫ b=r2=23
21-Jan-22
Multiplicative Inverse using Extended
Euclidean Algorithm
⚫ Find the inverse of 12 in Z26.
21-Jan-22
Addition and Multiplication Tables
⚫ Addition table for Z10
21-Jan-22
Addition and Multiplication Tables
⚫ Multiplication table for Z10
21-Jan-22
Different Sets : Zn and Zn* sets
21-Jan-22
Different Sets : Zn and Zn* sets
21-Jan-22
Different Sets : Zn and Zn* sets
⚫ Find Z6 and Z6* sets
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
Addition table for Z6 Multiplication table for Z6
⚫ Z6 ={0, 1, 2, 3, 4, 5}
⚫ Z6* ={1, 5}
Compiled By Rohini Temkar 21-Jan-22
Two More Sets
21-Jan-22
MATRICES
⚫ A matrix of size l × m
21-Jan-22
Examples of matrices
21-Jan-22
Matrix Addition and Subtraction
21-Jan-22
Matrix Multiplication
⚫ Product of a 2 × 3 matrix by a 3 × 4 matrix.
21-Jan-22
Scalar multiplication of Matrix
21-Jan-22
Determinant of Matrix
21-Jan-22
Determinant of Matrix
21-Jan-22
Inverse of Matrix
⚫ Matrices have both additive and multiplicative
inverses.
⚫ Additive inverse
⚫ Additive inverse of matrix A is defined -A .
⚫ Additive inverse of matrix A is matrix B, such that
A+B=0
⚫ Multiplicative Inverse
⚫ Multiplicative inverses are only defined for square
matrices.
⚫ Multiplicative of matrix A is matrix B, such that, 21-Jan-22
A×B = B×A =I
Residue Matrices
⚫ Cryptography uses residue matrices: matrices where all
elements are in Zn.
⚫ Operations on matrix are done in modular arithmetic.
⚫ A residue matrix has a multiplicative inverse if gcd (det(A),
n) = 1
21-Jan-22
LINEAR CONGRUENCE
21-Jan-22
Single-Variable Linear Equations
21-Jan-22
Single-Variable Linear Equations
Steps to find Solution:
⚫ Reduce equation by dividing both sides of
equation(including modulus) by ‘d’.
⚫ Multiply both sides of equation by
multiplicative inverse of ‘a’ to find
particular solution ‘x0’.
⚫ The general solutions are
x = x0 +k (n/d) for k=0, 1, ……, (d-1)
21-Jan-22
Single-Variable Linear Equations
Example 1
Solve the equation 10 x ≡ 2(mod 15).
Solution
First we find the gcd (10 and 15) = 5.
Since 5 does not divide 2, we have no solution.
21-Jan-22
Single-Variable Linear Equations
Example 2
Solve the equation 14 x ≡ 12 (mod 18).
Solution: d= gcd(a,n) = gcd(14, 18) = 2
Solution
2.53
Compiled By Rohini Temkar 21-Jan-22
Without
Fermat’s
theorem
With
Fermat’s
theorem