1

Find the inverse modulo,

Modulo inverse of $5991 \pmod{2014}$ ?

I am aware of the Euclid algorithm, but I am not sure how to apply it here?

Amad27
  • 10,465

3 Answers3

2

Hints:

Try to follow, understand and justify the following steps:

$$5991=-51\pmod{2104}$$

But:

$$\begin{align}&-51=2\pmod{53}\;,\;\;2^{-1}=27\pmod{53}\\&-51=6\pmod{19}\;,\;\;6^{-1}=16\pmod{19}\end{align}$$

and thus we need a solution for

$$\begin{cases}x=27\pmod{53}\\{}\\x=16\pmod{19}\\{}\\x=1\pmod2\end{cases}$$

and the Chinese Remainder Theorem (CRT) gives us:

$$x=27\cdot38\cdot\overbrace{7}^{=38^{-1}\pmod{53}}+16\cdot106\cdot\overbrace{7}^{=106^{-1}\pmod{19}}+1\cdot1007\cdot\overbrace{1}^{=1007^{-1}\pmod2}=20061$$

so that finally

$$5991^{-1}=20061=1935\pmod{2014}$$

Timbuc
  • 34,191
  • 1
    You really also deserve an upvote for your efforts related to this. – quid Jan 23 '15 at 18:55
  • 1
    @quid Thanks. Somehow the OP didn't think so and decided only to upvote and choose your answer which, by the loooong array of comments below it, I gather (s)he didn't even understand. I think he's very confused and did try to solve another problem to begin with which, of course, gets solved once one knows what is $;5991^{-1}\pmod{2014};$ . – Timbuc Jan 23 '15 at 19:03
  • @Timbuc, sorry buddy, I didnt see this answer. (+1) because even though this answer is difficult to understand, it still has rigour. It is (+1) worthy, I'm very sorry Timbuc. =) – Amad27 Jan 25 '15 at 07:35
2

The (extended) Euclidean algorithm applied to $a,b$ does not only give the $\gcd(a,b)$ but also two integers $u,v$ such that $ua +vb = \gcd(a,b)$. Also, note that you can only find a modular inverse of $a \mod b$ if $\gcd(a,b)=1$.

Now, to use this to fine modular inverses proceed like this.

  • Perform extended Euclidean algorithm on $5991$ and $2014$.

  • You find $1=\gcd(5991, 2014)$ and $u,v$ such that $u\ 5991 +v\ 2014 = 1$.

So, $ u \ 5991 = 1 + v\ 2014$. And this just means $u \ 5991 \equiv 1 \mod 2014$, that is $u$ is the modular inverse you searched.

This assumes knowing how to perform the extended Euclidean algorithm to find the GCD and the couple $(u,v)$ sometimes called Bézout coefficients. For details on this algorithm see How to use the Extended Euclidean Algorithm manually?


A way to do the extended Euclidean algorithm is to start from the following two equations:

  • $5991 \cdot 1 + 2014 \cdot 0 = 5991$ (Eq 1)
  • $5991 \cdot 0 + 2014 \cdot 1 = 2014$ (Eq 2)

Now perform the normal Euclidean algorithm on the right and keep track of what you do on the left. As $5991 = 2\cdot 2014 + 1963$:

  • $5991 \cdot 1 + 2014 \cdot (-2) = 1963 $ (Eq 3 is Eq 1 minus two times Eq 2).

As $2014 = 1 \cdot 1963 + 51$:

  • $5991 \cdot (-1) + 2014 \cdot 2 = 51 $ (Eq 4 is Eq 2 minus Eq 3).

As $1963 = 38 \cdot 51 + 25$:

  • $5991 \cdot 39 + 2014 \cdot (-74) = 25 $ (Eq 5 is Eq 3 minus 38 times Eq 4).

As $51 = 2 \cdot 25 + 1$:

  • $5991 \cdot (-79) + 2014 \cdot 150 = 1 $ (Eq 6 is Eq 4 minus two times Eq 5).

As $1$ divides $25$, we have found that $1$ is the gcd and we also have in Eq 6 that

$$5991 \cdot (-79) = 1 - 2014 \cdot (150) $$

So $5991 \cdot (-79) \equiv 1 \mod 2014$ and $-79$ is the modular inverse. If you want one between $1$ and $2013$ add $2014$ to it. Then it matches the solution in another answer.

quid
  • 42,135
  • That has been the question all along, how do you find $v$? – Amad27 Jan 23 '15 at 14:03
  • This is one of the things the (extended) Euclidean algorithm returns. You said you knew that algorithm. For an explanation see http://math.stackexchange.com/questions/85830/how-to-use-the-extended-euclidean-algorithm-manually I also updated the answer. – quid Jan 23 '15 at 14:09
  • I do know it, but I dont see how it works here.. Also, how did you know $\gcd(2014, 5991) = 1$? – Amad27 Jan 23 '15 at 14:10
  • I said at the start that you cannot find a modular inverse unless the gcd is $1$ so if the gcd were not one the question would make no sense, and you would find this out once you have completed the algorthm and found a different gcd. I just see I flipped the numbers relative to your question I will fix this. – quid Jan 23 '15 at 14:13
  • That page is too difficult, I am not too experienced with matrices. – Amad27 Jan 23 '15 at 14:14
  • You do not need any experience with matrices. But okay I will spell it out. But next time do not claim you know something that you in fact do not know. – quid Jan 23 '15 at 14:17
  • I performed Euclid's algorithm above: Step 3: $1963/51 = (1)1938 + 25$ Step 4: $1938/25 = (1)1925 + 13$ Step 5: $1925/13 = (1)1924 + 1$ Step 6: $1924/1 = (1)1924 + 0$

    Using Steps, 1, 2 from Mark.

    – Amad27 Jan 23 '15 at 14:29
  • This seems better. But why not a direct approach? Why are you using negatives? – Amad27 Jan 23 '15 at 14:35
  • Because this is what comes out of the extended Euclidean Algorithm performed in this way. Moreover a pair of Bezout coeeficients will essentially always be one positive one negative otherwise you could hardly write $1$ as sum of multiples of $2014$ and $5991$. – quid Jan 23 '15 at 14:38
  • Okay. So you found $1 \equiv 5991(-79) \pmod{2014}$ But how can you say that the modular inverse is $-79$ I thoght I knew a lot about this but I dont... THANKS! – Amad27 Jan 23 '15 at 14:43
  • The modular inverse of $5991$ is, at least in my mind, the residue class $u$, modulo $2014$ such that $5991 \ u$ is $1$ modulo $2014$. Now $-79$ is clear a member of that residue class as it has the property that $5991 \times (-79) $ is $1$ modulo $2014$ so it is an inverse. If your convention is that you always want representative in a given interval than add $2014$. – quid Jan 23 '15 at 14:49
  • $2014 - 79 = 1935$ So $b = 1935$? If so, its incorrect. $b = 677$ is the answer. – Amad27 Jan 23 '15 at 14:50
  • Yes. And note it matches the result in an other answers. – quid Jan 23 '15 at 14:51
  • Wait, I want to link this. http://math.stackexchange.com/questions/1115400/find-the-least-number-b-for-divisibility $b$ cannnot be $1935$ – Amad27 Jan 23 '15 at 14:52
  • 1
    For the other problem the answer $677$ seems to be correct. But this $b$ is not the modular inverse of $5991$. – quid Jan 23 '15 at 14:57
  • How? Sasha's answer suggests that? – Amad27 Jan 23 '15 at 14:59
  • It is suggested to find the modular inverse and to then multiply both sides with the mod inverse. Your $b$ is (congruent to) the mod inverse times the number on the right. – quid Jan 23 '15 at 15:10
  • I actually posted a new question on how to solve congruences. Since this is a congruence really. – Amad27 Jan 23 '15 at 15:17
  • @Amad27 you only need a simple calculator to check: it is $;5991^{-1}=1935\pmod{2014};$ – Timbuc Jan 23 '15 at 15:21
  • @Timbuc But how do I use that to solve $5991b \equiv 1725 \pmod{2014} $ Multiply by $1935$ so:

    $$b \equiv 1725*1935 \equiv 3337875 \pmod{2014}$$ Yikes, what can I do?

    – Amad27 Jan 23 '15 at 15:41
  • "Yikes"?? It's all you need ! Now just simplify 3337875 modulo $;2014;$ ...! It's very easy to check that $;3337875=677\pmod{2014};$ – Timbuc Jan 23 '15 at 18:51
1

After using the Euclidean algorithm and manipulating the equations backward, you can find $a,b \in \mathbb{Z}$ such that $$a \cdot 2014 + b \cdot 5991 = 1.$$

Working modulo 2014, we see that $b$ is the inverse of 5991.