Modular Inverses

Multiplicative inverse

Let SS be our set that has some notion aba · b of multiplication and a neutral element 1S1 ∈ S, such that 1a=a1 · a = a for all elements aSa ∈ S. Then a multiplicative inverse a1a^{−1} of an element aSa ∈ S is defined as follows:

aa1=1.a · a^{−1} = 1.

If aa is number such that the multiplicative inverse a1a^{−1} exists, then we define division by a simply as multiplication by the inverse:

b/a:=ba1.b/a := b · a^{−1}.

In modular nn arithmetic, a number rr has a multiplicative inverse if and only if nn and rr are coprime. Since gcd(n,r)=1gcd(n, r) = 1 in that case, we know from the Extended Euclidean Algorithm that there are numbers ss and tt, such that the following equation holds:

1=sn+tr1 = s · n + t · r

If we take the modulus nn on both sides, the term sns · n vanishes, which tells us that tmodnt \mod n is the multiplicative inverse of rr in modular nn arithmetic.

The situation where the modulus is a prime number is of particular interest, because in these cases, all remainder classes must have modular inverses, since gcd(r,n)=1gcd(r, n) = 1 for prime nn and any r<nr < n. In fact, Fermat’s Little Theorem provides a way to compute multiplicative inverses in this situation, since, in case of a prime modulus pp and r<pr < p, we get the following:

rprmodprp11modprrp21modp.r^p ≡ r \mod p ⇔ \\ r^{p−1} ≡ 1 \mod p ⇔\\ r · r^{p−2} ≡ 1 \mod p.

This tells us that the multiplicative inverse of a residue class rr in modular pp arithmetic is precisely rp2r^{p−2}.

Additive inverse

The definition of multiplicative inverse has an analog definition for addition called the additive inverse. In the case of integers, the neutral element with respect to addition is 0, since a+0=0a + 0 = 0 for all integers aZa ∈ Z. The additive inverse always exists, and is given by the negative number a−a, since a+(a)=0a + (−a) = 0.

Last updated