mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory

Reply
 
Thread Tools
Old 2019-10-25, 19:48   #1
mgb
 
"Michael"
Aug 2006
Usually at home

22·3·7 Posts
Default 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
mgb is offline   Reply With Quote
Old 2019-10-26, 13:48   #2
Dr Sardonicus
 
Dr Sardonicus's Avatar
 
Feb 2017
Nowhere

633910 Posts
Default

Quote:
Originally Posted by mgb View Post
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.
<snip>
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
Dr Sardonicus is offline   Reply With Quote
Old 2019-10-26, 19:21   #3
mgb
 
"Michael"
Aug 2006
Usually at home

22×3×7 Posts
Default

Quote:
Originally Posted by Dr Sardonicus View Post
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
mgb is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
P-adic inverses devarajkandadai Number Theory Discussion Group 1 2018-11-10 05:17
calculating with circles diep Homework Help 9 2014-07-12 12:14
Calculating E based on B1 c10ck3r Math 1 2012-02-22 06:29
Calculating a difficult sum CRGreathouse Math 3 2009-08-25 14:11
Can I quickly unreserve & get my assignments back? petrw1 PrimeNet 18 2008-11-15 23:51

All times are UTC. The time now is 19:17.


Fri Mar 31 19:17:33 UTC 2023 up 225 days, 16:46, 0 users, load averages: 0.97, 0.84, 0.74

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔