Talk:Modular multiplicative inverse

message: Modified the New examples to show why the repeating numbers terminated the computation
the old explanation is here, which doesn't explain why we terminate
the old examples also use inconsistent notation for the repeating case
assume we want to get x-1 we can do this as following.
x-1 = x * x-2
and 
x-2 = x2 * x-4
we continue this expansion until it terminates with either a repeated number, or a one.
NeilUK 20:30, 20 June 2007 (UTC)
thread_title:  early thread 

message: I'm going to remove this algorithm, because it is badly described and significantly slower than the extended Euclidean algorithm and the modular exponentiation method (even if we have to factor the modulus first). Furthermore it appears to be original research. 85.2.78.131 08:21, 17 July 2007 (UTC)
thread_title:  New Modular Multiplicative Inverse Algorithm 

message: I think it should be better to use pseudo-code or a more general-purpose language, like C. Squalho (talk) 16:55, 30 January 2009 (UTC)
thread_title:  PHP Script 

message: According to Hacker's Delight Newton's algorithm, x_{n+1} = x_n(2-d\,x_n), apparently also works in modular arithmetic, for powers-of-two anyway. Perhaps this ought to be mentioned?
At very least this results in a short and sweet (not to mention efficient) implementation if one is needed for the article.unsigned int modinv(unsigned int d) {
	unsigned int t, x = d;
	do {
		t = 2 - d*x;
		x *= t;
	} while(t != 1);
	return x;
}
--78.110.85.150 (talk) 23:02, 29 April 2009 (UTC)
thread_title:  Newton's method 

message: Correct me if I'm wrong but doesn't the fact that the solution of Bezout's Identity ax + by = 1 require that either x or y to be negative? If so then this means that its Modular multiplicative inverse is not 1 but - (a - 1) or - (b - 1). Perhaps a small mention of this might be helpful?  —Preceding unsigned comment added by 122.106.89.151 (talk) 07:37, 19 March 2010 (UTC)
replies: text: I think the last line "return x % m" should read "return (x+m) % m", since in most common programming languages, a modulus of a negative number is negative. --Erel Segal (talk) 14:37, 7 November 2010 (UTC)
replies: text:  Not in Python. -- X7q (talk) 15:52, 7 November 2010 (UTC)
thread_title:  Perhaps there should be a mention of negative values for the Modular multiplicative inverse? 

message: I am removing this. It is a specific case of direct modular exponentiation by Euler's theorem, already described.  —Preceding unsigned comment added by 164.107.227.117 (talk) 21:08, 5 May 2010 (UTC)
thread_title:  Fermat's little theorem algorithm 

message: Hi!
The article can be improved by explaining where this notation
:a^{-1} \equiv x \pmod{m}          (Equation 1)
comes from? It's supremely horrible and confusing. 
Consider this: by looking at this we learn that 
if 
:y \equiv x \pmod{m}                               (Equation 2)
then there exists an integer k, such that
:y - x  \equiv k \pmod{m}                               (Equation 3)
So now comparing the first two equations we see that 
:y = a^{-1}                                                           (Equation 4)
which means that Equation 1 can be converted to the form of Equation 3:
:a^{-1} - x  \equiv k \pmod{m}         in other words         \frac{1}{a} - x  \equiv k \pmod{m}                     (Equation 5)
Thus by following standard notation, I have shown that if Equation 1 is true, then Equation 5 must also be true (one can find an integer k such that Equation 5 is true). But of course it is not, since the left-hand side of Equation 5 cannot be an integer (if e.g. a = 5).
So my question: where the hell does the notation used in Equation 1 come from?
This definitely needs to be improved in the article, because currently it's just confusing. I'd like to know: who first used that notation? What's its history? Are there any other notations?
Because I'd never use Equation 1, but instead write:
:a x \equiv 1 \pmod{m}          (Equation 6)
Math;singular (talk) 20:02, 18 January 2011 (UTC)
thread_title:  What kind of notation is this? 

message: I updated the Euler's theorem section to say
*exponentiation. Though it can be implemented more efficiently using modular exponentiation, an efficient implementation of this operation itself requires the calculation of an inverse mod m in the first place (...)
This was to clarify a previous edit which had been reverted by User:X7q
A read of the modular exponentiation article confirms that the efficient method for modular exponentiation, namely the Montgomery method, does use a multiplicative inverse. Since this section is about the efficiency of the Euler method to calculate the inverse, I believe it is justified to use the most efficient method as the basis for the discussion. But maybe there's an even better way to explain it, I'm certainly open to discuss it.
Even if it isn't, the page before my updates did contain a mistake which I corrected (it said that modular exponentiation is a form of binary exponentiation, which is clearly not true since binary exponentiation is simply one of the methods that can be used to calculate an exponent). 83.183.40.68 (talk) 11:33, 10 July 2011 (UTC)
replies: text: Modular exponentiation can be efficiently performed using binary exponentiation algorithm, which doesn't require modular inverses. So I still think that your edit is wrong. -- X7q (talk) 11:38, 10 July 2011 (UTC)
replies: text:  Binary exponentiation without Montgomery multiplication is certainly not efficient when big numbers are involved. It requires a lengthy division at every step in order to reduce the intermediate results mod m. With the Montgomery method the only divisions required are by powers of 2 which are very efficient on any binary computer (and it can be adapted to other bases too I believe). 83.183.40.68 (talk) 11:44, 10 July 2011 (UTC)
replies: text:  Your edit made it sound like modular inversion is a required operation in modular exponention, which it isn't. Multiplication can be done without Montgomery reductions just fine, although, yes, it could be slower. -- X7q (talk) 12:01, 10 July 2011 (UTC)
replies: text:  It's required for efficiency when a big value of m is involved. But I definitely see your point, so I think the best solution would be to update the page to say this objection applies for big values of m (which is when Montgomery reduction becomes the efficient solution, and normal binary exponentiation is inefficient). Do you agree or do you have another idea? 83.183.40.68 (talk) 12:04, 10 July 2011 (UTC)
replies: text:  Agree. Please mention that implementations of modular exponentiation for large moduli typically use Montgomery reductions for efficiency, and that Montgomery reductions can not be used in this case because they require modular inverses. -- X7q (talk) 12:09, 10 July 2011 (UTC)
replies: text:  Done. I think the page is definitely better after our discussion, but I'm sure my phrasing is not optimal so feel free to improve it if needed. Thanks for the discussion! 83.183.40.68 (talk) 12:27, 10 July 2011 (UTC)
replies: text:  I agree, it looks much better now. Thank you! -- X7q (talk) 12:37, 10 July 2011 (UTC)
thread_title:  Efficiency of exponentiation under Euler's theorem 

message: http://en.wikipedia.org/wiki/Wikipedia:Talk_page_guidelines#Others.27_comments  — Preceding unsigned comment added by 60.241.171.231 (talk) 19:33, 8 April 2012 (UTC)
thread_title:  Please do not delete anything (even junk) from talk pages 

message: First its stated that "and there are no other values of x in \mathbb{Z}_{11} that satisfy this congruence" then, a line later, "Once we have found the inverse of 3 in \mathbb{Z}_{11}, we can find other values of x in \mathbb{Z} that also satisfy the congruence".  Isn't that contradictory?  — Preceding unsigned comment added by 178.38.79.80 (talk) 13:48, 28 October 2012 (UTC)
replies: text: \mathbb{Z}_{11} is the finite group consisting of the 11 equivalence classes of integers modulo 11. Of these 11 equivalence classes, only one satisfies the equation 3x \equiv 1 \pmod{11}, and that is the equivalence class that contains 4. In the set of integers \mathbb{Z}, this equivalence class corresponds to the infinite set of integers that are congruent to 4 mod 11 i.e. ..., -18, -7, 4, 15, 26, ... So there is no contradiction - the context for the two statements is just different. Gandalf61 (talk) 09:13, 29 October 2012 (UTC)
thread_title:  Example wording 

message: The example and computation sections just make the whole concept impossible to understand:
1) What the heck is the "=" sign with 3 bars?
2) What is Z(11)?
3) Why are these equations bitmaps instead of Unicode text?
4) Why don't any of these have a wikipedia hyperlink?
5) Most visitors land in this page because of the RSA article. Why is there no detailed example for 17 (mod 3120)? I tried other numbers than 17 and 3120, to no avail. Searched the whole web, not a single understandable example either.  — Preceding unsigned comment added by Chimel31 (talk • contribs) 20:32, 14 February 2013 (UTC)
thread_title:  Messy and terribly frustrating article 

message: The article starts with a term, which has the three-horizontal-lines mathematical sign, which is probably not known to a majority of people, ever to bump into this article. If a reader is familiar with this notation and principles, why would they ever ask Wikipedia? Sorry, Wikipedia is not a encyclopedia for people who already know everything, but for people curious finding out new things. If someone could make this article better? Reference to other existing articles regarding the notation might also be very useful for the beginning. Thank You!  — Preceding unsigned comment added by 129.13.72.198 (talk) 12:15, 10 February 2014 (UTC)
thread_title:  Explanation of mathematical notation is missing - making the whole article almost useless 

message: Articles in Wiki should basically not just address the already well informed but also the interested in a certain subjects. 
This article completely fails in that regard. 
The "three line" math sign is not widely known, therefore it is a hard to understand just that.
Let's say you want to find the modular multiplicative inverse i of b in regard to mod n.
(i is just a variable and not the mathematical sign for imaginary numbers!!!)
Does this not just mean the following equation is correct:
(b * i) mod n = 1 ???
This is basically what the result should be?!
I solved it with a simple spreadsheet. It is simple. It is even primitive. Not a big deal!  
I am not a math genius, but I wanted to understand it exactly and this article does not provide the least help. Sometimes articles are just frustrating. Sorry!  — Preceding unsigned comment added by 79.227.151.37 (talk • contribs) 00:19, 14 February 2014 (UTC)
thread_title:  why not even more complicated ? not a good article [sarcasm] 

message: I don't know if this section has any validity here (and I'll understand if it gets deleted), as I am not suggesting any improvements, but I just wanted to say that, as a beginner in math, this is one of the very few articles that I almost fully understood and, for the biggest part, is accessible to people unfamiliar with these concepts already. For the biggest part, it is clear and it has a structure that makes sense, so again thanks to everyone involved for this article. 
2A02:587:4526:EA00:4940:D912:B4:B87C (talk) 02:42, 16 August 2017 (UTC)
thread_title:  Excellent article 

message: I remember vaguely that there is an easier algorithm for "multiplicative inverse modulo 2n", especially when n is the word size of the processor (e.g. 32 or 64). It would be nice if this algorithm is also described here (or at least mentioned, if it has its own name/article). --RokerHRO (talk) 10:08, 16 August 2018 (UTC)
thread_title:  Special / easier algorithm for "inverse modulo 2<sup>n</sup>"?