The modular inverse via Gauss not Euclid

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

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 7 ай бұрын
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 3 жыл бұрын
Does this work for any finite field?
@ProofofConceptMath
@ProofofConceptMath 3 жыл бұрын
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: Under the Hood
17:27
Proof of Concept
Рет қаралды 2,3 М.
Modular Arithmetic: In Motion
18:48
Proof of Concept
Рет қаралды 3,2 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
Modular Arithmetic:  Multiplication in Motion
23:15
Proof of Concept
Рет қаралды 1,6 М.
The Euclidean Algorithm:  How and Why, Visually
13:29
Proof of Concept
Рет қаралды 35 М.
Modular Arithmetic:  Addition in Motion
14:48
Proof of Concept
Рет қаралды 1,5 М.
Modular Arithmetic: User's Manual
9:23
Proof of Concept
Рет қаралды 3 М.
The extended Euclidean algorithm in one simple idea
10:59
Proof of Concept
Рет қаралды 13 М.
Studying Apollonian Circle Packings using Group Theory
8:05
Proof of Concept
Рет қаралды 6 М.
Rethinking the real line #SoME3
14:54
Proof of Concept
Рет қаралды 99 М.
Greatest common divisor and least common multiple:  building blocks
12:02
Lehmer Factor Stencils: A paper factoring machine before computers
26:06
Proof of Concept
Рет қаралды 53 М.