Sie sind auf Seite 1von 15

Sample draft: Do not cite or quote The Chinese Remainder Theorem Page 96

8
8.1

The Chinese Remainder Theorem

Introduction
After making exciting discoveries and even building new structures (the nite rings Z/nZ), here is a version of an age-old problem that we explore in this chapter: (from Chin Chiu-shao, Mathematical Treatise in Nine Sections, 1247) [5, 7] Three farmers equally divide the rice that they have grown. One goes to a market where an 83-pound weight is used, another to a market that uses a 112-pound weight, and the third to a market using a 135-pound weight. Each farmer sells as many full measures as possible, and when the three return home, the rst has 32 pounds of rice left, the second 70 pounds, and the third 30 pounds. Find the total amount of rice they took to market. The rst job we assign ourselves is to write the equations and stare them down; let the amount of rice (in pounds) be 3x, with x the part that each farmer takes to market. Then, if the rst farmer sells her x pounds in 83-pound batches and has 32 pounds left, we get x = 83n + 32 for some integer n. Thats the same as saying that x 32 (mod 83). So too with the other two farmers. Hence we can model the situation in the problem by three congruences: x 32 x 70 x 30 (mod 83) (mod 112) (mod 135)
Seeing the Connections

At rst sight, we are back to square 1: algebra as a means of solving strange word problems. (Find Johns age if hes 3 years older than Mary, if shes 5 times Elizabeths age, if . . . ). But be patient; things will pick up shortly.

These are not quite the numbers that are in the original source. We doctored them a bit to simplify things. More about this in a bit.

Boston University/Education Development Center, Inc. 2004

Sample draft: Do not cite or quote Solution 1: Just Do It Page 97

Its easy to classify the x that work for each one of these, but we are looking for a simultaneous solution to all three. 1. 2. 3. Classify all x that satisfy the three congruences above, using any method you want. Come up with some other problems that require a common solution to a set of congruences modulo dierent integers. Classify all x that satisfy x 3 x 7 x 2 (mod 5) (mod 11) (mod 10)
It even takes some luck to get integers (x, n) to satisfy the equation x n 83 = 32; in fact, it takes a line x + 83y = 32 with a good aim for lattice points! See problem 24 on page 60.

The Chinese Remainder Theorem (CRT from now on) provides a complete answer to the problem of nding a simultaneous solution to a set of congruences of the kind in Chin Chiushaos problem. More precisely, given a system of congruences x b1 (mod m1 ) x b2 (mod m2 ) . . . . . . x br (mod mr ), CRT tells you when the system will have a solution, and if it does have a solution, it will provide an algorithm for nding one and for classifying them all. And, like most beautiful results, CRT generalizes to other algebraic structures. Its statement, proof, and algorithm will work, for example, in R[x], the ring of polynomials in one variable with real coecients. In its most general formulation (see [6], for example), CRT is a result about some crucial structural properties of very abstract algebraic systems. Well provide a taste of this generality in later sections. For now, lets look at two solutions to Chin Chiu-shaos problem.
You cant ask for more than that. When cast as a theorem about polynomials, CRT can be used to nd a polynomial function of least degree that agrees with an input-output table. More about that later. Applications of CRT range from parallel computing to cryptology.

8.2

Solution 1: Just Do It
Lets rst approach the problem in the usual, no-nonsense way that we solve a system of equations, by eliminating from the rst

Boston University/Education Development Center, Inc. 2004

Seeing the Connections

Sample draft: Do not cite or quote Solution 1: Just Do It Page 98

equation, plugging into an x such that x x x So, we write

the next, and so on. We are looking for 32 70 30 (mod 83) (mod 112) (mod 135)

x = 83n + 32 and plug in the second equation 83n + 32 = 112m + 70 So, we are looking for integer solutions to 83n 112m = 38. This is exactly the kind of problem we solved in problems 1618 on page 59. Since the gcd of 83 and 112 is 1, we know that we can nd r and s so that 83r + 112s = 1 In fact, working Euclids algorithm backwards, we nd that 83 27 + 112 20 = 1 Multiplying by 38, we have 83 27 38 + 112 20 38 = 38 And by problem 17 on page 59, every solution to 83n + 32 = 112m + 70 is of the form n = 27 38 112a, m = 20 38 + 83a (any integer a will do). So, a general form of x is x = 83(27 38 112a) + 32 = 85190 9296a Now plug in the third equation: 85190 9296a 30 or a 9296 + b 135 = 85160
Boston University/Education Development Center, Inc. 2004 Seeing the Connections

or 83 1026 + 112 760 = 38

Its a good idea to check that this solves the rst two equations.

(mod 135)

Sample draft: Do not cite or quote Solution 1: Just Do It Page 99

Since gcd(9296, 135) = 1, we can solve this by the same method we used to solve the previous equation (backing up Euclids algorithm). Since 64 9296 + 4407 135 = 1, a particular solution to a 9296 + b 135 = 85160 is a = 64 85160 = 5450240, b = 4407 85160 = 375300120 So, we can take for x x = 85190 9296 5450240 = 50665516230 That could be how many pounds of rice each farmer took to market 4. 5. Check that 50665516230 satises the conditions of Chin Chiu-shaos problem. This answer, 50665516230, is way too big. How high would a cylindrical silo need to be to contain 50665516230 pounds of rice if it were 100 feet in diameter? Assume rice weighs 5 pounds per cubic foot. Show that if we have two solutions to Chin Chiu-shaos problem, x and x : x 32 x 70 x 30 then xx 7. 8. (mod 83 112 135) Use the result of problem 6 to nd the smallest amount of rice the farmers could have brought to market. Prove, Disprove, and Salvage if Possible. Suppose we have two solutions, x and x , to a set of simultaneous set of congruences x b1 x b2 . . . x br (mod m1 ) (mod m2 ) . . . (mod mr ) x x . . . x b1 b2 br (mod m1 ) (mod m2 ) . . . (mod mr )
Seeing the Connections

6.

(mod 83) (mod 112) (mod 135)

x x x

32 70 30

(mod 83) (mod 112) (mod 135)


Hint: Check put problem 64 on page 68.

Boston University/Education Development Center, Inc. 2004

Sample draft: Do not cite or quote Solution 2: Use the structure of Z/nZ Page 100

Then xx (mod m1 m2 . . . mr )

8.3

Solution 2: Use the structure of

Z/nZ

The next solution uses a method that has quite a few applications in algebra. The idea is to localize our problem of nding an x such that x 32 (mod 83) x 70 (mod 112) x 30 (mod 135) Localize in this case means concentrating on one modulus at a time, nding a way to ignore the other two. in other words, suppose we could nd an integer r so that: r 32 (mod 83) r 0 (mod 112) r 0 (mod 135) And, while we are engaging in wishful thinking, suppose we could nd integers s and t so that s 0 (mod 83) s 70 (mod 112) s 0 (mod 135) t 0 (mod 83) t 0 (mod 112) t 30 (mod 135)

Ignore often means make zero.

Well, then we could take x to be r + s + t. Why? Well, because of the reduce as you go idea described on page 35, you can nd the remainder when r + s + t is divided by, say, 83, by nding the remainders when r, s, and t are divided by 83 and adding the answers. 9. Show that if r, s, and t have the properties described above, then r + s + t satises Chin Chiu-shaos congruences. r 32 (mod 83) r 0 (mod 112) r 0 (mod 135) are equivalent to r 32 (mod 83) r 0 (mod 112 135)
Boston University/Education Development Center, Inc. 2004 Seeing the Connections

10. Show that the congruences


Equivalent means have the same solutions.

Sample draft: Do not cite or quote Solution 2: Use the structure of Z/nZ Page 101

So, how do you nd such r, s, and t? Well, look at what we want r to do: r 32 (mod 83) r 0 (mod 112) r 0 (mod 135) Its easy to make r equal to 0 modulo 112 and 135: Just make it a multiple of 112 135. So, we want r to look like: r = some integer 112 135 And we choose some integer to meet the local condition that r wants to be 32 modulo 83; we want some integer112135 = some integer15120 some integer14 32 Now (and this is an important step), since 112 and 135 are relatively prime to 83, so is their product. Hence 14 (which is the same as 112 135 modulo 83) is also relatively prime to 83. So, it has an inverse in Z/83Z (see problem 22 on page 60 for example). That means we can solve for the some integer: Where 141 means the reciprocal of 14 in Z/83Z. But we have a method for nding reciprocals (see problem 20 on page 60); that method tells us that 141 = 6 and we can take some integer to be 6 32 = 192 26 (mod 83) So we can take r = 26 112 135 = 393120 11. Use this method to nd solutions to s 0 (mod 83) s 70 (mod 112) s 0 (mod 135) t 0 (mod 83) t 0 (mod 112) t 30 (mod 135)
By the way, the answers are s = 156870 and t = 976080. The problem asks you to work through the method to get these answers.

(mod 83)

See problems 66 and 67 on page 68.

some integer = 141 32

(mod 83)

12. Using r = 393120 and the values for s and t you found in problem 11, show that r + s + t solves Chin Chiu-shaos problem. Is it the smallest solution? 13. Use this localization method to solve the system y y y y 3 (mod 12) 17 (mod 35) 2 (mod 11) 12 (mod 49)

Find the smallest positive solution.


Boston University/Education Development Center, Inc. 2004 Seeing the Connections

Sample draft: Do not cite or quote Solution 2: Use the structure of Z/nZ Page 102

14. What happens if you try to use this method on a system that clearly has no solution, like y 2 (mod 6) y 1 (mod 3) y 2 (mod 11) What goes wrong?

Ways to think about it The localization technique that we used in our most recent solution to Chin Chiu-shaos problem is a method that is general in principle. That is, the argument works with any system of congruences, as long as the moduli are relatively prime. If you work out a few more examples (make up systems of your own), and concentrate on the form of your arguments (making them the same in each case), youll have no trouble proving the following theorem. Theorem 14 Chinese Remainder Theorem: Suppose m1 , m2 , . . . , mr are relatively prime integers. An explicit way of writing a solution to the set of simultaneous congruences x b1 x b2 x b3 . . . . . . x br is x = b1 (n1 )1 n1 + b2 (n2 )1 n2 + b3 (n3 )1 n3 +. . .+ br (nr )1 nr where and (ni )1 is the multiplicative inverse of ni in Z/mi Z. Furthermore, any other solution to this system is congruent to x modulo m1 m2 . . . mr . ni = n1 n2 . . . ni1 ni+1 . . . nr (mod m1 ) (mod m2 ) (mod m3 ) (mod mr )

Boston University/Education Development Center, Inc. 2004

Seeing the Connections

Sample draft: Do not cite or quote Solution 2: Use the structure of Z/nZ Page 103

Write and Reect: 15. In the notation of the theorem, why does ni have a multiplicative inverse in Z/mi Z? 16. Carefully write out a proof to this theorem, generalizing the localization method.

17. If my age is divided by 5, the remainder is 4. If its divided by 3, the remainder is 2. If its divided by 7, the remainder is 5. How old am I? 18. A band of 17 stock brokers stole a sack of hundred dollar bills. When they were divided equally, there were three left over. So, one associate was sent on vacation. Then, when the sack was divided equally, there were 10 bills left. So, another member of the crew was asked to take a break. Now, the bills could be distributed evenly with none left over. How many bills were in the sack? 19. (From Bhaskara I, sixth century; also al-Haitham, eleventh century; Fibonacci, early thirteenth century [5]). If eggs in a basket are taken out 2,3,4,5 and 6 at a time, there are 1,2,3,4, and 5 eggs left over, respectively. If they are taken out 7 at a time, there are no eggs left over. What is the least number of eggs that can be in the basket?
This is a slight modication of an old Chinese problem: replace stockbroker by pirate, bill by gold coin, and asked to go on vacation by killed.

What if the moduli are not relatively prime? Sometimes you can solve the system and sometimes you cant. Heres the whole story: Theorem 15 The system of congruences x x . . . a1 a2 . . . (mod m1 ) (mod m2 ) (mod mr )

x ar

Boston University/Education Development Center, Inc. 2004

Seeing the Connections

Sample draft: Do not cite or quote Solution 2: Use the structure of Z/nZ Page 104

has a solution if and only if gcd(mi , mj ) | (ai aj ) for all pairs of integers (i, j) where 1 i, j r, and if a solution exists, then it is unique modulo lcm(m1 , m2 , . . . , mr ).

Boston University/Education Development Center, Inc. 2004

Seeing the Connections

Sample draft: Do not cite or quote Fitting polynomials to data Page 105

FOR DISCUSSION 1. Prove Theorem 15. 2. Can you modify the algorithm given in Theorem14 to produce a solution to the system in this more general version of the CRT?

20. Chiu-shaos actual problem is this: Three farmers equally divide the rice that they have grown. One goes to a market where an 83pound weight is used, another to a market that uses a 110-pound weight, and the third to a market using a 135-pound weight. Each farmer sells as many full measures as possible, and when the three return home, the rst has 32 pounds of rice left, the second 70 pounds, and the third 30 pounds. Find the total amount of rice they took to market. (a) Why did we not use these numbers originally? (b) Solve this version of the problem

8.4

Fitting polynomials to data


Suppose we have this table: Input Output 0 5 1 6 2 7 3 166 4 843 5 2770 Heres a method, called Lagrange Interpolation, for nding a polynomial (of lowest degree, it turns out) that agrees with the table: We start with the following beast of an expression for our
Does this seem like something completely dierent? Patience.

You may want to use a CAS in what follows. Does this feel familiar? Like localization?

Boston University/Education Development Center, Inc. 2004

Seeing the Connections

Sample draft: Do not cite or quote Fitting polynomials to data Page 106

solution f as a sum of products: f (x) = Ax(x 1)(x 2)(x 3)(x 4) + Bx(x 1)(x 2)(x 3)(x 5) +Cx(x 1)(x 2)(x 4)(x 5) + Dx(x 1)(x 3)(x 4)(x 5) +Ex(x 2)(x 3)(x 4)(x 5) + F (x 1)(x 2)(x 3)(x 4)(x 5) () The numbers AF will be determined in a minute. Each product is formed by taking x(x 1)(x 2)(x 3)(x 4)(x 5) and dropping one factor. So, each product is a polynomial of degree 5, and that ensures that the whole expression will be of degree at most 5. Why write f in such a messy way? Well, it allows you to easily calculate f (n) for any n between 0 and 5. For example, from the table, we want f (0) to be 5. So, we calculate like this: 5 = A0(0 1)(0 2)(0 3)(0 4) + B0(0 1)(0 2)(0 3)(0 5) +C0(0 1)(0 2)(0 4)(0 5) + D0(0 1)(0 3)(0 4)(0 5) +E0(0 2)(0 3)(0 4)(0 5) + F (0 1)(0 2)(0 3)(0 4)(0 5) But look: all the terms except the last have a factor of 0, so they all vanish. We get 5 = F (0 1)(0 2)(0 3)(0 4)(0 5) = 120F So, F =
5 120

1 . 24

Next, let x = 1. We want f (1) to be 6. But when we replace x by 1 in expression (), the only term to survive is the E term, and we get: 6 = E(1 0)(1 2)(1 3)(1 4)(1 5) = 24E So E = 1 . 4 Similarly, we can pick o the other missing coecients by re7 placing x by 2 (producing D = 12 ), 3 (producing C = 83 ), 4 6 843 (producing B = 24 ), and 5 (producing A = 277 ). So, substi12 tuting in (), we get: f (x) =
277 x(x 1)(x 2)(x 3)(x 4) 843 x(x 1)(x 2)(x 3)(x 5) 12 24 7 + 83 x(x 1)(x 2)(x 4)(x 5) 12 x(x 1)(x 3)(x 4)(x 5) 6 1 1 4 x(x 2)(x 3)(x 4)(x 5) + 24 (x 1)(x 2)(x 3)(x 4)(x
Seeing the Connections

5)

Boston University/Education Development Center, Inc. 2004

Sample draft: Do not cite or quote Fitting polynomials to data Page 107

A CAS simplies this to x5 3x3 + x2 5. Try it for yourself. Lagrange Interpolation applies to any nite set of input-output pairs, not just consecutive integers starting at 0. It can be stated like this: Theorem 16 Lagrange Interpolation: An explicit way of writing the polynomial in x of minimal degree which takes the values bi at the points ai , 1 i r is f (x) = b2 b3 br b1 p1 (x)+ p2 (x)+ p3 (x)+. . .+ pr (x) p1 (a1 ) p2 (a2 ) p3 (a3 ) pr (ar )
In the example above, if g were any polynomial of degree less than f that agreed with f at the six inputs in the table, f g would be a polynomial of degree at most 5 with six roots, so it would be 0.

where pi (x) is the polynomial dened by pi (x) = (x a1 )(x a2 ) (x ai1 )(x ai+1 ) (x ar ) The proof, except for the minimal degree part, is implicit in the example that opened this section, and the fact that f is of minimal degree follows from classical advanced high school algebra. Lets look at what we have done in a slightly more abstract way: In general, were looking for a polynomial f so that f (a1 ) = b1 f (a2 ) = b2 . . . . . . f (ar ) = br By the remainder theorem, another way to say this is that we want f to satisfy f (x) = (x a1 )q1 (x) + b1 f (x) = (x a2 )q2 (x) + b2 . . . . . . f (x) = (x ar )qr (x) + br where qi is the quotient you get when f (x) is divided by (xai ). Put another way, we want f to satisfy the congruences: f (x) b1 f (x) b2 . . . . . . f (x) br (mod (x a1 )) (mod (x a2 )) (mod (x ar ))
Seeing the Connections

Boston University/Education Development Center, Inc. 2004

Sample draft: Do not cite or quote Fitting polynomials to data Page 108

So, we are looking for a polynomial that simultaneously leaves r prescribed remainders modulo r dierent polynomials of the form x a. In other words, were trying to nd a simultaneous solution to a set of congruences . Because all the machinery in Z transports to R[x], we not only have a CRT in R[x], but the same method (localization) provides an algorithm for nding a solution. The fact that the same method works comes from deep structural similarities between the ordinary integers and the system of polynomials in one variable with, say, real coecients. Both of these systems are Euclidean rings; they have a long division algorithm, and you can use Euclids algorithm to calculate the gcd of two elements (integers or polynomials). Students practice the features of this structural similarity throughout their K12 experience. In elementary school, they factor integers into primes, divide with remainder, and nd gcds and lcms. They do similar things in high school algebra, except they do them with polynomials instead of with integers. 21. Use the proof of the Chinese Remainder Theorem, transported to R[x], to nd a polynomial that agrees with this table: Input Output 0 5 1 6 2 7 3 166 4 843 5 2770

If a = b, x a and x b are relatively prime in R[x]. Why?

They have very similar structures, but they are dierent. For example, in Z, there are only two units, but in R[x], any polynomial of degree 0 (that is, any non-zero real number) is a unit. So, the reciprocal of 3 is 1 in R[x], but 3 3 has no reciprocal in Z. Why do polynomials of degree greater than 0 (like x + 1) have no reciprocals in R[x]?

22. Show that, if a R, x a is prime in

R[x].

1 23. Show that, in the statement of Theorem 16, the pi (ai ) parts bi of the pi (ai ) are just the multiplicative inverses of pi (x) modulo x ai .

Well return to the CRT and look at its use in determining the periods for decimal expansions in section 10.2

Boston University/Education Development Center, Inc. 2004

Seeing the Connections

Sample draft: Do not cite or quote An application Page 109

8.5

An application
Weve already seen how the CRT, when cast as a statement about polynomials, can be used to t a polynomial to a set of data. Heres an application of the CRT right in Z. Imagine how useful it is to recover an awfully large number from a bunch of small numbers, namely its remainders modulo m1 , . . . , mr . In case you are not interested in the number of eggs in a basket, or pounds of rice, or even troops reckoned by Chinese generals, keep in mind that the method is used in parallel computing. Following [7], computers have a word size; suppose that a computer has word size 100 but we need to perform arithmetic on integers as large as 106 . For example: add x = 123, 684 and y = 413, 456. First we secure relatively prime integers m1 , . . . , mr less than 100 and with product larger than 106 . That way, any integer N < 106 is known as soon as its remainders mod m1 , . . . , mr are known, by the CRT. We can pick m1 = 99, m2 = 98, m3 = 97, m4 = 95. Why? The larger we pick them, the fewer we need to achieve the condition m1 . . . mr > 106 , which is convenient! Well, a pocket calculator shows that: x 33 (mod 99) x 8 (mod 98) x 9 (mod 97) x 89 (mod 95) so that x+y x+y x+y x+y 65 2 51 10 y y y y 32 92 42 16 (mod (mod (mod (mod 99) 98) 97) 95)

Note: x + y is still < 106 .

The numbers used in practice are much bigger. Here, we go through the argument with smaller numbers for the sake of example.

(mod 99) (mod 98) (mod 97) (mod 95)

We now use the Chinese Remainder Theorem to nd x + y modulo 99 98 97 95. 24. Use the CRT to show that x + y 65 903, 070 37 + 2 912, 285 33 + 51 921, 690 24 + 10 941, 094 4 = 3, 397, 886, 480 537, 140 (mod 89, 403, 930)

Boston University/Education Development Center, Inc. 2004

Seeing the Connections

Sample draft: Do not cite or quote An application Page 110

Since 0 < x + y < 89, 403, 930, we conclude that x + y = 537, 140. In real real life, most computers have word size a power of 2, frequently 235 . In the exercises you will nd a nice trick to pick m1 , . . . , mr conveniently so as to ease operation. 25. (Taken from [7].) Multiply 784 and 813 on a computer of size 100 using the Chinese Remainder Theorem. Hint: Let x = 784 and y = 813. We choose m1 = 95, m2 = 97. and m3 = 99 for our moduli. This leads to the systems x 24 (mod 95) x 8 (mod 97) x 91 (mod 99) y 53 y 37 y 21 (mod 95) (mod 97) (mod 99)

Using the Chinese remainder theorem to solve the systems x + y 24 + 53 77 (mod 95) x + y 8 + 37 45 (mod 97) x + y 91 + 21 13 (mod 99) xy 24 53 37 (mod 95) xy 8 37 5 (mod 97) xy 91 21 30 (mod 99)

yields x + y = 1597 and xy = 637392 respectively. 26. Show that if a and b are positive integers, then the least positive residue of 2a 1 modulo 2b 1 is 2r 1, where r is the least positive residue of a modulo b. Hint: Use the formula 2a 1 = 2bq+r 1 = (2b 1)(2b(q1)+r +. . .+2b+r +2r )+(2r 1) 27. If a and b are positive integers, then the greatest common divisor of 2a 1 and 2b 1 is 2gcd(a,b) 1. In particular, 2a 1 and 2b 1 are relatively prime if and only if a and b are relatively prime. Note the same statement is true for any positive integer t replacing 2. 28. Show that to do arithmetic with integers as large as 2184 on a computer of word size 235 , we may pick m1 = 235 1, m2 = 234 1, m3 = 233 1, m4 = 231 1, m5 = 229 1, and m6 = 223 1, and use the CRT. 29. Find the reciprocal of x2 + 1 modulo x 1. Can you nd the reciprocal of x2 2x + 1 modulo (x 1)?

Boston University/Education Development Center, Inc. 2004

Seeing the Connections

Das könnte Ihnen auch gefallen