Question about the Extended Euclidean Algorithm

So about the Extended Euclidean algorithm, the algorithm that finds, a, b, and d in the equation am+bn=d, where m and n are two positive integers, d is their GCD, and a and b are two integers (not necessarily positive)

So the book I am following has the following instructions for implementing this algorithm:

E1. [Initialize.] Set aβ€² ← b ← 1, a ← bβ€² ← 0, c ← m, d ← n.

E2. [Divide.] Let q and r be the quotient and remainder, respectively, of c divided by d. (We have c = qd + r and 0 ≀ r < d.)

E3. [Remainder zero?] If r = 0, the algorithm terminates; we have in this case am + bn = d as desired.

E4. [Recycle.] Set c ← d, d ← r, t ← aβ€², aβ€² ← a, a ← t βˆ’ qa, t ← bβ€², bβ€² ← b, b ← t βˆ’ qb, and go back to E2.

My problem is that I don't particularly understand all the math around this algorithm, I understand the normal Euclidean algorithm well enough, so I understand half of the extended one as well. What I don't understand is the need for a' and b' as well t (I get that t is a temporary variable but I don't get the a = t - qa and b = t - qb part). That as well as the initialization of the variables a, a', b, and b' as well as the swapping of the values between them on each iteration. Can anybody help me bridge these gaps in my understanding of this algorithm?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/prithvidiamond1
πŸ“…︎ Nov 22 2021
🚨︎ report
Hi, here is a simple solved example of RSA algorithm.The value of d is found without using Extended Euclidean algorithm. youtu.be/aJ9HAdiAnIU
πŸ‘︎ 15
πŸ’¬︎
πŸ‘€︎ u/Trinity_software
πŸ“…︎ Oct 26 2020
🚨︎ report
[University Discrete Mathematical Structures] How to calculate the last step in an Extended Euclidean Algorithm example.

I know this is probably one of the simpler parts of the problem, but how (in this example) are they getting 5 * 675 - 16 *210 from 5 * (675 - 3 * 210) - 210? I understand all the mod calculations and plugging in steps, just that last jump is getting me.

https://preview.redd.it/89la6ngpx6u51.png?width=637&format=png&auto=webp&s=69ce6e371970ded844ec77488b9958d191fdec48

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/jst_my_lck
πŸ“…︎ Oct 20 2020
🚨︎ report
[Number Theory] Can someone help me with the extended euclidean algorithm and bezout identity s and t values?

Found GCD(561, 442) to be 17

561 = 1*442 +119

412 = 3*119 +85

119 = 1*85 + 34

85 = 2*34 + 17

34 = 2*17 + 0

Rewritten

561 - 1*442 =119

412 - 3*119 =85

119 - 1*85 = 34

85 -2*34 = 17

34 -2*17 = 0

Then what do I do? I think I need to substitute somehow, but I cannot figure that out

πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ Oct 07 2020
🚨︎ report
The Extended Euclidean Algorithm is Disgusting (Look Closer)
πŸ‘︎ 39
πŸ’¬︎
πŸ‘€︎ u/NoahRCarver
πŸ“…︎ Feb 26 2020
🚨︎ report
Extended Euclidean Algorithm

from "https://crypto.stanford.edu/pbc/notes/numbertheory/euclid.html"

3=33m+27n

6=33-1*27

3=27-4*6

3=27-4*(33-1*27) = (-4)*33+5*27

m = -4, n=5

How did they get from 3=27-4(33-1*27)

to

3= -4*33+5*27... Where did the +5 come from? How does that term 3=27-4(33-1*27) become -4*33+5*27

Thanks!

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/EveningPossible5
πŸ“…︎ Mar 13 2020
🚨︎ report
Help with the Euclidean's extended algorithm

Hi, I feel like this must be a really silly question compared to the other questions I have seen on this subreddit.

But pretty much I'm a little stuck on how to do the Euclidean's algorithm.

I think the part I don't understand is when you simplify the groups.

How did they get from this to the end result

31 = ( 527 - 341 x 1 ) x 2 - 341

31 = 527 x 2 - 341 x 2 - 341

31 = 527 x 2 - 341 x 3

I understand how they got to the first equation by expanding but I'm a little confused about the simplification process.

also please keep in mind this is not a homework question but I just want to learn the Euclidean's algorithm the question I'm talking about can be found here.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/abmoob
πŸ“…︎ Mar 24 2020
🚨︎ report
Extended Euclidean Algorithm

Animating the Euclidean Algorithm and its application to computer science encryption (extended Euclidean Algorithm - BΓ©zout's identity) would be really cool. Computers stay secured by an algorithm derived 3000 years ago.

https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/osarjeant
πŸ“…︎ Jan 13 2020
🚨︎ report
Analysis of traditional Extended Euclidean Algorithm [PART-1]
πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/hiswaps
πŸ“…︎ Jan 11 2020
🚨︎ report
Extended Euclidean Algorithm Question

I have spent a few hours watching videos and running through this, and would appreciate any help. I have successfully used the extended euclidean algorithm to find the modular multiplicative inverse of other examples, but have failed with this example: 17x = 1 (mod 90). I have used brute force calculations to successfully define x as 53, but I can not get the result using the Euclidean algorithm.

Where am I going wrong?

This is the first portion to reduce to 1:

90 = 5(17) + 5

17 = 3(5) + 2

5 = 2(2) + 1

1 is reached, indicating a multiplicative inverse exists, so I begin working back up now for the extended portion of the algorithm, solving for the remainders first:

1 = 5 - 2(2)

2 = 17 - 3(5)

5 = 90 - 5(17)

Now, the issue begins when I start substituting:

1 = 5 - 2(2)

= 5 - 2(17-3(5))

=7(5) - 2(17)

=7(90-5(17))-2(17)

=7(90)-37(17) mod 90

1 =37(17) mod 90 <---- this is false, mod 90 returns 89, not 1.

Any help working out the second half of the algorithm with these numbers would be greatly appreciated. *Solved see comments.

πŸ‘︎ 6
πŸ’¬︎
πŸ‘€︎ u/jolo1989
πŸ“…︎ Feb 14 2018
🚨︎ report
[Number Theory] In RSA Cryptography you need the extended euclidean algorithm to get the value of d, but how do I get the other candidates for d without trial and error?

I believe so that the Extended Euclidean Algorithm and other related algorithm of getting the inverse modulo would only yield to the smallest positive d

and the formula for getting d is either

d ≑ e-1 (mod Ο•(n) )

or

d * e mod Ο•(n) = 1

where e and (mod phi(n)) are constant numbers

my current implementation right now is through bruteforce

ull getD(ull e, ull totient)
{	
    ull d;
    smint flag;
    
    for(d=flag=0; d &lt; ULLONG_MAX &amp;&amp; flag &lt; 2; d++) {
        if(d*e % totient == 1) {
            flag++;
        }
    }
    return d;
}

this code should get the third candidate of d that would satisfy the equation..

πŸ‘︎ 19
πŸ’¬︎
πŸ‘€︎ u/trettet
πŸ“…︎ May 24 2017
🚨︎ report
[University Comp Sci] Modular multiplicative inverse / Extended Euclidean algorithm

The problem I'm trying to solve is this:
d * 3 ≑ 1 mod 40

That is (d * 3) / 40 should have a remainder of 1

I use Extended Euclidean algorithm to try and solve this since gcd(3, 40) is 1.

Euclidean

40 = (3 * 13) + 1  
3 = (1 * 3) + 0 

Extended Euclidean

1 = 40 - (3 * 13)
0 = 3 - (1 * 3)
0 = 3 - 3[40 - (3 * 13)]  // replaced 1 with the equation above
0 = 3 - [40(3) - 3(39))]  // distribute 3
0 = 3 + [40(-3) + 3(39))]  //distribute -
0 = [40(-3) + 3(40))]

I'm getting 40 instead of 27. What am I doing wrong?

Edit:
I solved: 7 * e = 1 mod 20 like so:
Euclidean

    20 = (7*2) + 6
    7 = (6*1) + 1
    6 = (1*6) + 0

Extended

    6 = 20 - (7*2)
    1 = 7 - (6*1)
    
    1 = 7 - [20 - (7*2)]
    1 = 7 + [(-1)20 + (2)7]
    1 = [(-1)20 + (3)7]

The correct answer is e = 3
I can't find what I'm doing wrong for the d * 3 ≑ 1 mod 40 problem. It seems like I'm doing the exact same steps...

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/orange_ball
πŸ“…︎ Dec 18 2016
🚨︎ report
[Cryptography] - Extended Euclidean Algorithm

Hi, I've looked at several youtube tutorials and googled thoroughly on how to use the Extended Euclidean Algorithm to find the multiplicative inverse. I'm still not sure how to do this problem though because the remainder equals 1 in the first step...

Problem: Use the EEA and your code to find the multiplicative inverse of 5474 mod 10949. Confirm that your answer is correct by showing that 5474 * x mod 10949 = 1.

Help!

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/raaz9930
πŸ“…︎ Jan 31 2017
🚨︎ report
Using extended euclidean algorithm to solve equation.

I've been presented with the following question and I'm a bit lost as to how to solve or explain it:

Find integers x and y such that 8 = x * 1022 + y * 400, or explain why they don’t exist.

I've gone through the algorithm earlier and done the following working out:

1022 = 2 * 400 + 222

400 = 1 * 222 + 178

222 = 1 * 178 + 44

178 = 4 * 44 + 2

44 = 22 * 2 + 0

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/howtoswagpls
πŸ“…︎ Mar 06 2016
🚨︎ report
ELI5: The extended Euclidean Algorithm for finding Modular inverses

I must be a moron but anytime wikipedia gets into mathematics none of it ever makes any sense. I understand how to work the algorithm by hand using the back substitution method but I don't understand it well enough to turn it into a computer algorithm.

Basically, how do I solve something like 13^-1 mod 60 using an algorithm?

πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/rhm54
πŸ“…︎ Feb 27 2013
🚨︎ report
extended Euclidean algorithm in F# gettingsharper.de/?p=141
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/CKoenig
πŸ“…︎ Nov 21 2011
🚨︎ report
The Euclidean Algorithm implemented in Rust's type system

I was playing around with GATs today and decided to challenge myself to implement the Euclidean Algorithm using only the type system. Also, to make it even harder, I used GATs wherever possible, including for implementing comparisons, addition, squaring, and multiplication on the natural numbers.

GitHub gist

Playground link

Surprisingly the most difficult part was implementing the absolute difference operation (|x-y|). I had to create a "-1"-ish type which I'm not thrilled about :/

I tried to provide at least a little documentation of my thought process, but some of the implementation (mostly floor division) is a bit messy.

Let me know what you think, this is my first time posting here and my first finished Rust project that I'm really proud of!

πŸ‘︎ 138
πŸ’¬︎
πŸ‘€︎ u/Steelbirdy
πŸ“…︎ Nov 07 2021
🚨︎ report
I made a video on the Euclidean Algorithm for SOME1. Here is an animation (link to video in the comments) v.redd.it/yxefzn75zii71
πŸ‘︎ 99
πŸ’¬︎
πŸ‘€︎ u/NumberSense4
πŸ“…︎ Aug 20 2021
🚨︎ report
I made a video on the Euclidean Algorithm for SOME1. Here is an animation (link to video in the comments) v.redd.it/yxefzn75zii71
πŸ‘︎ 21
πŸ’¬︎
πŸ‘€︎ u/NumberSense4
πŸ“…︎ Aug 20 2021
🚨︎ report
I made a visualization of the Euclidean algorithm in my first week with manim v.redd.it/r56t9lju5wu61
πŸ‘︎ 87
πŸ’¬︎
πŸ‘€︎ u/NumberSense4
πŸ“…︎ Apr 23 2021
🚨︎ report
I made a visualization of the Euclidean algorithm in my first week with manim v.redd.it/r56t9lju5wu61
πŸ‘︎ 199
πŸ’¬︎
πŸ‘€︎ u/NumberSense4
πŸ“…︎ Apr 23 2021
🚨︎ report
Programming the Euclidean Algorithm on the Casio fx-991EX

As the title says, a program to run the Euclidean algorithm on the fx-991EX: https://imgur.com/a/L3MC2dD

It's a little technical, a little long ( ... ), but for a first ever ( because I can say with some confidence that no one sufficiently versed with calculator logic programs on a non-programmable calculator ) attempt I made in a physics lesson I don't think it's so bad ( there are a few bits here and there I'm able to condense, but for reasons of convenience I don't think I will ).

Now, as for actually running the 'program':

We start with the initialisation of the variables:

  • Set A to be the larger of the two values, B to be the smaller, and everything else as 0.

  • Make sure the calculator is operating with radians as the angle measure, degrees will not work with what I've done here. ( If you're unsure of how this is changed, just type in [ SHIFT, SETUP, 2, 2 ] ) ).

  • Next, input: [ A . STO x ]

  • If entered correctly, this should trigger a syntax error ( all intended, don't worry! ).

( note: it's important that the decimal point is not deleted until after the program is entered in full, so keep it there even as we're typing in the rest )

  • Press on the D-PAD Left button three times to move to the end of the expression and continue to write the program till we're finished and it's all on screen.

  • Remove the decimal point and start the program by pressing enter. From here on you'll need to manually push equals for every step forward.

Done! There's nothing more that requires any direct input, so just keep it going and if all goes well it’ll finish with the very last value of B as the HCF of our initial inputs A & B.

If anyone has any thoughts / queries, feel free to share, I’m quite interested to see if there’re actually any meaningful applications to this. Happy calculating!

πŸ‘︎ 13
πŸ’¬︎
πŸ‘€︎ u/MLGcrumpets
πŸ“…︎ Apr 01 2021
🚨︎ report
Fibonacci Numbers and Euclidean Algorithm

n >= 3.
The greatest common divisor is:

(F_n, F_n+1).

so be it:

aF_n + bF_{n+1}.

What general assumption could you make about a and b? Prove it.

This is our task and we are completly lost about how to deal with that.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/FallenButNotLost
πŸ“…︎ Dec 15 2020
🚨︎ report
What is the Algorithmic Complexity of Euclidean Method of GCD Calculating?

Hi folks. In short, the Euclidean method of calculating GCD says that;

suppose a&gt;= b and rem = remainder, gcd(a, b) = gcd(rem(a,b), b)

Implementing this method is also easy. However, I do wonder what its algorithmic complexity is. Or does it exist in terms of known notations? I know some basic ideas behind categorizing algorithms such as recursivity, loops, binary searches, etc, but I couldn't categorize that. Thanks in advance.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/FuxuryCo
πŸ“…︎ Oct 25 2021
🚨︎ report
I have an assignment to submit on Euclidean Algorithm . This is the reference i have got from the text book . I sort of figured out the first page . But the second one doesn't makes any sense. Any replies regarding an explanation will be extremely appreciated reddit.com/gallery/koqhvz
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/SOKLOMAX
πŸ“…︎ Jan 02 2021
🚨︎ report
Gabriel LamΓ©'s Theorem: A running time analysis of the Euclidean Algorithm - First practical application of Fibonacci numbers... This is the third video, continuing from 2 introductory videos related to Fibonacci numbers. Feedback is much appreciated :-) youtu.be/VEQ30NKUZI0
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/rondoCappuccino20
πŸ“…︎ Aug 27 2020
🚨︎ report
Just released Modulus Operandi, a Swift package for declarative modular arithmetic that supports Euclidean, flooring, and truncating division algorithms -- also with a CLI tool built by Swift Argument Parser twitter.com/cypher_poet/s…
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/CypherPoet
πŸ“…︎ Oct 25 2020
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.