3. Chinese Reminder Theory¶
3.1. Knowledge required¶
3.2. Question¶
For a number x, if
what is x?
In order to use CRT, the module number 3, 5 and 7 should be relatively prime.
Let Mi be the multiplication of the module number except number i. Say:
The multiplicative inverse of M1, M2 and M3 in GF(3), GF(5) and GF(7) repectively can be computed by Extended Euclidean algorithm.
We can easily check that \(2*35 ~mod~ 3 = 1\).
Then we have
3.3. A simple Proof¶
Let’s restate the problem and the solution again.
Find \(x\) such that
Then
The final \(mod~abc\) is only to make \(x\) as small as possible.
Now, let’s compute \(x~mod~a\)
Split the computation to three parts:
So
3.4. Applications of CRT¶
3.4.1. Example 1¶
Suppose we have two calculators which can do operations smaller than 5 and 3 respectively. How to deal with operations with numbers smaller than 15?
Create a table as follows:
0 |
1 |
2 |
3 |
4 |
|
---|---|---|---|---|---|
0 |
0 |
6 |
12 |
3 |
9 |
1 |
10 |
1 |
7 |
13 |
4 |
2 |
5 |
11 |
2 |
8 |
14 |
Arrange numbers from 0-14 to the table above Row 0 means the number mod 3 is 0. Column 3 means then number mod 5 is 3.
\(12\) is row 0, column 2 \(13\) is row 1, column 3 So the result’s row is \(0 * 1 ~mod~3 = 0\), column is \(2 * 3~mod~5=1\). The number in row 0, column 1 is 6.
We have
3.4.2. Example 2¶
\(973 \times 73~mod~1813 = ?\)
\(1813 = 49*37\). We can split the modulo 1813 into modulo 49 and modulo 37.
We use \(937 = (11, 42)\) and \(73 = (36, 24)\) to denote the two numbers under modulo 37 and 39.
Then \(973x73 = (11*36~mod~37, 42*24~mod~49) = (26, 28)\). We now have a classic CRT problem.
What is \(x\) if \(x~mod~37=26\) and \(x~mod~49=28\)?
Honestly, if we can compute it directly, no bother to do the split. This method here is the fundamental for parallel computing. Example 1 may be a better example.