Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Modular arithmetic

From Wikipedia, the free encyclopedia
Computation modulo a fixed integer
This article is about the concept that uses the "a (modm)" notation. For the binary operationmod(a,m), seeModulo.
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Modular arithmetic" – news ·newspapers ·books ·scholar ·JSTOR
(June 2025) (Learn how and when to remove this message)

Left: Analog clock reading 9 o'clock. Right: After four hours have passed, the clock now reads 1 o'clock.
Time-keeping on this clock uses arithmetic modulo 12. Adding 4 hours to 9 o'clock gives 1 o'clock, since 13 is congruent to 1 modulo 12.

Inmathematics,modular arithmetic is a system ofarithmetic operations forintegers, other than the usual ones from elementary arithmetic, where numbers "wrap around" when reaching a certain value, called themodulus. The modern approach tonumber theory using modular arithmetic was developed byCarl Friedrich Gauss in his bookDisquisitiones Arithmeticae, published in 1801.[1]

A familiar example of modular arithmetic is the hour hand on a12-hour clock. If the hour hand points to 7 now, then 8 hours later it will point to 3. Ordinary addition would result in7 + 8 = 15, but 15 reads as 3 on the clock face. This is because the hour hand makes one rotation every 12 hours and the hour number starts over when the hour hand passes 12. We say that 15 iscongruent to 3 modulo 12, written 15 ≡ 3 (mod 12), so that 7 + 8 ≡ 3 (mod 12).

Similarly, if one starts at 12 and waits 8 hours, the hour hand will be at 8. If one instead waited twice as long, 16 hours, the hour hand would be on 4. This can be written as 2 × 8 ≡ 4 (mod 12). Note that after a wait of exactly 12 hours, the hour hand will always be right where it was before, so 12 acts the same as zero, thus 12 ≡ 0 (mod 12).

Congruence

[edit]

Given anintegerm ≥ 1, called amodulus, two integersa andb are said to becongruent modulom, ifm is adivisor of their difference; that is, if there is an integerk such that

ab =k m.

Congruence modulom is acongruence relation, meaning that it is anequivalence relation that is compatible withaddition,subtraction, andmultiplication. Congruence modulom is denoted by

ab (mod m).{\displaystyle a\equiv b~({\text{mod }}m).}

The parentheses mean that(modm) applies to the entire equation, not just to the right-hand side (here,b).

This notation is not to be confused with the notationb modm (without parentheses), which refers to the remainder ofb when divided bym, known as themodulo operation: that is,b modm denotes the unique integerr such that0 ≤r <m andrb (modm). Indeed, the expressionb modm does not appear in the statementab (modm), since it is parsed as

(ab)modm.{\displaystyle (a\equiv b){\bmod {m}}.}

The congruence relation may be rewritten as

a =k m +b,

explicitly showing its relationship withEuclidean division. However, theb here need not be the remainder in the division ofa bym. Rather,ab (modm) asserts thata andb have the sameremainder when divided bym. That is,

a =p m +r,
b =q m +r,

where0 ≤r <m is the common remainder. We recover the previous relation (ab =k m) by subtracting these two expressions and settingk =pq.

Because the congruence modulom is defined by thedivisibility bym and because−1 is aunit in the ring of integers, a number is divisible bym exactly if it is divisible bym.This means that every non-zero integerm may be taken as a modulus.

Examples

[edit]

In modulus 12, one can assert that:

38 ≡ 14 (mod 12)

because the difference is38 − 14 = 24 = 2 × 12, a multiple of12. Equivalently,38 and14 have the same remainder2 when divided by12.

The definition of congruence also applies to negative values. For example:

23(mod5)8+7(mod5)38(mod5).{\displaystyle {\begin{aligned}2&\equiv -3{\pmod {5}}\\-8&\equiv {\phantom {+}}7{\pmod {5}}\\-3&\equiv -8{\pmod {5}}.\end{aligned}}}

Basic properties

[edit]

The congruence relation satisfies all the conditions of anequivalence relation:

  • Reflexivity:aa (modm)
  • Symmetry:ab (modm) if and only ifba (modm).
  • Transitivity: Ifab (modm) andbc (modm), thenac (modm)

Ifa1b1 (modm) anda2b2 (modm), or ifab (modm), then:[2]

  • a +kb +k (modm) for any integerk (compatibility with translation)
  • k ak b (modm) for any integerk (compatibility with scaling)
  • k ak b (modk m) for any integerk
  • a1 +a2b1 +b2 (modm) (compatibility with addition)
  • a1a2b1b2 (modm) (compatibility with subtraction)
  • a1a2b1b2 (modm) (compatibility with multiplication)
  • akbk (modm) for any non-negative integerk (compatibility with exponentiation)
  • p(a) ≡p(b) (modm), for anypolynomialp(x) with integer coefficients (compatibility with polynomial evaluation)

Ifab (modm), then it is generally false thatkakb (modm). However, the following is true:

Ifab (modmn), thenab (modm) andab (modn).

For cancellation of common terms, we have the following rules:

  • Ifa +kb +k (modm), wherek is any integer, thenab (modm).
  • Ifk ak b (modm) andk is coprime withm, thenab (modm).
  • Ifk ak b (modk m) andk ≠ 0, thenab (modm).

The last rule can be used to move modular arithmetic into division. Ifb dividesa, then(a/b) modm = (a modb m) /b.

Themodular multiplicative inverse is defined by the following rules:

  • Existence: There exists an integer denoteda−1 such thataa−1 ≡ 1 (modm) if and only ifa is coprime withm. This integera−1 is called amodular multiplicative inverse ofa modulom.
  • Ifab (modm) anda−1 exists, thena−1b−1 (modm) (compatibility with multiplicative inverse, and, ifa =b, uniqueness modulom).
  • Ifaxb (modm) anda is coprime tom, then the solution to this linear congruence is given byxa−1b (modm).

The multiplicative inversexa−1 (modm) may be efficiently computed by solvingBézout's equationa x +m y = 1 forx,y, by using theExtended Euclidean algorithm.

In particular, ifp is a prime number, thena is coprime withp for everya such that0 <a <p; thus a multiplicative inverse exists for alla that is not congruent to zero modulop.

Advanced properties

[edit]

Some of the more advanced properties of congruence relations are the following:

  • Fermat's little theorem: Ifp is prime and does not dividea, thenap−1 ≡ 1 (modp).
  • Euler's theorem: Ifa andm are coprime, thenaφ(m) ≡ 1 (modm), whereφ isEuler's totient function.
  • A simple consequence of Fermat's little theorem is that ifp is prime, thena−1ap−2 (modp) is the multiplicative inverse of0 <a <p. More generally, from Euler's theorem, ifa andm are coprime, thena−1aφ(m)−1 (modm). Hence, ifax1 (modm), thenxaφ(m)−1 (modm).
  • Another simple consequence is that ifab (modφ(m)), whereφ is Euler's totient function, thenkakb (modm) providedk iscoprime withm.
  • Wilson's theorem:p is prime if and only if(p − 1)! ≡ −1 (modp).
  • Chinese remainder theorem: For anya,b and coprimem,n, there exists a uniquex (modmn) such thatxa (modm) andxb (modn). In fact,xb mn−1m +a nm−1n (modmn) wheremn−1 is the inverse ofm modulon andnm−1 is the inverse ofn modulom.
  • Lagrange's theorem: Ifp is prime andf (x) =a0xd + ... +ad is apolynomial with integer coefficients such thatp is not a divisor ofa0, then the congruencef (x) ≡ 0 (modp) has at mostd non-congruent solutions.
  • Primitive root modulom: A numberg is a primitive root modulom if, for every integera coprime tom, there is an integerk such thatgka (modm). A primitive root modulom exists if and only ifm is equal to2, 4,pk or 2pk, wherep is an odd prime number andk is a positive integer. If a primitive root modulom exists, then there are exactlyφ(φ(m)) such primitive roots, whereφ is the Euler's totient function.
  • Quadratic residue: An integera is a quadratic residue modulom, if there exists an integerx such thatx2a (modm).Euler's criterion asserts that, ifp is an odd prime, anda is not a multiple ofp, thena is a quadratic residue modulop if and only if
    a(p−1)/2 ≡ 1 (modp).

Congruence classes

[edit]

The congruence relation is anequivalence relation. Theequivalence class modulom of an integera is the set of all integers of the forma +k m, wherek is any integer. It is called thecongruence class orresidue class ofa modulo m, and may be denoted(a modm), or asa or[a] when the modulusm is known from the context.

Each residue class modulo m contains exactly one integer in the range0,...,|m|1{\displaystyle 0,...,|m|-1}. Thus, these|m|{\displaystyle |m|} integers arerepresentatives of their respective residue classes.

It is generally easier to work with integers than sets of integers; that is, the representatives most often considered, rather than their residue classes.

Consequently,(a modm) denotes generally the unique integerr such that0 ≤r <m andra (modm); it is called theresidue ofa modulo m.

In particular,(a modm) = (b modm) is equivalent toab (modm), and this explains why "=" is often used instead of "" in this context.

Residue systems

[edit]

Each residue class modulom may be represented by any one of its members, although we usually represent each residue class by the smallest nonnegative integer which belongs to that class[3] (since this is the proper remainder which results from division). Any two members of different residue classes modulom are incongruent modulom. Furthermore, every integer belongs to one and only one residue class modulom.[4]

The set of integers{0, 1, 2, ...,m − 1} is called theleast residue system modulom. Any set ofm integers, no two of which are congruent modulom, is called acomplete residue system modulom.

The least residue system is a complete residue system, and a complete residue system is simply a set containing precisely onerepresentative of each residue class modulom.[5] For example, the least residue system modulo4 is{0, 1, 2, 3}. Some other complete residue systems modulo4 include:

  • {1, 2, 3, 4}
  • {13, 14, 15, 16}
  • {−2, −1, 0, 1}
  • {−13, 4, 17, 18}
  • {−5, 0, 6, 21}
  • {27, 32, 37, 42}

Some sets that arenot complete residue systems modulo 4 are:

  • {−5, 0, 6, 22}, since6 is congruent to22 modulo4.
  • {5, 15}, since a complete residue system modulo4 must have exactly4 incongruent residue classes.

Reduced residue systems

[edit]
Main article:Reduced residue system

Given theEuler's totient functionφ(m), any set ofφ(m) integers that arerelatively prime tom and mutually incongruent under modulusm is called areduced residue system modulom.[6] The set{5, 15} from above, for example, is an instance of a reduced residue system modulo 4.

Covering systems

[edit]
Main article:Covering system

Covering systems represent yet another type of residue system that may contain residues with varying moduli.

Integers modulom

[edit]

In the context of this paragraph, the modulusm is almost always taken as positive.

The set of allcongruence classes modulom is aring called thering of integers modulom, and is denotedZ/mZ{\textstyle \mathbb {Z} /m\mathbb {Z} },Z/m{\displaystyle \mathbb {Z} /m}, orZm{\displaystyle \mathbb {Z} _{m}}.[7] The ringZ/mZ{\displaystyle \mathbb {Z} /m\mathbb {Z} } is fundamental to various branches of mathematics (see§ Applications below).(In some parts ofnumber theory the notationZm{\displaystyle \mathbb {Z} _{m}} is avoided because it can be confused with the set ofm-adic integers.)

Form > 0 one has

Z/mZ={a¯maZ}={0¯m,1¯m,2¯m,,m1¯m}.{\displaystyle \mathbb {Z} /m\mathbb {Z} =\left\{{\overline {a}}_{m}\mid a\in \mathbb {Z} \right\}=\left\{{\overline {0}}_{m},{\overline {1}}_{m},{\overline {2}}_{m},\ldots ,{\overline {m{-}1}}_{m}\right\}.}

Whenm = 1,Z/mZ{\displaystyle \mathbb {Z} /m\mathbb {Z} } is thezero ring; whenm = 0,Z/mZ{\displaystyle \mathbb {Z} /m\mathbb {Z} } is not anempty set; rather, it isisomorphic toZ{\displaystyle \mathbb {Z} }, sincea0 = {a}.

Addition, subtraction, and multiplication are defined onZ/mZ{\displaystyle \mathbb {Z} /m\mathbb {Z} } by the following rules:

The properties given before imply that, with these operations,Z/mZ{\displaystyle \mathbb {Z} /m\mathbb {Z} } is acommutative ring. For example, in the ringZ/24Z{\displaystyle \mathbb {Z} /24\mathbb {Z} }, one has

12¯24+21¯24=33¯24=9¯24{\displaystyle {\overline {12}}_{24}+{\overline {21}}_{24}={\overline {33}}_{24}={\overline {9}}_{24}}

as in the arithmetic for the 24-hour clock.

The notationZ/mZ{\displaystyle \mathbb {Z} /m\mathbb {Z} } is used because this ring is thequotient ring ofZ{\displaystyle \mathbb {Z} } by theidealmZ{\displaystyle m\mathbb {Z} }, the set formed by all multiples ofm, that is, all numbersk m withkZ.{\displaystyle k\in \mathbb {Z} .}

Under addition,Z/mZ{\displaystyle \mathbb {Z} /m\mathbb {Z} } is acyclic group. All finite cyclic groups are isomorphic withZ/mZ{\displaystyle \mathbb {Z} /m\mathbb {Z} } for somem.[8]

The ring of integers modulom is afield; that is, every nonzero element has amultiplicative inverse, if and only ifm isprime. Ifm =pk is aprime power withk > 1, there exists a unique (up to isomorphism) finite fieldGF(m)=Fm{\displaystyle \mathrm {GF} (m)=\mathbb {F} _{m}} withm elements, which isnot isomorphic toZ/mZ{\displaystyle \mathbb {Z} /m\mathbb {Z} }, which fails to be a field because it haszero-divisors.

Ifm > 1,(Z/mZ)×{\displaystyle (\mathbb {Z} /m\mathbb {Z} )^{\times }} denotes themultiplicative group of the integers modulom that are invertible. It consists of the congruence classesam, whereais coprime tom; these are precisely the classes possessing a multiplicative inverse. They form anabelian group under multiplication; its order isφ(m), whereφ isEuler's totient function.

Applications

[edit]

In pure mathematics, modular arithmetic is one of the foundations ofnumber theory, touching on almost every aspect of its study, and it is also used extensively ingroup theory,ring theory,knot theory, andabstract algebra. In applied mathematics, it is used incomputer algebra,cryptography,computer science,chemistry and thevisual andmusical arts.

A very practical application is to calculate checksums within serial number identifiers. For example,International Standard Book Number (ISBN) uses modulo 11 (for 10-digit ISBN) or modulo 10 (for 13-digit ISBN) arithmetic for error detection. Likewise,International Bank Account Numbers (IBANs) use modulo 97 arithmetic to spot user input errors in bank account numbers. In chemistry, the last digit of theCAS registry number (a unique identifying number for each chemical compound) is acheck digit, which is calculated by taking the last digit of the first two parts of the CAS registry number times 1, the previous digit times 2, the previous digit times 3 etc., adding all these up and computing the sum modulo 10.

In cryptography, modular arithmetic directly underpinspublic key systems such asRSA andDiffie–Hellman, and providesfinite fields which underlieelliptic curves, and is used in a variety ofsymmetric key algorithms includingAdvanced Encryption Standard (AES),International Data Encryption Algorithm (IDEA), andRC4. RSA and Diffie–Hellman usemodular exponentiation.

In computer algebra, modular arithmetic is commonly used to limit the size of integer coefficients in intermediate calculations and data. It is used inpolynomial factorization, a problem for which all known efficient algorithms use modular arithmetic. It is used by the most efficient implementations ofpolynomial greatest common divisor, exactlinear algebra andGröbner basis algorithms over the integers and the rational numbers. As posted onFidonet in the 1980s and archived atRosetta Code, modular arithmetic was used to disproveEuler's sum of powers conjecture on aSinclair QLmicrocomputer using just one-fourth of the integer precision used by aCDC 6600supercomputer to disprove it two decades earlier via abrute force search.[9]

In computer science, modular arithmetic is often applied inbitwise operations and other operations involving fixed-width, cyclicdata structures. The modulo operation, as implemented in manyprogramming languages andcalculators, is an application of modular arithmetic that is often used in this context. The logical operatorXOR sums 2 bits, modulo 2.

The use oflong division to turn a fraction into arepeating decimal in any baseb is equivalent to modular multiplication ofb modulo the denominator. For example, for decimal,b = 10.

In music, arithmetic modulo 12 is used in the consideration of the system oftwelve-tone equal temperament, whereoctave andenharmonic equivalency occurs (that is, pitches in a 1:2 or 2:1 ratio are equivalent, and C-sharp is considered the same as D-flat).

The method ofcasting out nines offers a quick check of decimal arithmetic computations performed by hand. It is based on modular arithmetic modulo 9, and specifically on the crucial property that 10 ≡ 1 (mod 9).

Arithmetic modulo 7 is used in algorithms that determine the day of the week for a given date. In particular,Zeller's congruence and theDoomsday algorithm make heavy use of modulo-7 arithmetic.

More generally, modular arithmetic also has application in disciplines such aspolitics (for example,apportionment),economics (for example,game theory) and other areas of thesocial sciences, whereproportional division and allocation of resources plays a central part of the analysis.

Computational complexity

[edit]

Since modular arithmetic has such a wide range of applications, it is important to know how hard it is to solve a system of congruences. A linear system of congruences can be solved inpolynomial time with a form ofGaussian elimination, for details seelinear congruence theorem. Algorithms, such asMontgomery reduction, also exist to allow simple arithmetic operations, such as multiplication andexponentiation modulo m, to be performed efficiently on large numbers.

Some operations, like finding adiscrete logarithm or aquadratic congruence appear to be as hard asinteger factorization and thus are a starting point forcryptographic algorithms andencryption. These problems might beNP-intermediate.

Solving a system of non-linear modular arithmetic equations isNP-complete.[10]

See also

[edit]

Notes

[edit]
  1. ^Gray, Jeremy. A History of Abstract Algebra: From Algebraic Equations to Modern Algebra. Germany, Springer International Publishing, 2018. 143.
  2. ^Lehoczky & Rusczky 2006.
  3. ^Weisstein.
  4. ^Pettofrezzo & Byrkit 1970, p. 90.
  5. ^Long 1972, p. 78.
  6. ^Long 1972, p. 85.
  7. ^Denton 2013.
  8. ^Sengadir T.,Discrete Mathematics and Combinatorics, p. 293, atGoogle Books
  9. ^"Euler's sum of powers conjecture".rosettacode.org.Archived from the original on 26 March 2023. Retrieved11 November 2020.
  10. ^Garey & Johnson 1979.

References

[edit]
  • Lehoczky, Sandor;Rusczky, Richard (2006). Patrick, David (ed.).The Art of Problem Solving. Vol. 1 (7 ed.). AoPS Incorporated. p. 44.ISBN 0977304566.

External links

[edit]
Fields
Key concepts
Advanced concepts
Retrieved from "https://en.wikipedia.org/w/index.php?title=Modular_arithmetic&oldid=1338339052"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp