Monday, July 3, 2017

divisibility - Extended Euclidean Algorithm problem



I'm confused about how to do the extended algorithm. For example, here's the gcd part
gcd(8000,7001)




8000=70011+9997001=9997+8999=8124+78=71+17=17+0gcd(8000,7001)=1



Now, the extended algorithm




1=817=81(9998124)=1999+8125



How do you get this 8*125 from the previous line?


Answer



By the distributive law  8 1(ab)=a+b 1(9998124)= 81999+8124= 8125999  by  124+1=125



This "back-substitution method" for the extended gcd is notoriously error-prone. Simpler to compute and easier to remember is the method described here., where we keep track of each remainder's expression as a linear combination of the gcd arguments. Executing that algorithm yields




8000107001019991187818761001



where each line  a  b  c  means that  a=8000b+7001c.  Therefore




1=8768000+10017001



The linked post described the algorithm in great detail, in a way that is easy to remember.



Here is another example computing  gcd(141,19), with the equations written explicitly



[[1]]   141 =  1141+ 019[[2]] 19 =  0141+ 119[[1]]7[[2]][[3]]   8 =  1141 719[[2]]2[[3]][[4]]   3 =2141+1519[[3]]3[[4]][[5]]1 =  71415219


No comments:

Post a Comment

analysis - Injection, making bijection

I have injection f:AB and I want to get bijection. Can I just resting codomain to f(A)? I know that every function i...