Monday, November 14, 2016

number theory - Congruence using extended GCD



x5mod15x8mod21



The extended Euclidean algorithm gives x50mod105.



I understand now that if we combine the two it implies 15a21b=3 but I don't understand how to use the extended GCD to go from there to finding x and the corresponding modulus.



This is what I am using for the extended gcd computations:




def egcd(a, b):
if a == 0:
return (b, 0, 1)
else:
g, y, x = egcd(b % a, a)
return (g, x - (b // a) * y, y)


From https://en.wikibooks.org/wiki/Algorithm_Implementation/Mathematics/Extended_Euclidean_algorithm#Python



Answer



Since the GCD of the moduli is (15,21)=3, it is necessary that x be the same thing in both equations mod 3. That is,
x5(mod15)x2(mod3)
and
x8(mod21)x2(mod3)
If we didn't get that x2(mod3) from both equations, a solution would not be possible.




This prompts us to look at x23(mod153) and x23(mod213). That is,
x231(mod5)
and
x232(mod7)




Using the Extended Euclidean Algorithm as implemented in this answer,
122101250113775210
we get that

5(3)15+7(2)14=1
We can use (4) to see that
141(mod5)140(mod7)

and that
150(mod5)151(mod7)
To solve (1) and (2) we can add 1 times (5) to 2 times (6) to get
161(mod5)162(mod7)
Equations (7) tell us that x2316(mod35) or that
\bbox[5px,border:2px solid #C0A000]{x\equiv50\pmod{105}}\tag{8}


No comments:

Post a Comment

analysis - Injection, making bijection

I have injection f \colon A \rightarrow B and I want to get bijection. Can I just resting codomain to f(A)? I know that every function i...