a ≡ b (mod m)
if
(a - b) mod m is zero
∀a,b ∈ ℤ and m ∈ ℤ⁺
From Discrete mathematics and its applications:
If
a
andb
are integers andm
is a positive integer, thena
is congruent tob modulo m
ifm
dividesa-b
.
Then,
a ≡ b (mod m)
is a congruencem
is its modulusEg:
Set of all integers which are congruent to a (mod m)
constitutes the congruence class of a modulo m.
a (mod m)
vs a mod b
a ≡ b (mod m) and a mod m = b are not the same.
a mod b is the reminder when a is divided by b.
Like a % b
in C.
But there is a link between the two 'mod's:
a ≡ b (mod m)
iff
a mod m = b mod m
where a, b ∈ ℤ and m ∈ ℤ⁺ (a positive integer)
Eg:
19 ≡ 3 (mod 4)
then
19 mod 4 = 3 mod 4
3 = 3 ✓
aka Bézout's identity
If a, b ∈ ℤ⁺ then ∃s, t ∈ ℤ such that gcd(a, b) = sa + tb
where s and t are known as Bézout's coefficients.
ie, gcd(a, b) can be expressed as a linear combination with integer coefficients for a and b.
Eg:
gcd(6, 14) = 2
(-2 * 6) + (1 * 14) = 2
Usable when the moduli of the system of linear congruences are pairwise relatively prime.
From Discrete mathematics and its applications:
When the moduli of a system of linear congruences are pairwise relatively prime, there is a unique solution of the system modulo the product of the moduli.
Eg:
x ≡ 2 (mod 3)
x ≡ 3 (mod 5)
x ≡ 2 (mod 7)
Biggest one is 7:
2: ✗ ∵ 2(mod 5) is 2 ≠ 3
9: ✗ ∵ 9(mod 2) is 1 ≠ 2
16: ✗ ∵ 16(mod 5) is 1 ≠ 3
23: ✓
—
M = 3 * 5 * 7 = 105
mᵢ | Mᵢ | |
---|---|---|
1 | 3 | 35 |
2 | 5 | 21 |
3 | 7 | 15 |
Same solution with Back-substitution method:
a ≡ b (mod m)
means (a - b) mod m
is zero.
a ≡ b (mod m)
means ∃k ∈ ℤ, a = km + b
a ≡ b (mod m)
iff a mod m = b mod m
If a ≡ b (mod m)
and c ≡ d (mod m)
, then
a+c ≡ b+d (mod m)
ac ≡ bd (mod m)
(a+b) mod m = ((a mod m) + (b mod m)) mod m
(Note that this is the function mod!)
(ab) mod m = ((a mod m) * (b mod m)) mod m
(Note that this is the function mod!)
ℤₘ with modular addition constitutes a commutative group (ie, an Abelian group).
Informally speaking,
a⁻¹ ≡ b (mod m) is same as
0 ≡ (b-a) (mod m)
but a coprime condition is involved??
But, beware: Modular fraction arithmetic is valid only for fractions with denominator coprime to the modulus.
a | b
means a
divides b
. ie, a mod b
is zero.49 ≡ 1 mod 48
7² ≡ 1 mod 48
(7²)¹⁰⁰⁷ ≡ 1 mod 48
7.(7²)¹⁰⁰⁷ ≡ (7.1) mod 48
7²⁰¹⁵ ≡ 7 mod 48
So the remainder is 7.
289 ≡ -11 (mod 100) 17² ≡ -11 (mod 100)
(17²)⁹⁹ ≡ -11 (mod 100)