1

I got two questions that I'm wondering, one main question and one "bonus" question I guess

  1. what is the general method to solve congruence equations like $ax \equiv b \pmod m$?

Take for example $3x\equiv 2 \pmod 5$ how would I go about solving this?

I was able to solve it using trial and error and found the answer to be $4$, but I'm looking for a better and faster way to solve problems like these for larger $m$'s..

Also I'm wondering sometimes you can solve these with just the inverse of $a$, but when does that apply? only when $b=1$ and $a$ and $m$ are coprime? example $9x\equiv 1 \pmod 14$ for instance?

  1. can someone please show me how I can find the modular inverse of $9$ mod $14$? I'm familiar with the method used and I'm able to find the inverse in other examples, but I'm not sure why this one is causing me so much trouble, answer should be $11$ I think.
eyy321
  • 69
  • 1
  • Euclidean algorithm is the way to go for bigger $m$. When $m$ is small its faster to brute force every possibility. And if you have the inverse of $a$ you can always just multiply with that to get the solution. 2) Solve $9x=1$ (mod $14$) to get the inverse.
  • – Harto Saarinen Nov 26 '15 at 21:30
  • ok so for 1) I just try to find the inverse and multiply thats it? 2) thats exactly what I wasnt able to do btw..dunno why that one caused so much problem for me, probably just some silly mistake, but I looked through it and tried again several times still dont get the correct answer. @HartoSaarinen – eyy321 Nov 26 '15 at 21:34
  • 2
    Inverses can always solve $ax\equiv b\pmod{m}$ when $\gcd(a,m)$. The solution is $x\equiv ba^{-1}\pmod{m}$. – user236182 Nov 26 '15 at 21:34
  • $3x\equiv 2\equiv -3\pmod{5}\stackrel{:3}\iff x\equiv -1\equiv 4\pmod{5}$. – user236182 Nov 26 '15 at 21:35
  • You can just try out all the numbers ${1,2, ... , 14}$ to find the solutions. Since there aren't so many I would just do that. – Harto Saarinen Nov 26 '15 at 21:36
  • 1
    Finding $9^{-1}\bmod 14$ is equivalent to solving $9x\equiv 1\pmod{14}$. You can use Extended Euclidean Algorithm to find $s,t$ such that $9s+14t=1$. Then $x\equiv s\pmod{14}$. Or notice that $$9x\equiv 1\equiv -27\pmod{14}\stackrel{:9}\iff x\equiv -3\equiv 11\pmod{14}$$ – user236182 Nov 26 '15 at 21:38
  • yeah I tried euclidean algorithm on this 2), and I didnt really manage to do it, so yeah I think the other methods suggested are better on the second question, thanks – eyy321 Nov 26 '15 at 21:42
  • just wondering if gcd(a,m) is not 1, then ax≡b(mod m) got no solution right? @user236182 – eyy321 Nov 26 '15 at 21:49
  • 1
    @eyy321 $ax\equiv b\pmod{m}$ has a solution if and only if $\gcd(a,m)\mid b$. So $ax\equiv \gcd(a,m)k\pmod{m}$ has a solution for any integers $a,m,k$, even if $\gcd(a,m)>1$. – user236182 Nov 26 '15 at 21:52