From the second-to-last equation: rn=rn−2−qnrn−1.
Substitute the expression for rn−1 from the line above, then rn−2, and so on, all the way back to a and b. This substitution reveals rn=x⋅a+y⋅b for some integers x,y.
Instead of backtracking, maintain coefficients (xi,yi) at each step such that ri=xia+yib.
Base cases:
r0=a=1⋅a+0⋅b⟹(x0,y0)=(1,0)
r1=b=0⋅a+1⋅b⟹(x1,y1)=(0,1)
Recurrence: From ri=ri−2−qiri−1, we have:
ri=(xi−2a+yi−2b)−qi(xi−1a+yi−1b)=(xi−2−qixi−1)a+(yi−2−qiyi−1)b
Why this step? Each remainder is a linear combination of the previous two. If we know how to write the previous two in terms of a and b, we can write the new one the same way.
Modular Inverse: To find a−1(modm) (when gcd(a,m)=1), run Extended Euclidean on a and m. The coefficient x satisfying ax+my=1 is the inverse: ax≡1(modm).
Linear Diophantine Equations: To solve ax+by=c, first find gcd(a,b). If c is not a multiple of gcd(a,b), no solution exists. Otherwise, scale the Bézout coefficients: if ax0+by0=gcd(a,b), then x=x0⋅(c/gcd(a,b)) and y=y0⋅(c/gcd(a,b)) is a particular solution.
RSA Cryptography: Computing the private key d such that ed≡1(modϕ(n)) uses the Extended Euclidean Algorithm.
Imagine you have two piles of coins, say 56 and 15. The regular Euclidean algorithm is like repeatedly removing the smaller pile from the larger until you're left with the biggest pile size that divides both (the gcd).
Now, the Extended version asks: "Can I combine the original two pile sizes using addition and subtraction to build exactly this gcd?" The answer is always yes! The algorithm keeps a running tally: "So far, this remainder is made of __ copies of the first pile and ___ copies of the second pile (where negative means we're subtracting)."
At the end, you know exactly how many of each original pile you need to add/subtract to get the gcd. That's the magic formula ax+by=gcd(a,b) and it's used everywhere in number theory!
RSA Algorithm — private key calculation relies on Extended Euclidean
#flashcards/maths
What does the Extended Euclidean Algorithm compute? :: It computes gcd(a,b) and integers x,y such that ax+by=gcd(a,b) (Bézout's identity).
What are the base cases for the coefficient recurrence?
(x0,y0)=(1,0) for r0=a, and (x1,y1)=(0,1) for r1=b.
What is the recurrence for xi in the Extended Euclidean Algorithm?
xi=xi−2−qi⋅xi−1, where qi is the quotient at step i.
How do you find the modular inverse of a modulo m using Extended Euclidean? :: Run Extended Euclidean on a and m. If gcd(a,m)=1, the coefficient x from ax+my=1 is the inverse a−1(modm).
When does the linear Diophantine equation ax+by=c have integer solutions?
If and only if gcd(a,b) divides c.
If 56x+15y=gcd(56,15), what are x and y? :: x=−4, y=15, since 56(−4)+15(15)=1 and gcd(56,15)=1.
Why do we use the second-to-last row for the gcd and coefficients?
The last remainder is always 0. The gcd is the last non-zero remainder, which appears in the second-to-last row.
What is Bézout's Identity?
For any integers a,b (not both zero), there exist integers x,y such that ax+by=gcd(a,b).
Extended Euclidean Algorithm ek powerful technique hai jo tumhe sirf gcd nahi, balki ek special combination bhi deta hai: ax+by=gcd(a,b). Matlab agar tumhare pas do numbers hain, toh yeh algorithm tumhe bata dega kitne copies first number ke aur kitne copies second number ke (addition ya subtraction ke sath) mil kar exactly gcd ban sakta hai. Yeh Bézout's identity kehlata hai aur number theory mein bahut kaam ata hai.
Algorithm simple hai — regular Euclidean algorithm ki tarah divisions karte raho, lekin sath-saath do extra columns maintain karo: xi aur yi. Har step par recurrence use karo: xi=xi−2−qi⋅xi−1 (same for yi). Base case yad rakho: pehla number (1,0) se start hota hai aur dosra (0,1) se, kyunki a=1⋅a+0⋅b aur b=0⋅a+1⋅b.
Iska sabse bada use modular inverse nikalne mein hota hai. Agar tumhe a−1(modm) chahiye (cryptography aur coding theory mein zaroori), toh Extended Euclidean chala do a aur m par. Jo x milega wahi inverse hai! Linear Diophantine equations solve karne ke liye bhi yahi method use hota hai. Basically, yeh algorithm tumhe number theory ke bahut sare problems ka direct solution de deta hai, efficiently aur exactly.