-1

Solve:

$$5991x + 289 \equiv 0 \pmod{2014}$$

$$5991x \equiv -289 \equiv 1725 \pmod{2014}$$

I need to find the inverse of $5991$ modulo $2014$.

Start with Euclid's algorithm:

$$5991 = 2(2014) + 1963$$

$$2014 = 1(1963) + 51$$

$$1963 = 38(51) + 25$$

$$51 = 2(25) + 1$$

$$25 = 25(1) + 0$$

So how should I get the inverse?

Thanks!

Amad27
  • 10,465
  • 3
    How is this different from you two earlier questions? – quid Jan 23 '15 at 15:22
  • @quid, because I wanted someone to go on from whereI left off. Perhaps that wouldhave helped more. =) – Amad27 Jan 23 '15 at 15:38
  • Okay. Since I already used an order of magnitude more time then I planed on this, and the argument is somewhat reasonable. Hold on. I will give it one more try. – quid Jan 23 '15 at 15:41
  • Note there is a trick to simplify this which is not apparent in the duplicate. The original equation can be recast as $51x\equiv 289$. Then you can divide by $17$, which is not a factor of $2014$ to obtain $3x\equiv 17$. This reduces the work considerably, especially if you also spot that $2031$ is divisible by $3$. – Mark Bennet Jan 23 '15 at 16:11
  • @MarkBennet, how can it be written like that? – Amad27 Jan 23 '15 at 16:14
  • Well $3\times 2014=6042=51+5991$ so that $5991x=(6042-51)x\equiv -51x$. This means $-51x+289\equiv 0$ whence $51x\equiv 289$ – Mark Bennet Jan 23 '15 at 16:30
  • Note I started by wanting to reduce $5991$ to something smaller to simplify. Looking for factors which can be cancelled to simplify such an equation is also a useful technique. You do have to check that any factors you cancel are co-prime with the modulus (if not there are then other things you can do) – Mark Bennet Jan 23 '15 at 16:44
  • 1
    Perhaps I am seeing double but less than $24$ hours ago there was the same question and in a comment I pointed out the $17$ trick. Don't remember who asked the question, but sasha gave a find the modular inverse answer. – André Nicolas Jan 23 '15 at 16:45
  • Yes,but how do you use that trick? How did you do it? – Amad27 Jan 24 '15 at 06:59

1 Answers1

1

To calculate the modular inverse one uses the extended Euclidean algorithm. Normally, one can perform this in parallel but with some methods it works also afterwards.

Set $s_0 =1$ and $s_1 = 0$, and calculate $s_{i+1}= s_{i-1}- q_i s_i$ where $q_i$ are the quotients you found. Then $s_{k+1}$ is your modular inverse; where $k$ is such that the $k$-th reminder is the $\gcd$. See the linked to site for details.

So:

  • $s_2 = 1 - 2 \cdot 0= 1$,
  • $s_3 = 0 - 1 \cdot 1 = -1 $,
  • $s_4 = 1 - 38 \cdot (-1)= 39$,
  • $s_5 = -1 - 2 \cdot 39 = -79$

You are done! The modular inverse is (the class of) $-79$. Note that the sequence of the $s_i$ so $1,0,1,-1, 39, -79$ is the exact same sequence and you performed the exact same computations that were performed in my other answer

The only difference is that here we did all the calculations for the right-hand side first; this is what you did, and then did (half) the computations for the left-hand side afterwards. I say "half", as we only computed the coefficient for the $5991$ not for $2014$. Though you could compute it in about the same way; see the calculation of the $t_i$ on the linked to page though it is really the same recursion as for the $s_i$, only the starting values are flipped, so $t_0 = 0$ and $t_1 = 1$.

quid
  • 42,135
  • Okay. So I suppose next step is to multiply both sides by $-79$? – Amad27 Jan 23 '15 at 16:00
  • Yes. Then you have $(-79) 5991 b \equiv (-79) 289 \mod 2014$ and sicne $(-79) 5991 \equiv 1 \mod 2014$ we have $b \equiv (-79) 289 \mod 2014$. Thus we have found $b$. To make everything a bit nicer we can still compute the producr $(-79) 289$ and reduce it $\mod 2014$ to have a nicer representative. – quid Jan 23 '15 at 16:03
  • so $b \equiv 22831 \equiv 677$ perfect answer! – Amad27 Jan 23 '15 at 16:05
  • Great. I am glad we figured it out in the end. :-) – quid Jan 23 '15 at 16:08
  • Yeah, except that I got 2 downvotes =( – Amad27 Jan 23 '15 at 16:10
  • It is a bit unusual to ask three questions for one problem. So, some got a bit impatient I asume. – quid Jan 23 '15 at 16:12