3.3 Congruences

One of the most basic and useful notions in number theory is modular arithmetic, or congruences.

Definition

Let a, b, n be integers with n0. We say that

ab(modn)

(read: a is congruent to b mod n) if ab is a multiple (positive or negative or zero) of n.

Another formulation is that ab(modn) if a and b differ by a multiple of n. This can be rewritten as a=b+nk for some integer k (positive or negative).

Example

327(mod5), 1237(mod7), 1717(mod13).

Note: Many computer programs regard 17(mod10) as equal to the number 7, namely, the remainder obtained when 17 is divided by 10 (often written as 17%10=7). The notion of congruence we use is closely related. We have that two numbers are congruent mod n if they yield the same remainders when divided by n. For example, 1737(mod10) because 17%10 and 37%10 are equal.

Congruence behaves very much like equality. In fact, the notation for congruence was intentionally chosen to resemble the notation for equality.

Proposition

Let a, b, c, n be integers with n0.

  1. a0(modn) if and only if n|a.

  2. aa(modn).

  3. ab(modn) if and only if ba(modn).

  4. If ab and bc(modn),  then ac(modn).

Proof. In (1), a0(modn) means that a=a0 is a multiple of n,  which is the same as n|a. In (2), we have aa=0n,  so aa(modn). In (3), if ab(modn),  write ab=nk. Then ba=n(k),  so ba(modn). Reversing the roles of a and b gives the reverse implication. For (4), write a=b+nk and b=c+n. Then ac=n(k+),  so ac(modn).

Usually, we have n>0 and we work with the integers mod n,  denoted Zn. These may be regarded as the set {0, 1, 2, , n1},  with addition, subtraction, and multiplication mod n. If a is any integer, we may divide a by n and obtain a remainder in this set:

a=nq+r with 0r<n.

(This is just division with remainder; q is the quotient and r is the remainder.) Then ar(modn),  so every number a is congruent mod n to some integer r with 0r<n.

Proposition

Let a, b, c, d, n be integers with n0,  and suppose ab(modn) and cd(modn). Then

a+cb+d, acbd, acbd(modn).

Proof. Write a=b+nk and c=d+n,  for integers k and . Then a+c=b+d+n(k+),  so a+cb+d(modn). The proof that acbd is similar. For multiplication, we have ac=bd+n(dk+b+nk),  so acbd.

The proposition says you can perform the usual arithmetic operations of addition, subtraction, and multiplication with congruences. You must be careful, however, when trying to perform division, as we’ll see.

If we take two numbers and want to multiply them modulo n,  we start by multiplying them as integers. If the product is less than n,  we stop. If the product is larger than n1,  we divide by n and take the remainder. Addition and subtraction are done similarly. For example, the integers modulo 6 have the following addition table:

A table shows 6 rows and 6 columns for addition mod 6.

A table for multiplication mod 6 is

A table shows 6 rows and 6 columns for multiplication mod 6.

Example

Here is an example of how we can do algebra mod n. Consider the following problem: Solve x+73(mod17).

SOLUTION

x37413(mod17).

There is nothing wrong with negative answers, but usually we write the final answer as an integer from 0 to n1 when we are working mod n.

3.3.1 Division

Division is much trickier mod n than it is with rational numbers. The general rule is that you can divide by a(modn) when gcd(a, n)=1.

Proposition

Let a, b, c, n be integers with n0 and with gcd(a, n)=1. If abac(modn),  then bc(modn). In other words, if a and n are relatively prime, we can divide both sides of the congruence by a.

Proof Since gcd(a, n)=1,  there exist integers x, y such that ax+ny=1. Multiply by bc to obtain

(abac)x+n(bc)y=bc.

Since abac is a multiple of n,  by assumption, and n(bc)y is also a multiple of n,  we find that bc is a multiple of n. This means that bc(modn).

Example

Solve: 2x+73(mod17).

SOLUTION

2x374,  so x215(mod17). The division by 2 is allowed since gcd(2, 17)=1.

Example

Solve: 5x+613(mod11).

SOLUTION

5x7(mod11). Now what do we do? We want to divide by 5, but what does 7/5 mean mod 11? Note that 7182940(mod11). So 5x7 is the same as 5x40. Now we can divide by 5 and obtain x8(mod11) as the answer. Note that 785(mod11),  so 8 acts like 7/5.

The last example can be done another way. Since 591(mod11),  we see that 9 is the multiplicative inverse of 5(mod11). Therefore, dividing by 5 can be accomplished by multiplying by 9. If we want to solve 5x7(mod11),  we multiply both sides by 9 and obtain

x45x638(mod11).

Proposition

Suppose gcd(a, n)=1. Let s and t be integers such that as+nt=1 (they can be found using the extended Euclidean algorithm). Then as1(modn),  so s is the multiplicative inverse for a(modn).

Proof. Since as1=nt,  we see that as1 is a multiple of n.

Notation: We let a1 denote this s,  so a1 satisfies a1a1(modn).

The extended Euclidean algorithm is fairly efficient for computing the multiplicative inverse of a by the method stated in the proposition.

Example

Solve 11111x4(mod12345).

SOLUTION

In Section 3.2, from the calculation of gcd(12345, 11111) we obtained

1=12345(2224)+111112471.

This says that

1111124711(mod12345).

Multiplying both sides of the original congruence by 2471 yields

x9884(mod12345).

In practice, this means that if we are working mod 12345 and we encounter the fraction 4/11111, we can replace it with 9884. This might seem a little strange, but think about what 4/11111 means. It’s simply a symbol to represent a quantity that, when multiplied by 11111, yields 4. When we are working mod 12345, the number 9884 also has this property since 11111×98844(mod12345).

Let’s summarize some of the discussion:

Finding

a1(modn)
  1. Use the extended Euclidean algorithm to find integers s and t such that as+nt=1.

  2. a1s(modn).

Solving

axc(modn) when gcd(a, n)=1

(Equivalently, you could be working mod n and encounter a fraction c/a with gcd(a, n)=1.)

  1. Use the extended Euclidean algorithm to find integers s and t such that as+nt=1.

  2. The solution is xcs(modn) (equivalently, replace the fraction c/a with cs(modn)).

What if

gcd(a, n)>1?

Occasionally we will need to solve congruences of the form axb(modn) when gcd(a, n)=d>1. The procedure is as follows:

  1. If d does not divide b,  there is no solution.

  2. Assume d|b. Consider the new congruence

    (a/d)xb/d(modn/d).

    Note that a/d, b/d, n/d are integers and gcd(a/d, n/d)=1. Solve this congruence by the above procedure to obtain a solution x0.

  3. The solutions of the original congruence axb(modn) are

    x0, x0+(n/d), x0+2(n/d), , x0+(d1)(n/d)(modn).

Example

Solve 12x21(mod39).

SOLUTION

gcd(12, 39)=3,  which divides 21. Divide by 3 to obtain the new congruence 4x7(mod13). A solution x0=5 can be obtained by trying a few numbers, or by using the extended Euclidean algorithm. The solutions to the original congruence are x5, 18, 31(mod39).

The preceding congruences contained x to the first power. However, nonlinear congruences are also useful. In several places in this book, we will meet equations of the form

x2a(modn).

First, consider x21(mod7). The solutions are x1, 6(mod7),  as we can see by trying the values 0, 1, 2, , 6 for x. In general, when p is an odd prime, x21(modp) has exactly the two solutions x±1(modp) (see Exercise 15).

Now consider x21(mod15). If we try the numbers 0, 1, 2, , 14 for x,  we find that x=1, 4, 11, 14 are solutions. For example, 1121211(mod15). Therefore, a quadratic congruence for a composite modulus can have more than two solutions, in contrast to the fact that a quadratic equation with real numbers, for example, can have at most two solutions. In Section 3.4, we’ll discuss this phenomenon. In Chapters 9 (factoring), 18 (flipping coins), and 19 (identification schemes), we’ll meet applications of this fact.

3.3.2 Working with Fractions

In many situations, it will be convenient to work with fractions mod n. For example, 1/2(mod12345) is easier to write than 6173(mod12345) (note that 2×61731(mod12345)). The general rule is that a fraction b/a can be used mod n if gcd(a, n)=1. Of course, it should be remembered that b/a(modn) really means a1b(modn),  where a1 denotes the integer mod n that satisfies a1a1(modn). But nothing will go wrong if it is treated as a fraction.

Another way to look at this is the following. The symbol “1/2” is simply a symbol with exactly one property: If you multiply 1/2 by 2, you get 1. In all calculations involving the symbol 1/2, this is the only property that is used. When we are working mod 12345, the number 6173 also has this property, since 6173×21(mod12345). Therefore, 1/2(mod12345) and 6173(mod12345) may be used interchangeably.

Why can’t we use fractions with arbitrary denominators? Of course, we cannot use 1/6(mod6),  since that would mean dividing by 0(mod6). But even if we try to work with 1/2(mod6),  we run into trouble. For example, 28(mod6),  but we cannot multiply both sides by 1/2, since 14(mod6). The problem is that gcd(2, 6)=21. Since 2 is a factor of 6, we can think of dividing by 2 as “partially dividing by 0.” In any case, it is not allowed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset