Number theory: As a practical matter, is there a simple way to determine the inverse of a number mod n?
For example, if I have 504s congruent to 14 (mod 35), is there an easy way to find \[504^{-1}(14) \mod35\]
you want to solve \[504x\equiv 14\pmod{35}\] right ?
Yes, as part of a Chinese Remainder Theorem problem
reduce 504 first
Would you also need to reduce the 35 at the same time?
Oh, their GCD is 7
504 =35*14 + 14
so \(504 \equiv 14 \pmod{35}\)
If we do that, don't we need to divide 35 by GCD(35, 504)?
you want to solve \[504x\equiv 14\pmod{35}\] reduces to \[14x\equiv 14\pmod{35}\]
we are not dividing anything yet we are just using the fact that \(504\equiv 14\)
I think I'm having trouble with the difference between the idea of reducing versus dividing
lets divide 14 through out you will see the difference then i hope :)
So 14x is congruent to 14 mod(35) and we have x=1?
\[14x\equiv 14\pmod{35}\] dividing 14 though out gives you \[\dfrac{14x}{14}\equiv \dfrac{14}{14}\pmod{\dfrac{35}{\gcd(35,14)}}\]
\[x\equiv 1 \pmod{5}\]
Ah, I see the difference now. Thanks for your help!
we have been using two properties of congruences
\(a\equiv b\pmod{n}\) and \(b\equiv c\pmod{n} \implies a\equiv c\pmod{n}\) that allows you to replace 504 by 14
One's using the transitive property, and the other is using an inverse property?
yes :) in the end you have used \[ac \equiv bc\pmod{n} \implies a\equiv b\pmod{\frac{n}{\gcd(c,n)}}\]
:)
Thank you for your help - this clarifies things a lot!
you must be knowing solving a congruence is same as solving the diophantine eqn : \[ax \equiv b \pmod{n}\] is equivalent to solving \[ax -ny = b\] so you can use all the methods that work for diophantine equations to solve ur congruence
you're welcome :)
Huh, I haven't seen it put in terms of a Diophantine Equation like this
\(ax\equiv b\pmod{n}\) means \(ax = ny + b\) for some integer \(y\) rearrange to get the standard linear diophantine eqn form
so your original problem is same as solving the diophantine eqn \(504x-35y = 14\)
it is now a regular equation so we can divide 7 through out \(72x-5y = 2\)
this is actually the standard method for finding inverse when no other simplification is possible this method works always
That's much easier to think about. I hadn't really been thinking of these things as Diophantine equations or linear combinations of variables, and I suppose I should.
you could also use chinese remainder thm
you said you want to solve it using chinese remainder thm , so.. lets work it using chinese remainder thm quick maybe
\(504x\equiv 14\pmod{35} \) split it into two congruences \(504x\equiv 14\pmod{5} \) \(504x\equiv 14\pmod{7} \) work each congruence separately and combine them using chinese remainder thm
chinese remainder thm helps here because mod 5 and mod 7 are simpler to work compared to mod 35
In the first equation, we have 4x congruent to 4 (mod5), and so x = 1 In the second equation, could use any integer, so we could take x = 0 (?)
Oh, we want x to be the same in each case, so x=1
Oh yes we can drop second congruence because x could be any integer
we're done yeah no need to apply chinese remainder thm
So suppose it didn't work out that way, how would the Chinese Remainder Theorem help?
Say, if we used 505 instead of 504?
lets cookup an example
ohk lets use 505
it has no inverse because gcd(505, 35) does not divide 14
pick some other good number
How about 25 congruent to 1 (mod 6)
25x*
knw what, there is nothing to solve there 25 = 1 mod 6 :P
so 25x = 1 mod 6 can be solved trivially by reducing to x = 1 mod 6
Right, but just as a demonstration of the Chinese Remainder Theorem when you use 2 and 3
Ahh okay I see what you mean
\(25x \equiv 1 \pmod{6}\) split into two \(25x \equiv 1 \pmod{2}\) \(25x \equiv 1 \pmod{3}\)
*Sorry, brb
solving each gives \(x\equiv 1\pmod{2}\) \(x\equiv 1\pmod{3}\) by chinese remainder thm the solution would be below expression mod 6 : \[1\times 3 \times 3^{-1}\pmod 2 + 1\times 2\times 2^{-1}\pmod{3}\] right ?
I'm with you
**\[1\times 3 \times [3^{-1}\pmod 2 ]+ 1\times 2\times [2^{-1}\pmod{3}]\]
inverse of 3 in mod2 is 1 and inverse of 2 in mod 3 is 2 plug them
lets work a not so simple congruence after this
1(3)(1)+1(2)(2) congruent to a mod 6 7 congruent to a mod 6 And we get 1 mod 6
yes that was easy, try solving this using chinese remainder thm \[17x\equiv 9 \pmod{276}\]
17x congruent to 9 mod 12 17x congruent to 9 mod 23
yes
I suppose we could further split these up to 17x congruent to 9 mod 3 17x congruent to 9 mod 4 2x congruent to 0 mod 3, x=0 x congruent to 1 mod 4, x=1
Oh, yeah, I got stuck with the 5x congruent to 9 mod 12
looks good!
``` I suppose we could further split these up to 17x congruent to 9 mod 3 17x congruent to 9 mod 4 2x congruent to 0 mod 3, x=0 x congruent to 1 mod 4, x=1 ``` use chinese remainder thm to cookup solution for 17x congruent to 9 mod 12
So we have 0 + 1(4)(1) [mod 12]?
Lol, 4 mod 12
im getting 9 mod 12
By I i mean wolfram :)
whats the inverse of 3 in mod4 ?
3
x = 0 mod 3 x = 1 mod 4 chinese remainder thm gives 0 + 1*3*3 mod 12
OH, haha, I was looking at the wrong modulus
\[0 + 1\times 3\times [3^{-1}\pmod{4}]\]
Yeah, I'm with you. Stupid mistake.
So now there's the part with the 17x congruent to 9 mod 23
17x congruent to 9 mod 12 : solution ` x = 9 mod 12` 17x congruent to 9 mod 23
lets work second congruence quick
17x congruent to 9 mod 23 reduces to -6x congruent to 9 mod 23 yes ?
Yes
divide 3 through out : -2x congruent to 3 mod 23
Ah, clever
we can eyeball now x = 10
Isn't it -10?
17x congruent to 9 mod 12 : solution `x = 9 mod 12` 17x congruent to 9 mod 23 : solution `x = 10 mod 23`
-2x congruent to 3 mod 23 -2(10) = 3 mod 23 -20 = 3 mod 23 which is true right
*head bonk* Sorry
K, good now
below is the most useful definition of congruence : \(a \equiv b \pmod{n}\) means \(a -b\) is divisible by \(n\)
you have solutions work chinese remainder thm again and call it a day !
So we still need to work the inverses for 9 mod 12 and 10 mod 23, right?
basically we are doing this : we have 17x congruent to 9 mod 276 to solve we solved below baby congruences and hoping to stitch the final solution using chinese remainder theorem : 17x congruent to 9 mod 12 : solution `x = 9 mod 12` 17x congruent to 9 mod 23 : solution `x = 10 mod 23`
Right
yes
repeat the same story :)
just the numbers are different now
method is same
Join our real-time social learning platform and learn together with your friends!