In mathematics, particularly in the area of arithmetic, a modular multiplicative inverse of an integer a is an integer x such that the product ax is congruent to 1 with respect to the modulus m. In the standard notation of modular arithmetic this congruence is written as
ax≡1(modm), which is the shorthand way of writing the statement that m divides (evenly) the quantity ax − 1, or, put another way, the remainder after dividing ax by the integer m is 1. If a does have an inverse modulo m, then there is an infinite number of solutions of this congruence, which form a congruence class with respect to this modulus. Furthermore, any integer that is congruent to a (i.e., in a's congruence class) has any element of x's congruence class as a modular multiplicative inverse. Using the notation of w‾ to indicate the congruence class containing w, this can be expressed by saying that the modulo multiplicative inverse of the congruence class a‾ is the congruence class x‾ such that:
a‾⋅x‾=1‾, where the symbol ⋅ denotes the multiplication of equivalence classes modulo m. Written in this way, the analogy with the usual concept of a multiplicative inverse in the set of rational or real numbers is clearly represented, replacing the numbers by congruence classes and altering the binary operation appropriately. As with the analogous operation on the real numbers, a fundamental use of this operation is in solving, when possible, linear congruences of the form
ax≡b(modm). Finding modular multiplicative inverses also has practical applications in the field of cryptography, e.g. public-key cryptography and the RSA algorithm. A benefit for the computer implementation of these applications is that there exists a very fast algorithm (the extended Euclidean algorithm) that can be used for the calculation of modular multiplicative inverses.
Modular arithmetic
For a given positive integer m, two integers, a and b, are said to be congruent modulo m if m divides their difference. This binary relation is denoted by,
a≡b(modm). This is an equivalence relation on the set of integers, ℤ, and the equivalence classes are called congruence classes modulo m or residue classes modulo m. Let a‾ denote the congruence class containing the integer a, then
a‾={b∈ℤ∣a≡b(modm)}. A linear congruence is a modular congruence of the form
ax≡b(modm). Unlike linear equations over the reals, linear congruences may have zero, one or several solutions. If x is a solution of a linear congruence then every element in x‾ is also a solution, so, when speaking of the number of solutions of a linear congruence we are referring to the number of different congruence classes that contain solutions. If d is the greatest common divisor of a and m then the linear congruence ax ≡ b (mod m) has solutions if and only if d divides b. If d divides b, then there are exactly d solutions. A modular multiplicative inverse of an integer a with respect to the modulus m is a solution of the linear congruence
ax≡1(modm). The previous result says that a solution exists if and only if gcd(a, m) = 1, that is, a and m must be relatively prime (i.e. coprime). Furthermore, when this condition holds, there is exactly one solution, i.e., when it exists, a modular multiplicative inverse is unique: If b and b' are both modular multiplicative inverses of a respect to the modulus m, then
ab≡ab′≡1(modm), therefore
a(b−b′)≡0(modm). If a ≡ 0 (mod m), then gcd(a, m) = m, and a won't even have a modular multiplicative inverse. Therefore, b ≡ b' (mod m). When ax ≡ 1 (mod m) has a solution it is often denoted in this way −
x≡a−1(modm), but this can be considered an abuse of notation since it could be misinterpreted as the reciprocal of a (which, contrary to the modular multiplicative inverse, is not an integer except when a is 1 or −1). The notation would be proper if a is interpreted as a token standing for the congruence class a‾, as the multiplicative inverse of a congruence class is a congruence class with the multiplication defined in the next section.
Integers modulo m The congruence relation, modulo m, partitions the set of integers into m congruence classes. Operations of addition and multiplication can be defined on these m objects in the following way: To either add or multiply two congruence classes, first pick a representative (in any way) from each class, then perform the usual operation for integers on the two representatives and finally take the congruence class that the result of the integer operation lies in as the result of the operation on the congruence classes. In symbols, these definitions are
a‾+b‾=a+b‾ and
a‾⋅b‾=ab‾, where + and ⋅ on the left denote addition and multiplication of congruence classes modulo m. These operations are well-defined, meaning that the end result does not depend on the choices of representatives that were made to obtain the result. The m congruence classes with these two defined operations form a commutative ring, called the ring of integers modulo m. There are several notations used for these algebraic objects, most often ℤ/mℤ or ℤ/m, but several elementary texts and application areas use a simplified notation ℤm when confusion with other algebraic objects is unlikely. The congruence classes of the integers modulo m were traditionally known as residue classes modulo m, reflecting the fact that all the elements of a congruence class have the same remainder (i.e., "residue") upon being divided by m. Any set of m integers selected so that each comes from a different congruence class modulo m is called a complete system of residues modulo m. The division algorithm shows that the set of integers, {0, 1, 2, ..., m − 1} form a complete system of residues modulo m, known as the least residue system modulo m. In working with arithmetic problems it is sometimes more convenient to work with a complete system of residues and use the language of congruences while at other times the point of view of the congruence classes of the ring ℤ/mℤ is more useful.
Multiplicative group of integers modulo m
… excerpt ends here. Continue reading the full article.
