The modular inverse via Gauss not Euclid

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

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 8 ай бұрын
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 М.
The extended Euclidean algorithm in one simple idea
10:59
Proof of Concept
Рет қаралды 13 М.
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
Rethinking the real line #SoME3
14:54
Proof of Concept
Рет қаралды 100 М.
Multiplicative Inverse of 3 (mod 26)
7:36
Maths with Jay
Рет қаралды 127 М.
Modular Arithmetic: In Motion
18:48
Proof of Concept
Рет қаралды 3,3 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Modular Arithmetic:  Multiplication in Motion
23:15
Proof of Concept
Рет қаралды 1,6 М.
The Euclidean Algorithm:  How and Why, Visually
13:29
Proof of Concept
Рет қаралды 37 М.
What does it feel like to invent math?
15:08
3Blue1Brown
Рет қаралды 4,2 МЛН
The soundness and completeness of logic
14:31
All Angles
Рет қаралды 41 М.
The Mathematician So Strange the FBI Thought He Was a Spy
13:11
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН