Home

[This page is auto-generated; please prefer to read the article’s PDF Form.]



[Prev]   [Up]   

Modular Linear Equation

For given integers a,b,n with n > 0, a mod n0 and x unknown integer in n, the modular linear equation looks like:

ax ≡ b  (mod  n)

We need to find x, the solution of this equation where x n.

This equation can also be written as: (axb) mod n = 0. So finding x simply means that we need to find the element in set A = {(ai b) mod n : i n} which is 0 and then the corresponding i is the desired solution x. Using Corollary 3 with its b as (b), the set A consists of following values after taking their mod n: b,b + g,b + 2g,,b + ((n∕g) 1)g.

Let us assume that there exists some integer m ∈{0,1,2,,(n∕g) 1}, such that a value in set A, (b + mg) mod n, is 0. Then,

    {Such integer m exists}
⇔         (− b + mg ) mod n = 0

⇔               (− b+ mg ) = kn  {for some integer k }
⇔                      b∕g = − kn ∕g + m

Since gn, if integer m exists, then b∕g must be an integer, i.e. gb.

On the other hand, if gb (b∕g is an integer), then applying Division Theorem on integer b∕g divided by integer n∕g, we know that there exist integers k and m such that 0 m < n∕g. That will be our desired m.

As m was the remainder in above division, so m = (b∕g) mod (n∕g).

Thus we have proved this in both directions: gb iff  there exists m ∈{0,1,2,,(n∕g) 1} such that a value in set A, (b + mg) mod n, is 0.

To conclude, the equation has a solution iff  gb.

In proof of Theorem 2, we saw that the values vi = (ai) mod n are distinct for i = 0,1,2,,t 1 (t = n∕g), and then cycle for i = t onward as vt+j = vt. Similarly, values (ai b) mod n will also repeat in cycles of t = n∕g distinct values.

So, if solutions of the equation exist, one solution x0 must be among {0,1,2,,t 1}, such that (ax0 b) mod n = 0.

If solution x0 exists, then for every cycle of t integers i in n, a solution must exist. There are g cycles, each of length t among i in n. So, there will be g solutions: x = x0 + tj, j = 0,1,2,,(n∕t) 1.

We can write above findings in a theorem as below.

Theorem 6. For given integers a,b,n with n > 0, a mod n0 and g = gcd(a,n), the modular linear equation: ax b (mod n) is solvable iff  gb. If solvable, there are total g solutions.

Corollary 7. For given integers a,b,n with n > 0, if a and n are coprime, i.e. g = gcd(a,n) = 1, then the equation ax b (mod n) has exactly one solution.

Proof. Apply Theorem 6 with g = 1. Since for all integers b, 1b, so the equation is solvable and has g = 1 solution. □

Corollary 8. Equation ax 1 (mod n) is solvable iff  g = gcd(a,n) = 1. If solvable, it has exactly one solution.

Proof. Apply Theorem 6 with b = 1. Equation is solvable iff  g1. That is possible only if g = 1. Such a solution is referred as the “Multiplicative Inverse of a modulo n”, and denoted as a1 mod n. □

Corollary 9. If n is prime, ax b (mod n) has exactly one solution, for all integers a and b.

Proof. When n is prime, g = gcd(a,n) = 1, and so Corollary 7 applies. □

[Prev]   [Up]