 mersenneforum.org Calculating inverses quickly.
 Register FAQ Search Today's Posts Mark Forums Read 2019-10-25, 19:48 #1 mgb   "Michael" Aug 2006 Usually at home 2×41 Posts Calculating inverses quickly. Do you think this would be faster than the extended Euclidean Algorithm for finding inverses? For a given a find a-1 (mod m) 1. Let m = r mod a 2. Find r -1 mod a 3. Let x = a - r -1 (ie, x = -r -1 mod a) 4. a-1 mod m = (xm + 1)/a If this algorithm is applied recursively, at step 2., it should be possible to reduce the question finding the inverse of a small number and then working back up the chain to find the original inverse. The reasoning is as follows:- aa-1 = km + 1, for some k < a, so km = -1 (mod a) That is, k = -m -1 (mod a) Adding 1, km + 1 = 0 (mod a) Whence, (km + 1)/a = a-1 (Moderator, I meant to post this in the computing forum but posted here by mistake.) Last fiddled with by mgb on 2019-10-25 at 20:45   2019-10-26, 13:48   #2
Dr Sardonicus

Feb 2017
Nowhere

2·3·857 Posts Quote:
 Originally Posted by mgb Do you think this would be faster than the extended Euclidean Algorithm for finding inverses? For a given a find a-1 (mod m) 1. Let m = r mod a 2. Find r -1 mod a 3. Let x = a - r -1 (ie, x = -r -1 mod a) 4. a-1 mod m = (xm + 1)/a If this algorithm is applied recursively, at step 2., it should be possible to reduce the question finding the inverse of a small number and then working back up the chain to find the original inverse.
If I understand you correctly, you're doing the same sequence of divisions with quotient and remainder as in the Euclidean algorithm.

Last fiddled with by Dr Sardonicus on 2019-10-26 at 13:51 Reason: Rephrasing   2019-10-26, 19:21   #3
mgb

"Michael"
Aug 2006
Usually at home

2·41 Posts Quote:
 Originally Posted by Dr Sardonicus If I understand you correctly, you're doing the same sequence of divisions with quotient and remainder as in the Euclidean algorithm.
Yes but at step 2 the task is reduced to a smaller pair of numbers, to which the extended Euclidean algorithm can be applied. This is an immediate saving in processor time. Step 2 = Find r -1 mod a

Example:

Find 17 -1 mod 223
-223 -1 = 8 mod 17
(8*223 + 1)/17 = 105 = 17 -1 mod 223

Last fiddled with by mgb on 2019-10-26 at 19:41  Thread Tools Show Printable Version Email this Page Similar Threads Thread Thread Starter Forum Replies Last Post devarajkandadai Number Theory Discussion Group 1 2018-11-10 05:17 diep Homework Help 9 2014-07-12 12:14 c10ck3r Math 1 2012-02-22 06:29 CRGreathouse Math 3 2009-08-25 14:11 petrw1 PrimeNet 18 2008-11-15 23:51

All times are UTC. The time now is 08:46.

Tue Dec 7 08:46:12 UTC 2021 up 137 days, 3:15, 0 users, load averages: 1.49, 1.75, 1.70