4

assume we want to find the multiplicative inverse for $117$ in $Z337$.

i know that in order to find the the multiplicative inverse we use Euclidean and Extended Euclidean algorithm.

Eculidian:

$337 = 2*117 + 103$

$117 = 1*103 + 14$

$103 = 7*14 + 5$

$14 = 2*5 + 4$

$5 = 1*4 + 1$

Extended Euclidean:

not going to include the whole solution because i am pretty sure of it, i get:

$1=25*337-72*117$

Extended Euclidean gives us that the inverse is $-72$. but how come a calculator says the inverse is $265$ and so do the teacher. do i need to do anything more ? usually i only need to do Euclidean and Extended Euclidean to find the inverse.

Bill Dubuque
  • 272,048

1 Answers1

5

Either answer is correct since they are both congruent, i.e. $\,{\rm mod}\,\ 337\!:\ \color{#c00}{{-}72}\equiv 337-72\equiv 265.\ $ Below is the complete calculation by a fractional form of the Extended Euclidean Algorithm

${\rm mod}\ 337\!:\,\ \dfrac{0}{337} \overset{\large\frown}\equiv \dfrac{1}{117} \overset{\large\frown}\equiv \dfrac{-3}{\color{#0a0}{-14}} \overset{\large\frown}\equiv \dfrac{-23}5 \overset{\large\frown}\equiv\color{#c00}{\dfrac{-72} {1}}\overset{\large\frown}\equiv\dfrac{0}0\,$ or, equivalently, in equational form

$\qquad\ \begin{array}{rrl} [\![1]\!]\ \!\!\!& 337\,x\!\!\!&\equiv\ \ 0\\ [\![2]\!]\ \!\!\!& 117\,x\!\!\!&\equiv\ \ 1\\ [\![1]\!]-3[\![2]\!]=:[\![3]\!]\ \!\!\!& \color{#0a0}{{-}14}\,x\!\!\!&\equiv -3\\ [\![2]\!]+8[\![3]\!]=:[\![4]\!]\ \!\!\!& 5\,x\!\!\! &\equiv -23\\ [\![3]\!]+3[\![4]\!]=:[\![5]\!]\ \!\!\!& \color{#c00}1\, x\!\!\! &\equiv \color{#c00}{-72} \end{array}$

Remark $\ $ This is essentially the augmented matrix form of the extended Euclidean algorithm, optimized by omitting one column, then interpreting the linear congruences as modular fractions.

Allowing negative remainders (i.e. least magnitude reps) often simplifies calculations, e.g.$\,10^{n}\equiv (-1)^{n}\equiv \pm1\pmod{11}\ $ is used to calculate remainders mod $11$ via alternating digit sums (casting out elevens). I did so above: $\bmod 117\!:\ 337 \equiv \color{#0a0}{{-}14}\ ({\rm vs.}\ 103\,$ in your calculation). Using the smaller magnitude residue $\,-14\,$ simplifies subsequent calculations (it eliminates one step from your calculations, but generally such choices save many steps in longer calculations).

See this answer for another worked example.

Bill Dubuque
  • 272,048
  • Thanks for the answer, but i wonder if its mathematically correct to say that $-72$ is the multiplicative inverse? is it ok if the multiplicative inverse is negative ? – pabloBar Dec 11 '16 at 19:30
  • In@pabloBar $\ 117^{-1}\equiv -72\pmod{337},$ is correct, but $,{ -}72 = (117^{-1}\bmod 337),$ is not correct. Do you understand the difference? – Bill Dubuque Dec 11 '16 at 19:33
  • how would you translate these expressions in words?, sorry a bit bad when it comes the math expressions. – pabloBar Dec 11 '16 at 19:36
  • @pabloBar $\ a\equiv b\pmod n,$ means $,n,$ divides $,a-b,,$ but $, a = (b\bmod n),$ means the same plus $, 0\le a < n,,$ i.e. $,a,$ is the least nonnegative integer $\equiv b\pmod n,, $ i.e. the remainder left on dividing $,b,$ by $,n.$ $\ \ $ – Bill Dubuque Dec 11 '16 at 19:41
  • on exam i would do the calculations above and then state with the exact words that "the multiplicative is $-72$", would my statement be correct in this case ? – pabloBar Dec 11 '16 at 19:47
  • @pabloBar It depends on what was asked. If the answer $,k,$ is expected to be in normal form, i.e. $, 0 \le k < n = $ modulus, then you need to shift it into this range. It's similar to asking if $, 2/4,$ is a correct answer for a problem with fractions, i.e does the teacher expect that you normalize fractions to lowest terms? i.e. reduce $, 2/4 = 1/2.\ $ – Bill Dubuque Dec 11 '16 at 19:52
  • alright sounds good, the question only asked to find the inverse with no conditions on in which range the answer should be, so i guess my answer should be fine. – pabloBar Dec 11 '16 at 19:58
  • @pabloBar Probably so. I added a remark about this in the answer. – Bill Dubuque Dec 11 '16 at 20:05
  • exellent answer mate, i marked your post as the answer. And sorry dont have enough reputation to upvote it but its totally worth +1 – pabloBar Dec 11 '16 at 20:08
  • if possible, do you have a link where it shows a multiplicative inverse can be negative? , just so i can backup myself when arguing with the teacher – pabloBar Dec 11 '16 at 22:09
  • @pabloBar Why don't you simply use the least positive rep to avoid any issues? You can probably find examples in textbooks if you look at computations using the Chinese Remainder Theorem, which typically involves computing inverses. – Bill Dubuque Dec 11 '16 at 22:50