The modular inverse via Gauss not Euclid

  Рет қаралды 2,218

Proof of Concept

Proof of Concept

Күн бұрын

Пікірлер: 4
@ivolol
@ivolol 2 жыл бұрын
if in each step instead of collecting bi, we just multiply the second paired value to a result that starts at 1 (mod p), you can write this as the following python: def mod_inv(a, p): res = 1 while a != 1: q, r = p // a, p % a if r < a - r: a, res = r, (res * -q) % p else: a, res = a - r, (res * (q + 1)) % p return res
@innovationsanonymous8841
@innovationsanonymous8841 3 ай бұрын
Combining her notes from the previous video: ``` def mod_inv(a, p): _, x, _ = egcd(a, p) return (x % p + p) % p def egcd(a, b): if is_prime(b): # AKS ? return egcd_reference(a, b) return egcd_gauss(a, b) def egcd_gauss(a, b): x, y, u, v = 0, 1, 1, 0 while a != 0: q1, r1 = b // a, b % a q2, r2 = q1 + 1, a - r1 if r1
@Kaepsele337
@Kaepsele337 2 жыл бұрын
Does this work for any finite field?
@ProofofConceptMath
@ProofofConceptMath 2 жыл бұрын
Very interesting question! You could imitate the formalism using polynomials instead of integers (the usual model of finite fields). I think this works fine. It's a bit more work than the usual Euclidean algorithm, because you keep around p (which is now a big polynomial), instead of swapping it out for smaller things, like in the usual Euclidean algorithm. (In the prime modulus case also, this algorithm is slower than the euclidean one -- it's of more interest pedagogically than practically.)
Modular Arithmetic: In Motion
18:48
Proof of Concept
Рет қаралды 3 М.
The extended Euclidean algorithm in one simple idea
10:59
Proof of Concept
Рет қаралды 11 М.
Underwater Challenge 😱
00:37
Topper Guild
Рет қаралды 48 МЛН
مسبح السرير #قصير
00:19
سكتشات وحركات
Рет қаралды 11 МЛН
Researchers thought this was a bug (Borwein integrals)
17:26
3Blue1Brown
Рет қаралды 3,5 МЛН
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Modular Arithmetic:  Multiplication in Motion
23:15
Proof of Concept
Рет қаралды 1,5 М.
The Euclidean Algorithm:  How and Why, Visually
13:29
Proof of Concept
Рет қаралды 31 М.
Rethinking the real line #SoME3
14:54
Proof of Concept
Рет қаралды 96 М.
Modular Arithmetic: Under the Hood
17:27
Proof of Concept
Рет қаралды 2 М.
What is the Riemann Hypothesis REALLY about?
28:33
HexagonVideos
Рет қаралды 583 М.