Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Chinese Remainder Theorem. Setting the Scene (the problem) Imagine that you are a commander in the army. You have lost a major battle and are attempting.

Similar presentations


Presentation on theme: "The Chinese Remainder Theorem. Setting the Scene (the problem) Imagine that you are a commander in the army. You have lost a major battle and are attempting."— Presentation transcript:

1 The Chinese Remainder Theorem

2 Setting the Scene (the problem) Imagine that you are a commander in the army. You have lost a major battle and are attempting to regroup. Before you can do this, you must count the survivors. Originally you have 500 soldiers. You are a busy commander though and this process would be too strenuous to attempt by hand.

3 An Attempted Solution Being a wise leader, you realize that you could group the remaining infantry into a nxm matrix. Then, the total solders would just equal n * m. But, annoyingly enough, a large number of solders remain outside your matrix with no place to stand.

4 An Observation No matter what size matrix you have, there seems to be people left over. Although there might be a square solution, finding the correct n and m is difficult.

5 Guessing Not being one to admit defeat, you decide to try different sized groupings anyways: At first, you decide to group the survivors into groups of 3. After dividing the whole of the army, 1 person had no place in a group. Then, you decide that groups of 7. Once this was done, 3 people had been left out. In desperation, you decide to group the army into groups of 11. This left 2 people over.

6 Another Observation After thinking for awhile, you realize that the total number of solders is going to be some x such that: x = 1 (mod 3) x = 3 (mod 7) x = 2 (mod 11) Invigorated by these equations, but frustrated with no solution, you seek advice.

7 Advice Your advisors remind you of the Chinese Remainder Theorem: If m 1, m 2,... m k are positive integers with a greatest common divisor of one, then this system: x = a 1 (mod m 1 ) x = a 2 (mod m 2 ) … x = a k (mod m k ) Is solved by the modulo m = m 1 * m 2 *... * m k

8 Proof Unconvinced you demand an example of this theorem. It is presented as follows: with our numbers: x = 1 (mod 3) x = 3 (mod 7) x = 2 (mod 11) Now take M k, with m divided by m k for each k = 1, 2,... N What? The top aid explains slowly… Simply multiply all m except for m k to find M k. Using our numbers: M 1 = 7 * 11 = 77 M 2 = 3 * 11 = 33 M 3 = 3 * 7 = 21

9 Furthermore Next, we have to find the solutions x k for each of the equations M k * x k = 1 (mod m k ). M 1 = 7 * 11 = 77 M 2 = 3 * 11 = 33 M 3 = 3 * 7 = 21 x = 1 (mod 3) x = 3 (mod 7) x = 2 (mod 11) For our problem, this is: 77 * x 1 = 2 * x 1 = 1 (mod 3) -> 77 mod 3 = 2 33 * x 2 = 5 * x 2 = 1 (mod 7) -> 33 mod 7 = 5 21 * x 3 = 10 * x 3 = 1 (mod 11) -> 21 mod 11 = 10 So, we have x 1 = 2 x 2 = 3 x 3 = 10

10 Almost there… s = a 1 * M 1 * x 1 + a 2 * M 2 * x 2 +...+ a r * M r * x r s = 1 * 77 * 2 + 1 * 33 * 3 + 1 * 21 * 10 s = 463 = x (mod 231)

11 Solution Taking s = 463 = x (mod 231) Originally have 500 soldiers Solving for x: x = 463 mod 231 = 1 so: s = 1 (mod 231) s = 231*k + 1 k = 0 -> 1 soldier left k = 1 -> 232 soldiers left k = 2 -> 694 soldiers left (too large) We know now that we either have 1 or 232 soldiers left. Close enough to easily guess. Good news is that we have 232 soldiers.

12 Homework I mailed 200 invitations to this rave. I danced in every song… We did a dance where we paired off into groups of 5, but one group only had 4… Then, we had a line dance with 9 to a line, but three lines ended up with 10… At the end of the evening, everyone left in pairs, except for me… How many people (including me) attended the event (assuming no uninvited guests showed up)?


Download ppt "The Chinese Remainder Theorem. Setting the Scene (the problem) Imagine that you are a commander in the army. You have lost a major battle and are attempting."

Similar presentations


Ads by Google