All Topics  
Modular arithmetic

 

   Email Print
   Bookmark   Link






 

Modular arithmetic



 
 
In mathematics
Mathematics

Mathematics is the study of quantity, structure, space, change, and related topics of pattern and form. Mathematicians seek out patterns whether found in numbers, space, natural science, computers, imaginary abstractions, or elsewhere....
, modular arithmetic (sometimes called clock arithmetic) is a system of arithmetic
Arithmetic

Arithmetic or arithmetics is the oldest and most elementary branch of mathematics, used by almost everyone, for tasks ranging from simple day-to-day counting to advanced science and business calculations....
 for integer
Integer

The integers are natural numbers including 0 and their negative and non-negative numberss . They are numbers that can be written without a fractional or decimal component, and fall within the set ....
s, where numbers "wrap around" after they reach a certain value — the modulus. Modular arithmetic was introduced by Carl Friedrich Gauss
Carl Friedrich Gauss

Johann Carl Friedrich Gauss. was a Germans mathematician and scientist who contributed significantly to many fields, including number theory, statistics, mathematical analysis, Differential geometry and topology, geodesy, electrostatics, astronomy and optics....
 in his book Disquisitiones Arithmeticae
Disquisitiones Arithmeticae

The Disquisitiones Arithmeticae is a textbook of number theory written by Germany mathematician Carl Friedrich Gauss in 1798 when Gauss was 21 and first published in 1801 when he was 24....
, published in 1801.

A familiar use of modular arithmetic is its use in the 12-hour clock
12-hour clock

The 12-hour clock is a time conversion convention in which the 24 hours of the day are divided into two periods called ante meridiem and post meridiem ....
: the arithmetic of time-keeping in which the day is divided into two 12 hour periods.






Discussion
Ask a question about 'Modular arithmetic'
Start a new discussion about 'Modular arithmetic'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In mathematics
Mathematics

Mathematics is the study of quantity, structure, space, change, and related topics of pattern and form. Mathematicians seek out patterns whether found in numbers, space, natural science, computers, imaginary abstractions, or elsewhere....
, modular arithmetic (sometimes called clock arithmetic) is a system of arithmetic
Arithmetic

Arithmetic or arithmetics is the oldest and most elementary branch of mathematics, used by almost everyone, for tasks ranging from simple day-to-day counting to advanced science and business calculations....
 for integer
Integer

The integers are natural numbers including 0 and their negative and non-negative numberss . They are numbers that can be written without a fractional or decimal component, and fall within the set ....
s, where numbers "wrap around" after they reach a certain value — the modulus. Modular arithmetic was introduced by Carl Friedrich Gauss
Carl Friedrich Gauss

Johann Carl Friedrich Gauss. was a Germans mathematician and scientist who contributed significantly to many fields, including number theory, statistics, mathematical analysis, Differential geometry and topology, geodesy, electrostatics, astronomy and optics....
 in his book Disquisitiones Arithmeticae
Disquisitiones Arithmeticae

The Disquisitiones Arithmeticae is a textbook of number theory written by Germany mathematician Carl Friedrich Gauss in 1798 when Gauss was 21 and first published in 1801 when he was 24....
, published in 1801.

A familiar use of modular arithmetic is its use in the 12-hour clock
12-hour clock

The 12-hour clock is a time conversion convention in which the 24 hours of the day are divided into two periods called ante meridiem and post meridiem ....
: the arithmetic of time-keeping in which the day is divided into two 12 hour periods. If the time is 7:00 now, then 8 hours later it will be 3:00. Usual addition would suggest that the later time should be 7 + 8 = 15, but this is not the answer because clock time "wraps around" every 12 hours; there is no "15 o'clock". Likewise, if the clock starts at 12:00 (noon) and 21 hours elapse, then the time will be 9:00 the next day, rather than 33:00. Since the hour number starts over when it reaches 12, this is arithmetic modulo 12.

The congruence relation

Modular arithmetic can be handled mathematically by introducing a congruence relation
Congruence relation

In mathematics and especially in abstract algebra, a congruence relation or simply congruence is an equivalence relation that is compatible with some algebraic operation....
 on the integer
Integer

The integers are natural numbers including 0 and their negative and non-negative numberss . They are numbers that can be written without a fractional or decimal component, and fall within the set ....
s that is compatible with the operations of the ring
Ring (mathematics)

In mathematics, a ring is a type of algebraic structure. There is some variation among mathematicians as to exactly what properties a ring is required to have, as described in detail below....
 of integers: addition
Addition

Addition is the mathematics process of putting things together. The plus sign "+" means that numbers are added together. For example, in the picture on the right, there are 3 + 2 apples?meaning three apples and two other apples?which is the same as five apples, since 3 + 2 = 5....
, subtraction
Subtraction

Subtraction is one of the four basic arithmetic operations; it is the inverse of addition, meaning that if we start with any number and add any number and then subtract the same number we added, we return to the number we started with....
, and multiplication
Multiplication

Multiplication is the Operation of scaling one number by another. It is one of the four basic operations in elementary arithmetic .Multiplication is defined for Natural number in terms of repeated addition; for example, 4 multiplied by 3 can be calculated by adding 3 copies of 4 together:...
. For a fixed modulus n, it is defined as follows.

Two integers a and b are said to be congruent modulo n, if their difference a - b is an integer multiple
Multiple (mathematics)

In mathematics, a multiple of an integer is the Multiplication of that integer with another integer. In other words, for integer , is a multiple of iff for some integer ....
 of n. An equivalent definition is that both numbers have the same remainder when divided by n. If this is the case, it is expressed as:



The above mathematical statement is read: "a is congruent to b modulo n".

For example,

because 38 − 14 = 24, which is a multiple of 12. For positive n and non-negative a and b, congruence of a and b can also be thought of as asserting that these two numbers have the same remainder
Remainder

In arithmetic, when the result of the division of two integers cannot be expressed with an integer quotient, the remainder is the amount "left over."...
 after dividing by the modulus n. So,

because both numbers, when divided by 12, have the same remainder (2). Equivalently, the fractional parts of doing a full division of each of the numbers by 12 are the same: .1666... (38/12 = 3.166..., 2/12 = .1666...). From the prior definition we also see that their difference, a - b = 36, is a whole number (integer
Integer

The integers are natural numbers including 0 and their negative and non-negative numberss . They are numbers that can be written without a fractional or decimal component, and fall within the set ....
) multiple of 12 ( n = 12, 36/12 = 3).

The same rule holds for negative values of a:

A remark on the notation: Because it is common to consider several congruence relations for different moduli at the same time, the modulus is incorporated in the notation. In spite of the ternary notation, the congruence relation for a given modulus is binary
Binary relation

In mathematics, a binary relation is an arbitrary association of elements within a set or with elements of another set.An example is the "divides" relation between the set of prime numbers P and the set of integers Z, in which every prime p is associated with every integer z that is a divisibility of p, and no othe...
. This would have been clearer if the notation a n b had been used, instead of the common traditional notation.

The properties that make this relation a congruence relation (respecting addition, subtraction, and multiplication) are the following.

If and , then:

The ring of congruence classes

Like any congruence relation, congruence modulo n is an equivalence relation
Equivalence relation

In mathematics, an equivalence relation is, loosely, a binary relation on a Set that specifies how to split up the set into subsets such that every element of the larger set is in exactly one of the subsets....
, and the equivalence class
Equivalence class

In mathematics, given a Set X and an equivalence relation ~ on X, the equivalence class of an element a in X is the subset of all elements in X which are equivalent to a:...
 of the integer a, denoted by , is the set . This set, consisting of the integers congruent to a modulo n, is called the congruence class or residue class of a modulo n. Another notation for this congruence class, which requires that in the context the modulus is known, is .

The set of congruence classes modulo n is denoted as (or, alternatively, or ) and defined by:

When n ? 0, has n elements, and can be written as:

When n = 0, does not have zero elements; rather, it is isomorphic
Isomorphism

In abstract algebra, an isomorphism is a bijection map f such that both f and its inverse function f −1 are homomorphisms, i.e., structure-preserving mappings....
 to , since .

We can define addition, subtraction, and multiplication on by the following rules:



The verification that this is a proper definition uses the properties given before.

In this way, becomes a commutative ring
Commutative ring

In ring theory, a branch of abstract algebra, a commutative ring is a Ring in which the multiplication operation is commutative. The study of commutative rings is called commutative algebra....
. For example, in the ring , we have as in the arithmetic for the 24-hour clock.

The notation is used, because it is the factor ring of by the ideal containing all integers divisible by n, where is the singleton set .

In terms of groups, the residue class is the coset
Coset

In mathematics, if G is a group , H is a subgroup of G, and g is an element of G, thenA coset is a left or right coset of some subgroup in G....
 of a in the quotient group
Quotient group

In mathematics, given a group G and a normal subgroup N of G, the quotient group, or factor group, of G over N is intuitively a group that "collapses" the normal subgroup N to the identity element....
 , a cyclic group
Cyclic group

In group theory, a cyclic group or monogenous group is a group that can be generating set of a group by a single element, in the sense that the group has an element g such that, when written multiplicatively, every element of the group is a power of g ....
.

The set has a number of important mathematical properties that are foundational to various branches of mathematics.

Rather than excluding the special case n = 0, it is more useful to include (which, as mentioned before, is isomorphic to the ring of integers), for example when discussing the characteristic
Characteristic (algebra)

In mathematics, the characteristic of a ring R, often denoted char, is defined to be the smallest number of times one must add the ring's multiplicative identity element to itself to get the additive identity element ; the ring is said to have characteristic zero if this repeated sum never reaches the additive identity....
 of a ring
Ring (mathematics)

In mathematics, a ring is a type of algebraic structure. There is some variation among mathematicians as to exactly what properties a ring is required to have, as described in detail below....
.

Remainders

The notion of modular arithmetic is related to that of the remainder
Remainder

In arithmetic, when the result of the division of two integers cannot be expressed with an integer quotient, the remainder is the amount "left over."...
 in division
Division (mathematics)

In mathematics, especially in elementary arithmetic, division is an arithmetic operation which is the inverse of multiplication.Specifically, if c times b equals a, written:...
. The operation of finding the remainder is sometimes referred to as the modulo operation
Modulo operation

In computing, the modulo operation finds the remainder of division of one number by another.Given two numbers, and , a modulo n is the remainder, on division of a by n....
 and we may see "2 = 14 (mod 12)". The difference is in the use of congruency, indicated by =, and equality indicated by =. Equality implies specifically the "common residue", the least non-negative member of an equivalence class. When working with modular arithmetic, each equivalence class is usually represented by its common residue, for example "38 = 2 (mod 12)" which can be found using long division
Long division

In arithmetic, long division is the standard algorithm suitable for dividing simple or complex multidigit numbers. It breaks down a division problem into a series of easier steps....
. It follows that, while it is correct to say "38 = 14 (mod 12)", and "2 = 14 (mod 12)", it is incorrect to say "38 = 14 (mod 12)" (with "=" rather than "=").

Parentheses are sometimes dropped from the expression, e.g. "38 = 14 mod 12" or "2 = 14 mod 12", or placed around the divisor e.g. "38 = 14 mod (12)". Notation such as "38(mod 12)" has also been observed, but is ambiguous without contextual clarification.

The congruence relation is sometimes expressed by using modulo instead of mod, like "38 = 14 (modulo 12)" in computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
. The modulo function in various computer languages typically yield the common residue, for example the statement "y = MOD(38,12);" gives y = 2.

Functional representation of the remainder

If then there exists an integer k>=0 such that .

b, the remainder can be written , where is the integer (whole) part of .

Another functional representation is using Sine
Siné

Maurice Sinet, known as Sin? is a France cartoonist.As a young man he studied drawing and graphic arts, earning his life as a cabaret singer....
 and Arcsine.

Let

then ,     where          or         

and

,     where          or         

and a is the angle (in radians) of the expression inside the sinus:

Applications

Modular arithmetic is referenced in number theory
Number theory

Number theory is the branch of pure mathematics concerned with the properties of numbers in general, and integers in particular, as well as the wider classes of problems that arise from their study....
, group theory
Group theory

In mathematics and abstract algebra, group theory studies the algebraic structures known as group .The concept of a group is central to abstract algebra: other well-known algebraic structures, such as ring , field , and vector spaces can all be seen as groups endowed with additional operations and axioms....
, ring theory
Ring theory

In mathematics, ring theory is the study of ring , algebraic structures in which addition and multiplication are defined and have similar properties to those familiar from the integers....
, knot theory
Knot theory

In mathematics, knot theory is the area of topology that studies knot s. While inspired by knots which appear in daily life in shoelaces and rope, a mathematician's knot differs drastically in that the ends are joined together to prevent it from becoming undone....
, abstract algebra
Abstract algebra

Abstract algebra is the subject area of mathematics that studies algebraic structures, such as group , ring , field , module , vector spaces, and algebra over a field....
, cryptography
Cryptography

Cryptography is the practice and study of hiding information. In modern times cryptography is considered a branch of both mathematics and computer science and is affiliated closely with information theory, computer security and engineering....
, computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, chemistry
Chemistry

Chemistry is the science concerned with the composition, structure, and properties of matter, as well as the changes it undergoes during chemical reactions....
 and the visual
Visual arts

The visual arts are Art#Art forms that focus on the creation of works which are primarily visual in nature, such as drawing, painting, photography, printmaking, and filmmaking....
 and music
Music

Music is an art form whose media is sound organized in time. Common elements of music are pitch , rhythm , dynamics , and the sonic qualities of timbre and texture ....
al arts.

It is one of the foundations of number theory, touching on almost every aspect of its study, and provides key examples for group theory, ring theory and abstract algebra.

In cryptography, modular arithmetic directly underpins public key
Public-key cryptography

Public-key cryptography is a method for secret communication between two parties without requiring an initial key exchange of secret key. It can also be used to create digital signature....
 systems such as RSA
RSA

In cryptography, RSA is an algorithm for public-key cryptography. It is the first algorithm known to be suitable for digital signature as well as encryption, and one of the first great advances in public key cryptography....
 and Diffie-Hellman
Diffie-Hellman key exchange

Diffie-Hellman key exchange is a cryptographic protocol that allows two parties that have no prior knowledge of each other to jointly establish a shared secret key over an insecure communications channel....
, as well as providing finite field
Finite field

In abstract algebra, a finite field or Galois field is a field that contains only finitely many elements. Finite fields are important in number theory, algebraic geometry, Galois theory, cryptography, and coding theory....
s which underlie elliptic curve
Elliptic curve

In mathematics, an elliptic curve is a differentiable manifold, algebraic variety#Projective varieties algebraic curve of genus #Algebraic geometry one, on which there is a specified point O....
s, and is used in a variety of symmetric key algorithms including AES
Advanced Encryption Standard

In cryptography, the Advanced Encryption Standard is an encryption standard adopted by the Federal government of the United States. The standard comprises three block ciphers, AES-128, AES-192 and AES-256, adopted from a larger collection originally published as Rijndael. Each AES cipher has a 128 bit block size, with key sizes of 128...
, IDEA
International Data Encryption Algorithm

In cryptography, the International Data Encryption Algorithm is a block cipher designed by Xuejia Lai and James Massey of ETH Zurich and was first described in 1991....
, and RC4
RC4

In cryptography, RC4 is the most widely-used software stream cipher and is used in popular protocols such as Secure Sockets Layer and Wired Equivalent Privacy ....
.

In computer science, modular arithmetic is often applied in bitwise operation
Bitwise operation

In computer programming, a bitwise operation operates on one or two bit patterns or Binary numeral system at the level of their individual bits....
s and other operations involving fixed-width, cyclic data structure
Data structure

A data structure in computer science is a way of storing data in a computer so that it can be used efficiently. It is an organization of mathematical and logical concepts of data....
s. The modulo operation
Modulo operation

In computing, the modulo operation finds the remainder of division of one number by another.Given two numbers, and , a modulo n is the remainder, on division of a by n....
, as implemented in many programming language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
s and calculator
Calculator

A calculator is a device for performing mathematical calculations, distinguished from a computer by having a limited problem solving ability and an interface optimized for interactive calculation rather than programming....
s, is an application of modular arithmetic that is often used in this context.

In chemistry, the last digit of the CAS registry number
CAS registry number

CAS registry numbers are unique numerical identifiers for chemical elements, chemical compound, polymers, biological sequences, mixtures and alloys....
 (a number which is unique for each chemical compound) is a check digit
Check digit

A check digit is a form of redundancy check used for error detection, the decimal equivalent of a binary checksum. It consists of a single digit computed from the other digits in the message....
, which is calculated by taking the last digit of the first two parts of the CAS registry number
CAS registry number

CAS registry numbers are unique numerical identifiers for chemical elements, chemical compound, polymers, biological sequences, mixtures and alloys....
 times 1, the next digit times 2, the next digit times 3 etc., adding all these up and computing the sum modulo 10.

In music, arithmetic modulo 12 is used in the consideration of the system of twelve-tone equal temperament, where octave
Octave

In music, an octave The octave is occasionally referred to as a diapason.The octave above an indicated note is sometimes abbreviated 8va, and the octave below 8vb....
 and enharmonic
Enharmonic

In modern music and musical notation, an enharmonic equivalent is a note , interval , or key signature which is equivalence to some other note, interval, or key signature, but "spelled", or named, differently....
 equivalency occurs (that is, pitches in a 1:2 or 2:1 ratio are equivalent, and C-sharp
Sharp (music)

In music, sharp means higher in pitch. More specifically, in musical notation, sharp means "higher in pitch by a semitone ," and has an associated symbol , which is often confused with the number sign ....
 is considered the same as D-flat).

The method of casting out nines
Casting out nines

Casting out nines is a sanity check to ensure that hand computations of sums, differences, products, and quotients of integers are correct. By looking at the digital roots of the inputs and outputs, the casting-out-nines method can help one check arithmetic calculations....
 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).

More generally, modular arithmetic also has application in disciplines such as law
LAW

LAW may refer to:* Anti-tank warfare, e.g. the US Army M72 LAW or the British Army LAW 80*Palestinian Society for the Protection of Human Rights ...
 (see e.g., apportionment
Apportionment

The legal term apportionment means distribution or allotment in proper shares.It is a term used in law in a variety of senses. Sometimes it is employed roughly and has no technical meaning; this indicates the distribution of a benefit , or liability , or the incidence of a duty ....
), economics
Economics

File:Ballard Farmers' Market - vegetables.jpgEconomics is the Social sciences that studies the Production theory basics, Distribution , and Consumption of Good and Service ....
, (see e.g., game theory
Game theory

Game theory is a branch of applied mathematics that is used in the social sciences , biology, engineering, political science, international relations, computer science , and philosophy....
) and other areas of the social sciences
Social sciences

The social sciences comprise academic disciplines concerned with the study of the social life of human groups and individuals including anthropology, communication studies, economics, human geography, history, political science, psychology and sociology....
, where proportional
Proportional (fair division)

Proportional division or simple fair division is the original and simplest problem in fair division. Fair division problems are also called cake-cutting problems....
 division and allocation of resources plays a central part of the analysis.

Computational complexity

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 in polynomial time
Polynomial time

In computational complexity theory, polynomial time refers to the computation time of a problem where the run time, , is no greater than a polynomial function of the problem size, n....
 with a form of Gaussian elimination
Gaussian elimination

In linear algebra, Gaussian elimination is an efficient algorithm for solving system of linear equations, finding the Rank of a matrix , and calculating the inverse of an invertible matrix....
, for details see the linear congruence theorem
Linear congruence theorem

In modular arithmetic, the question of when a linear modular arithmetic can be solved is answered by the linear congruence theorem. If a and b are any integers and n is a positive integer, then the congruencehas a solution for x if and only if b is divisible by the greatest common divisor d of a and n ....
.

Solving a system of non-linear modular arithmetic equations is NP-complete
NP-complete

In computational complexity theory, the complexity class NP-complete is a class of problems having two properties:* Any given solution to the problem can be verified quickly ; the set of problems with this property is called NP ....
. For details, see for example M. R. Garey, D. S. Johnson: Computers and Intractability, a Guide to the Theory of NP-Completeness, W. H. Freeman 1979.

See also


External links

  • In this article, one can learn more about applications of modular arithmetic in art.
  • An on modular arithmetic on the GIMPS wiki
  • Automated modular arithmetic theorem provers: