Procedure to compute a multiplicative inverse

In summary, the conversation discusses a possible method, other than the extended Euclidean algorithm, to compute the multiplicative inverse of a number. The method involves using a twisted version of the division algorithm and finding the inverse of smaller numbers until the inverse of the original number is obtained. This procedure only works for prime moduli and can be applied to find the inverse of large numbers using the Chinese remainder theorem.
  • #1
dodo
697
2
I think I found a procedure (other than the extended Euclidean algorithm) to compute the multiplicative inverse of a number; possibly a simpler method. It goes like this:

***EDIT: Ah, dang. I made a mistake. It will only work for a prime modulus.

Suppose we need to find [itex]x[/itex] satisfying [itex]ax \equiv 1 \pmod m[/itex], where [itex]\gcd(a,m)=1[/itex].

We need to use a twisted version of the division algorithm, one that gives us integers [itex]q_1, r_1[/itex] such that [itex]m = q_1 a - r_1[/itex] (note the minus sign), with [itex]r_1[/itex] as small as possible. (So [itex]q_1=\lfloor m/a \rfloor+1[/itex].) Hence, [itex]q_1 a \equiv r_1 \pmod m[/itex].

Now, if [itex]r_1=1[/itex] we would be done: [itex]q_1[/itex] would be the multiplicative inverse we are looking for. So suppose it is not yet. But... if we had the multiplicative inverse of [itex]r_1[/itex], then we could multiply it to [itex]q_1[/itex] to get our solution.

So... rinse and repeat: find the inverse of [itex]r_1[/itex] (a smaller number, now). Note that [itex]\gcd(r_1,m)=1[/itex] (<-- only guaranteed when [itex]m[/itex] is prime!), so that the procedure can in fact be repeated.

Using the same procedure repeatedly, we obtain a sequence of divisors [itex]q_1, q_2, ..., q_n[/itex] until [itex]r_n=1[/itex]; then the multiplicative inverse of [itex]a[/itex] is the product of all [itex]q_1, q_2, ..., q_n[/itex] (reduce it modulo [itex]m[/itex] if you wish).

Here is a worked example. Suppose you want the inverse of 1234567 modulo 3257269. We proceed as follows:
3257269 = 3 . 1234567 - 446432
3257269 = 8 . 446432 - 314187
3257269 = 11 . 314187 - 198788
3257269 = 17 . 198788 - 122127
3257269 = 27 . 122127 - 40160
3257269 = 82 . 40160 - 35851
3257269 = 91 . 35851 - 5172
3257269 = 630 . 5172 - 1091
3257269 = 2986 . 1091 - 457
3257269 = 7128 . 457 - 227
3257269 = 14350 . 227 - 181
3257269 = 17996 . 181 - 7
3257269 = 465325 . 7 - 6
3257269 = 542879 . 6 - 5
3257269 = 651454 . 5 - 1

The end was agonizing, but here we are: the inverse is 3 . 8 . 11 . 17 . 27 . 82 . 91 . 630 . 2986 . 7128 . 14350 . 17996 . 465325 . 542879 . 651454... or 1127070 (mod 3257269).

On a computer, the product could be accumulated modularly, so there is really no need to handle too large numbers.
 
Last edited:
Physics news on Phys.org
  • #2
One can always break down large numbers via the modulo function and recombine the results with the Chinese remainder theorem. This is not new.
 

1. What is a multiplicative inverse?

A multiplicative inverse, also known as a reciprocal, is a number that when multiplied by a given number, results in an answer of 1.

2. Why is it important to compute a multiplicative inverse?

Computing a multiplicative inverse is important in a variety of mathematical applications, such as solving equations involving fractions, finding the inverse of a matrix, and performing division using multiplication.

3. What is the procedure for computing a multiplicative inverse?

The procedure for computing a multiplicative inverse involves taking the reciprocal of a given number. To do this, divide 1 by the given number. For example, the multiplicative inverse of 2 would be 1/2 or 0.5.

4. Can any number have a multiplicative inverse?

No, only non-zero numbers have multiplicative inverses. This is because any number multiplied by 0 will always result in 0, not 1.

5. Are there any shortcuts or tricks for computing a multiplicative inverse?

Yes, there are a few shortcuts that can be used to quickly compute a multiplicative inverse. For example, for fractions, you can simply flip the numerator and denominator. Additionally, for whole numbers, you can use the fact that the inverse of a number is equal to its reciprocal. So, the inverse of 2 can be quickly calculated by dividing 1 by 2, which is 0.5.

Back
Top