Chinese Remainder Theorem - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Chinese Remainder Theorem

Description:

How to construct the solution (mod M): Step 2: For each of the equations x = ak (mod mk) ... How to construct the solution (mod M) ... – PowerPoint PPT presentation

Number of Views:5581
Avg rating:5.0/5.0
Slides: 29
Provided by: jkjk
Category:

less

Transcript and Presenter's Notes

Title: Chinese Remainder Theorem


1
Chinese Remainder Theorem In the last section,
welearned how to solve theequation ax b (mod
m).
2
In the 1st Century CE (Common Era, 400 AD), the
Chinese mathematician Sun Tsu Suan-Ching asked
the following problem There are certain things
whose number is unknown. When divided by 3, the
remainder is 2 when divided by 5, the remainder
is 3 and when divided by 7, the remainder is 2.
What is the number of things?
3
There are certain things whose number is
unknown. When divided by 3, the remainder is 2
when divided by 5, the remainder is 3 and when
divided by 7, the remainder is 2. What is the
number of things? But remainder upon division
by m... just means mod. In terms of mod, we
want to find a number x such that x 2 (mod
3) x 3 (mod 5) x 2 (mod 7)
4
The Chinese Remainder Theorem Let m1, m2, , mn
be (pairwise) relatively prime numbers. Then the
system x a1 (mod m1) x a2 (mod m2) . x
an (mod mn) Has a unique solution modulo M
m1m2 mn.
5
What does that mean? For example, In Sun-Tsus
problem, the numbers 3, 5, and 7 are relatively
prime (actually they ARE prime). x 2 (mod
3) x 3 (mod 5) x 2 (mod 7) The Chinese
remainder theorem says that there is EXACTLY ONE
number (mod 3x5x7) which satisfies all of these.
6
Sun-Tsus Example So, in this example, M 3 x 5
x 7 105. The theorem says there is exactly one
number x (mod 105) which satisfies all the
equations. 105 is not very big so we can use a
computer to find it, x 23 (mod 105)
7
Sun-Tsus Example Lets check that x 23
satisfies this x 23 73 2 2 (mod 3) x
23 45 3 3 (mod 5) x 23 37 2 2
(mod 7) The number 23 satisfies all of Sun-Tsus
equations.
8
Sun-Tsus Example But the theorem says more than
that. It says that ANY number which satisfies all
the equations equals 23 (mod 105). What numbers
equal 23 (mod 105)? 23 plus any multiple of
105, positive or negative. That is, any number
of the form 23 105 n. , -292, -187, -82,
23, 128, 233, 338,
9
Sun-Tsus Example Therefore, all the numbers ,
-292, -187, -82, 23, 128, 233, 338, are
solutions of Sun-Tsus three equations since they
all equal 23 (mod 105). Usually we dont care
about negative solutions. But if we do, the
theoremtells us what they are.
10
How to construct the solution (mod M) Step 1
Start with the equations you want to solve. x
a1 (mod m1) x a2 (mod m2) . x an (mod
mn) Then let M m1m2m3mn i.e., we let M be the
product of all the mods, mk. Remember In
order for the Theorem to apply (which tells us a
solution EXISTS), the mks have to be relatively
prime.
11
How to construct the solution (mod M) Step 2
For each of the equations x ak (mod mk) Let Mk
M / mk m1 m2 m3 mk-1 mk1 mn-1 mn That is,
we let Mk be the product of all the mods EXCEPT
for mk. We then write down another equation, Mk
yk 1 (mod mk)
12
How to construct the solution (mod M) Example
For each equation in Sun-Tsus problem, we would
write down the equations x 2 (mod 3)
? (5x7) y1 1 (mod 3) x 3 (mod 5) ? (3x7) y2
1 (mod 5) x 2 (mod 7) ? (3x5) y3 1 (mod
7) Observe, the number in front of yk is the
product of all the OTHER mods.
13
How to construct the solution (mod M) Step 3
Solve each of the equations for yk. Hint
Sometimes this involves calculating an inverse,
but often the numbers involved are small enough
that it may be easier just to check all the
numbers (mod m) until you find the solution. On a
test, unless explicitly told not to, you can just
guess the yk.
14
In Sun-Tsus example, the numbers are small
enough that we can just guess each solution yk.
x 2 (mod 3) ? (5x7) y1 1 (mod 3)
35 y1 1 2 y1 1 y1 2 x 3
(mod 5) ? (3x7) y2 1 (mod 5) 21 y2
1 y2 1 x 2 (mod 7) ? (3x5) y3
1 (mod 7) 15 y3 1 y3
1
15
How to construct the solution (mod M) Step 4
The solution x (mod M) of the system of
equations x a1 (mod m1) x a2 (mod
m2) . x an (mod mn) is given by x a1M1y1
a2M2y2 anMnyn. That is, for each equation
multiply together the numbers ak (occuring in the
original equation), Mk (the product of all the
other mods), and yk (the number we get from step
3). Then add them all up.
16
Back to Sun-Tsus example x 2 (mod 3)
? M1y1 (5x7) y1 1 (mod 3) y1 2 x 3
(mod 5) ? M2y2 (3x7) y2 1 (mod 5) y2
1 x 2 (mod 7) ? M3y3 (3x5) y3 1 (mod
7) y3 1 Therefore, the solution is
x a1M1y1 a2M2y2 anMnyn. 2 x (5x7)
x 2 3 x (3x7) x 1 2 x (3x5) x 1 233 23
(mod 105).
17
Why does this work? (without going into
detail) Suppose I take the solution x and mod
it by m1 x a1M1y1 a2M2y2
anMnyn. 2 x (5x7) x 2 3 x (3x7) x 1 2 x
(3x5) x 1 But would be true for any of the mk.
Therefore, x satisfies all of the equations.
This term equals a1, since y1M1 1 (mod m1).
Every other term is zero (mod m1), since MK is a
multiple of m1.
18
Example (Ancient Chinese Problem) A band of 17
pirates stole a sack of gold coins. When they
tried to divide the fortune into equal portions,
3 coins remained. In the ensuing brawl over who
should get the extra coins, one pirate was
killed. The wealth was redistributed, but this
time an equal division left 10 coins. Again an
argument developed in which another pirate was
killed, but now the fortune could be evenly
distributed. What was the least number of coins
which could have been stolen? What are all
possible numbers of coins which could have been
stolen?
19
Example (Ancient Chinese Problem) If x is the
number of coins, it has to satisfy the following
modular equations x 3 (mod 17) x 10 (mod
16) x 0 (mod 15) These numbers are relatively
prime, so the Chinese Remainder Theorem says
there IS a solution mod 17x16x15 4080. It
might have been possible there is NO SOLUTION.
20
Example (Ancient Chinese Problem) Write down the
equations for yk x 3 (mod 17) ? (16x15) y1
1 (mod 17) 240 y1 1 x 10 (mod
16) ? (17x15) y2 1 (mod 16) 255 y2
1 x 0 (mod 15) ? (17x16) y3 1 (mod
15) 272 y3 1
21
Example (Ancient Chinese Problem) Solve the
equations for yk by whatever way is easiest
(brute force or by finding inverses) (16x15)
y1 1 (mod 17) 240 y1 1 ? y1 9
(mod 17) 2 y1 1 (17x15) y2 1
(mod 16) 255 y2 1 ? y2 15 (mod
16) 15 y2 1 (17x16) y3 1 (mod
15) 272 y3 1 ? y3 8 (mod 15)
2 y3 1
22
Example (Ancient Chinese Problem) Construct the
solution x (mod 17x16x15) x a1M1y1
a2M2y2 anMnyn. 3x(16x15)x9
10x(17x15)x15 0x(17x16)x8 44730 3930
(mod 105).
23
Example (Ancient Chinese Problem) Check our
answer 3930 231x17 3 3 (mod 17) 3930
245x16 10 10 (mod 16) 3930 262x15 0 (mod
15) Therefore the solution works.
?
24
Example (Ancient Chinese Problem) What is the
smallest number of coins which the pirates could
have stolen? The smallest number is 3930. What
other possible numbers of coins could the pirates
have stolen? Any number which satisfies all of
those equations is equal to 3930 (mod 4080).
Therefore, Any number of the form 3930
4080n could have been stolen. N 3930, 8010,
12090, 16170,
25
Systems of Linear Modular Equations Suppose I
have a system of n linear modular equations
a1x b1 (mod m1) a2x b2 (mod m2) . anx
bn (mod mn) We know from the last section how to
solve each equation aix bi (mod mi)
individually. (when the solution actually
exists).
26
Systems of Linear Modular Equations We can solve
each equation individually to get a1x b1
(mod m1) x c1 (mod m1) a2x b2 (mod m2)
x c2 (mod m2) . . anx bn (mod
mn) x cn (mod mn) and then apply the Chinese
remainder theorem to find a solution. We just
have to be careful in case one of the linear
equations has no solution or more than one
solution. In which case we might have to apply
CRT more than once (multiple), or not at all (no
solutions).
?
27
Homeworks Solve the the following set of
simultaneous congruences i) x 5 (mod 6)
iii) 2x 1 (mod 5) x 4 (mod 11) 3x 9
(mod 6) x 3 (mod 17) 4x 1 (mod
7) 5x 9 (mod 11) ii) x 5 (mod 11) x
14 (mod 29) x 15 (mod 21) Question iii is a
bit harder than I would probably ask on a test.
How badly do you want an A?
28
Homeworks Answer Brahmaguptas question (7th
century AD) An old woman goes to market and a
horse steps on her basket and crashes the eggs.
The rider offers to pay for the damages and asks
her how many eggs she had brought. She does not
remember the exact number, but when she had taken
them out two at a time, there was one egg left.
The same happened when she picked them out three,
four, five, and six at a time, but when she took
them seven at a time they came out even. What is
the smallest number of eggs she could have
had? What other possible number of eggs could she
have? Hint x 1 (mod 2,3,4,5,6), x 0 (mod
7).
Write a Comment
User Comments (0)
About PowerShow.com