Difference between revisions of "Modular arithmetic/Intermediate"
(beginning a stub) |
(moving info from modular arithmetic article) |
||
Line 18: | Line 18: | ||
For examples, see [[Introduction to modular arithmetic]]. | For examples, see [[Introduction to modular arithmetic]]. | ||
+ | |||
+ | |||
+ | |||
+ | == Algebraic Properties of the Integers Mod n == | ||
+ | |||
+ | The integers modulo <math>n</math> form an algebraic structure called a [[ring]] -- a structure in which we can add, subtract, and multiply elements. | ||
+ | |||
+ | Anyone who has taken a high school algebra class is familiar with several examples of rings, including the ring of integers, the ring of rational numbers, and the ring of real numbers. The ring <math>\mathbb{Z}_n</math> has some algebraic features that make it quite different from the more familiar rings listed above. | ||
+ | |||
+ | First of all, notice that if we choose a nonzero element <math>\overline{a}</math> of <math>\mathbb{Z}_n</math>, and add <math>n</math> copies of this element, we get | ||
+ | |||
+ | <math>\overline{a} + \overline{a} + \cdots + \overline{a} = n \cdot \overline{a} = \overline{na} = \overline{0}</math>, | ||
+ | |||
+ | since <math>na</math> is a multiple of <math>n</math>. So it is possible to add several copies of a nonzero element of <math>\mathbb{Z}_n</math> and get zero. This phenomenon, which is called '''torsion''', does not occur in the reals, the rationals, or the integers. | ||
+ | |||
+ | Another curious feature of <math>\mathbb{Z}_n</math> is that a polynomial over <math>\mathbb{Z}_n</math> can have a number of roots greater than its degree. Consider, for example, the polynomial congruence | ||
+ | |||
+ | <math>x^2 - 2x - 15 \equiv 0 \pmod{21}</math>. | ||
+ | |||
+ | We might be tempted to solve this congruence by factoring the expression on the left: | ||
+ | |||
+ | <math>(x - 5)(x + 3) \equiv 0 \pmod{21}</math>. | ||
+ | |||
+ | Indeed, this factorization yields two solutions to the congruence: <math>x \equiv 5 \pmod{21}</math>, and <math>x \equiv -3 \equiv 18 \pmod{21}</math>. (Note that two values of <math>x</math> that are congruent modulo <math>21</math> are considered the same solution.) | ||
+ | |||
+ | However, since <math>15 \equiv 99 \pmod{21}</math>, the original congruence is equivalent to | ||
+ | |||
+ | <math>x^2 - 2x - 99 \equiv 0 \pmod{21}</math>. | ||
+ | |||
+ | This time, factoring the expression on the left yields | ||
+ | |||
+ | <math>(x - 11)(x + 9) \equiv 0 \pmod{21}</math>. | ||
+ | |||
+ | And we find that there are two more solutions! The values <math>x \equiv 11 \pmod{21}</math> and <math>x \equiv -9 \equiv 12 \pmod{21}</math> both solve the congruence. So our congruence has at least four solutions -- two more than we might expect based on the degree of the polynomial. | ||
+ | |||
+ | Why do the "rules" of algebra that work so well for the real numbers seem to fail in <math>\mathbb{Z}_{21}</math>? To understand this, let's take a closer look at the congruence | ||
+ | |||
+ | <math>(x - 5)(x + 3) \equiv 0 \pmod{21}</math>. | ||
+ | |||
+ | If we were solving this as an equation over the reals, we would immediately conclude that either <math>x - 5</math> must be zero, or <math>x + 3</math> must be zero in order for the product to equal zero. However, this is not the case in <math>\mathbb{Z}_{21}</math>! It is possible to multiply two nonzero elements of <math>\mathbb{Z}_{21}</math> and get zero. For example, we have | ||
+ | |||
+ | <math>\overline{3} \cdot \overline{7} = \overline{0}</math> | ||
+ | |||
+ | <math>\overline{9} \cdot \overline{7} = \overline{0}</math> | ||
+ | |||
+ | <math>\overline{6} \cdot \overline{14} = \overline{0}</math> | ||
+ | |||
+ | But wait! Suppose we take a close look at this last product, and we set <math>x - 5 \equiv 6 \pmod{21}</math> and <math>x + 3 \equiv 14 \pmod{21}</math>. Then we have <math>x \equiv 11 \pmod{21}</math> -- another of the solutions of our congruence! (One can check that the other two factorizations don't lead to any valid solutions; however, there are many other factorizations of zero that need to be checked.) | ||
+ | |||
+ | In the ring of real numbers, it is a well-known fact that if <math>ab = 0</math>, then <math>a = 0</math> or <math>b = 0</math>. For this reason, we call the ring of real numbers a '''domain'''. However, a similar fact does ''not'' apply in general in <math>\mathbb{Z}_n</math>; therefore, <math>\mathbb{Z}_n</math> is not in general a domain. | ||
+ | |||
+ | |||
+ | |||
+ | == Topics == | ||
+ | The following topics expand on the flexible nature of modular arithmetic as a problem solving tool: | ||
+ | * [[Fermat's Little Theorem]] | ||
+ | * [[Euler's Totient Theorem]] | ||
+ | * [[Phi function]] | ||
Revision as of 17:22, 28 June 2006
Given integers ,
, and
, with
, we say that
is congruent to
modulo
, or
(mod
), if the difference
is divisible by
.
For a given positive integer , the relation
(mod
) is an equivalence relation on the set of integers. This relation gives rise to an algebraic structure called the integers modulo
(usually known as "the integers mod
," or
for short). This structure gives us a useful tool for solving a wide range of number-theoretic problems, including finding solutions to Diophantine equations, testing whether certain large numbers are prime, and even some problems in cryptology.
Contents
Arithmetic Modulo n
Useful Facts
Consider four integers and a positive integer
such that
and
. In modular arithmetic, the following identities hold:
- Addition:
.
- Subtraction:
.
- Multiplication:
.
- Division:
, where
is a positive integer that divides
and
.
- Exponentiation:
where
is a positive integer.
For examples, see Introduction to modular arithmetic.
Algebraic Properties of the Integers Mod n
The integers modulo form an algebraic structure called a ring -- a structure in which we can add, subtract, and multiply elements.
Anyone who has taken a high school algebra class is familiar with several examples of rings, including the ring of integers, the ring of rational numbers, and the ring of real numbers. The ring has some algebraic features that make it quite different from the more familiar rings listed above.
First of all, notice that if we choose a nonzero element of
, and add
copies of this element, we get
,
since is a multiple of
. So it is possible to add several copies of a nonzero element of
and get zero. This phenomenon, which is called torsion, does not occur in the reals, the rationals, or the integers.
Another curious feature of is that a polynomial over
can have a number of roots greater than its degree. Consider, for example, the polynomial congruence
.
We might be tempted to solve this congruence by factoring the expression on the left:
.
Indeed, this factorization yields two solutions to the congruence: , and
. (Note that two values of
that are congruent modulo
are considered the same solution.)
However, since , the original congruence is equivalent to
.
This time, factoring the expression on the left yields
.
And we find that there are two more solutions! The values and
both solve the congruence. So our congruence has at least four solutions -- two more than we might expect based on the degree of the polynomial.
Why do the "rules" of algebra that work so well for the real numbers seem to fail in ? To understand this, let's take a closer look at the congruence
.
If we were solving this as an equation over the reals, we would immediately conclude that either must be zero, or
must be zero in order for the product to equal zero. However, this is not the case in
! It is possible to multiply two nonzero elements of
and get zero. For example, we have
But wait! Suppose we take a close look at this last product, and we set and
. Then we have
-- another of the solutions of our congruence! (One can check that the other two factorizations don't lead to any valid solutions; however, there are many other factorizations of zero that need to be checked.)
In the ring of real numbers, it is a well-known fact that if , then
or
. For this reason, we call the ring of real numbers a domain. However, a similar fact does not apply in general in
; therefore,
is not in general a domain.
Topics
The following topics expand on the flexible nature of modular arithmetic as a problem solving tool:
Miscellany
The binary operation "mod"
Related to the concept of congruence, mod is the binary operation
mod
, which is used often in computer programming.
Recall that, by the Division Algorithm, given any two integers and
, with
, we can find integers
and
, with
, such that
. The number
is called the quotient, and the number
is called the remainder. The operation
mod
returns the value of the remainder
. For example:
mod
, since
.
mod
, since
.
mod
, since
.
Observe that if mod
, then we also have
(mod
).
An example exercise with modular arithmetic:
Problem:
Let
be a nine-digit positive integer (each digit not necessarily distinct). Consider
,
another nine-digit positive integer with the property that each digit ei when substituted for di makes the modified D divisible by 7. Let
be a third nine-digit positive integer with the same relation to E as E has to D.
Prove that every is divisible by 7.
Solution:
Any positive integer can be expressed
.
Since 10=3 mod 7, and since it holds that if a=b mod c then mod c, then D can be expressed much more simply mod 7; that is,
= x mod 7.
Each number in E must make the modified D equal 0 mod 7, so for each ,
, where c is the coefficient of
and k is an element of {-2,-1,0,1,2}. The patient reader should feel free to verify that this makes D = 0 mod 7.
In terms of terms, then, we find each
.
Then mod 7 can be expressed
mod 7 = (9x)- x = 8x = x mod 7.
(note that the 7s, which do not change the mod value, have been eliminated).
Each number in F must make the modified E equal 0 mod 7, so for each ,
.
By design and selection of k, all are integers, and
is always an integer because it is the difference of two integers.
is a member of the set {1, 2, 3}. Since no
divides 7, 7 may be factored and
is the product of two integers.
Let then
7A mod 7 = 0 mod 7 for all
, QED.