Please check linear congruence equation solution

148 Views Asked by At

Preface

At first I wanted to ask the community to solve the equation for me as I knew very little about modular arithmetic. But then I decided to try and found that this is a linear congruence equation and found the material about it on the web and seems, that I solved it eventually.

Now I ask the community to check my solution.

Problem

Suppose, we have a sequence of numbers, defined by formula:

$a(i) = 5 + i \cdot 7 \mod 12$

| i    | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
|------+---+---+---+---+---+----+---+---+---+---+----+----+---|
| a(i) | 5 | 0 | 7 | 2 | 9 | 4 | 11| 6 | 1 | 8 | 3  | 10 | 5  |

Given a sequence element, find it's number:

$5 + x \cdot 7 \mod 12 = a$

$a \in $[0, 11], $x \in $[0, 11]

x = ?

My solution

GCD(7, 12) = 1, therefore the solution exists.

$x \cdot 7 = (a - 5) \mod 12$

$x = (a - 5) \cdot 7^{-1} \mod 12$

$7^{-1} \mod 12 = 7\;$ because $7 \cdot 7 \mod 12 = 1$ ($49 = 48 + 1 = 12 \cdot 4 + 1$)

So we have:

$x = (a - 5) \cdot 7 \mod 12$

Check of the solution correctness

a = 1 (x = 8):

$x = (1 - 5) \cdot 7 \mod 12 = (-4) \cdot 7 \mod 12 = -28 \mod 12 = 12\cdot (-3) + 8 = 8$ (correct)

a = 5 (x = 0):

$x = (5 - 5) \cdot 7 \mod 12 = 0 \mod 12 = 0$ (correct)

a = 3 (x = 10):

$x = (3 - 5) \cdot 7 \mod 12 = (-2) \cdot 7 \mod 12 = -14 \mod 12 = -24 + 10 \mod 12 = 10$ (correct)

So, the formula seems correct.

1

There are 1 best solutions below

0
On BEST ANSWER

In response to your query to my comment : We have $\text{GCD}(7,12)=1$ so for all $p,q$ we have $$\text{[1]..........}p\equiv q \pmod{12}\text{ iff}$$ $$\ p.7\equiv q.7 \pmod{12}.$$ And $$ \text{[2]...........}7.7\equiv 1\pmod{12}.$$ Therefore, $$5+x.7 \equiv a \pmod{12}\text{ iff}$$ $$ x.7\equiv a-5 \pmod{12}\text{ iff}$$ $$ x.7.7\equiv (a-5).7 \pmod{12} \text{(...by [1]), iff}$$ $$ x.1\equiv (a-5).7\pmod{12}\text{...(by [2])}.$$ To check , work backwards from the last line. [BTW,the RHS of the last line can be simplified because $-35\equiv 1\pmod{12}]$.