ผลต่างระหว่างรุ่นของ "01204211/activity7 number theory 2"
Jittat (คุย | มีส่วนร่วม) |
Jittat (คุย | มีส่วนร่วม) |
||
(ไม่แสดง 7 รุ่นระหว่างกลางโดยผู้ใช้คนเดียวกัน) | |||
แถว 3: | แถว 3: | ||
== In-class activities == | == In-class activities == | ||
− | + | : '''Due date: 14 Dec 2015''' | |
+ | ''These activities require programming. You can use any languages that you like. Please keep the codes for these activities for the other sets of activities as well.'' | ||
'''A.1''' Implement the Extended-GCD algorithm and use it to find, for each following pair of <math>a</math> and <math>b</math>, the g.c.d. of <math>a</math> and <math>b</math> and a pair of integers <math>(x,y)</math> such that <math>ax + by = gcd(a,b)</math>. | '''A.1''' Implement the Extended-GCD algorithm and use it to find, for each following pair of <math>a</math> and <math>b</math>, the g.c.d. of <math>a</math> and <math>b</math> and a pair of integers <math>(x,y)</math> such that <math>ax + by = gcd(a,b)</math>. | ||
แถว 17: | แถว 18: | ||
(e) <math>a = </math>your student id, <math>b = </math> the student id of another student sitting next to you. (Don't forget to write down the values of <math>a</math> and <math>b</math> as well. | (e) <math>a = </math>your student id, <math>b = </math> the student id of another student sitting next to you. (Don't forget to write down the values of <math>a</math> and <math>b</math> as well. | ||
+ | |||
+ | |||
+ | '''Notes:''' The pseudo code for the Extended-GCD is as follows. (Don't forget to watch the video clips.) | ||
+ | |||
+ | FUNCTION ExtendedGCD(a,b) | ||
+ | 1. IF a mod b == 0 THEN | ||
+ | 2. return (b,0,1) | ||
+ | 3. ELSE | ||
+ | 4. (g,x,y) = ExtendedGCD(b, a mod b) | ||
+ | 5. return (g,y, x - y * floor(a/b)) | ||
+ | 6. ENDIF | ||
+ | |||
แถว 77: | แถว 90: | ||
The nice thing about modular arithmetic when the modulus is a prime is that we can perform division with integers. This enables us to use methods (designed for a system of real numbers) to solve a system of linear equations. | The nice thing about modular arithmetic when the modulus is a prime is that we can perform division with integers. This enables us to use methods (designed for a system of real numbers) to solve a system of linear equations. | ||
− | == | + | Let's take your student id and make it our constraints. Let <math>b_1,b_2,b_3,\ldots,b_{10}</math> be the digits from your student id. (E.g., if your id is 1234567890, <math>b_1=1,b_5=5,b_{10}=0</math>.) |
+ | |||
+ | Let's perform all calculations modulo 17. | ||
+ | |||
+ | (a) Solve for <math>a_0,a_1,\ldots,a_9</math> in this system of linear congruences. (Don't forget that we are doing modular arithmetic modulo 17 here.) | ||
+ | |||
+ | <math> | ||
+ | \left(\begin{array}{cccccccccc} | ||
+ | 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ | ||
+ | 2 & 1 & 9 & 13 & 15 & 16 & 8 & 4 & 2 & 1 \\ | ||
+ | 14 & 16 & 11 & 15 & 5 & 13 & 10 & 9 & 3 & 1 \\ | ||
+ | 4 & 1 & 13 & 16 & 4 & 1 & 13 & 16 & 4 & 1 \\ | ||
+ | 12 & 16 & 10 & 2 & 14 & 13 & 6 & 8 & 5 & 1 \\ | ||
+ | 11 & 16 & 14 & 8 & 7 & 4 & 12 & 2 & 6 & 1 \\ | ||
+ | 10 & 16 & 12 & 9 & 11 & 4 & 3 & 15 & 7 & 1 \\ | ||
+ | 8 & 1 & 15 & 4 & 9 & 16 & 2 & 13 & 8 & 1 \\ | ||
+ | 9 & 1 & 2 & 4 & 8 & 16 & 15 & 13 & 9 & 1 \\ | ||
+ | 7 & 16 & 5 & 9 & 6 & 4 & 14 & 15 & 10 & 1 | ||
+ | \end{array}\right) | ||
+ | \left(\begin{array}{c} | ||
+ | a_9 \\ a_8 \\ a_7 \\ a_6 \\ a_5 \\ a_4 \\ a_3 \\ a_2 \\ a_1 \\ a_0 | ||
+ | \end{array}\right) | ||
+ | \equiv | ||
+ | \left(\begin{array}{c} | ||
+ | b_1 \\ b_2 \\ b_3 \\ b_4 \\ b_5 \\ b_6 \\ b_7 \\ b_8 \\ b_9 \\ b_{10} | ||
+ | \end{array}\right) | ||
+ | </math> | ||
+ | |||
+ | If you need the coefficient matrix, you can copy from the following text: | ||
+ | |||
+ | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 | ||
+ | 2, 1, 9, 13, 15, 16, 8, 4, 2, 1 | ||
+ | 14, 16, 11, 15, 5, 13, 10, 9, 3, 1 | ||
+ | 4, 1, 13, 16, 4, 1, 13, 16, 4, 1 | ||
+ | 12, 16, 10, 2, 14, 13, 6, 8, 5, 1 | ||
+ | 11, 16, 14, 8, 7, 4, 12, 2, 6, 1 | ||
+ | 10, 16, 12, 9, 11, 4, 3, 15, 7, 1 | ||
+ | 8, 1, 15, 4, 9, 16, 2, 13, 8, 1 | ||
+ | 9, 1, 2, 4, 8, 16, 15, 13, 9, 1 | ||
+ | 7, 16, 5, 9, 6, 4, 14, 15, 10, 1 | ||
+ | |||
+ | (b) The coefficient matrix in this question is a special one to find coefficients of a polynomial <math>F(x)=a_9x^9 + a_8x^8 + \cdots a_1x + a_0</math>. Find <math>F(1),F(2),\ldots,F(10)</math>. What do you see? (Don't forget to perform every calculation modulo 17.) |
รุ่นแก้ไขปัจจุบันเมื่อ 17:15, 9 ธันวาคม 2558
- This is part of 01204211-58.
In-class activities
- Due date: 14 Dec 2015
These activities require programming. You can use any languages that you like. Please keep the codes for these activities for the other sets of activities as well.
A.1 Implement the Extended-GCD algorithm and use it to find, for each following pair of and , the g.c.d. of and and a pair of integers such that .
(a)
(b)
(c)
(d)
(e) your student id, the student id of another student sitting next to you. (Don't forget to write down the values of and as well.
Notes: The pseudo code for the Extended-GCD is as follows. (Don't forget to watch the video clips.)
FUNCTION ExtendedGCD(a,b) 1. IF a mod b == 0 THEN 2. return (b,0,1) 3. ELSE 4. (g,x,y) = ExtendedGCD(b, a mod b) 5. return (g,y, x - y * floor(a/b)) 6. ENDIF
A.2 Use the Extended-GCD algorithm to find the modular multiplicative inverse for the divisor in each of the following question and find the result of the modular division. If the inverse does not exist, you can just state the fact and state that the division cannot be found.
(E.g., if the question is to find 4/3 (mod 11), you have to find and then find such that (mod 11).)
(a) (mod )
(b) (mod )
(c) (mod )
(d) (mod )
(e) (mod )
A.3 RSA. In this activity, we will try to run the RSA algorithm.
PART I: Preparation
(a) Pick two primes from this list of primes. Call them and .
(b) Let .
(c) Pick some integer (where ) such that .
(d) Find integer which is (mod ).
(e) Write out the public key and the private key .
PART II: Encryption. In this part, you should work with another student. Let's call another student A.
(a) Give A you public key.
(b) Let A pick one number as a message (make sure that ). A should not tell you the message .
(c) Now, let A encrypt the message with your public key, and give you the encrypted message .
(d) Decrypt and compare the message with A's original message .
A.4 Solve for in this equation (mod 71143).
A.5 In this problem, we will perform all calculation modulo 11. Let denote the last 2 digits of your student id. (E.g., if you ID is 1234567890, then x=9, y=0.) Find the values that satisfy these equations.
(mod 11)
(mod 11)
(Try to solve this without the Gaussian elimination algorithm in the next activity.)
A.6 Gaussian Elimination. In this activity we will implement the Gaussian Elimination algorithm for solving systems of linear equations.
- Do you remember the Gaussian Elimination algorithm? If you don't, please read this wikipedia entry on the Gaussian elimination algorithm first.
The nice thing about modular arithmetic when the modulus is a prime is that we can perform division with integers. This enables us to use methods (designed for a system of real numbers) to solve a system of linear equations.
Let's take your student id and make it our constraints. Let be the digits from your student id. (E.g., if your id is 1234567890, .)
Let's perform all calculations modulo 17.
(a) Solve for in this system of linear congruences. (Don't forget that we are doing modular arithmetic modulo 17 here.)
If you need the coefficient matrix, you can copy from the following text:
1, 1, 1, 1, 1, 1, 1, 1, 1, 1 2, 1, 9, 13, 15, 16, 8, 4, 2, 1 14, 16, 11, 15, 5, 13, 10, 9, 3, 1 4, 1, 13, 16, 4, 1, 13, 16, 4, 1 12, 16, 10, 2, 14, 13, 6, 8, 5, 1 11, 16, 14, 8, 7, 4, 12, 2, 6, 1 10, 16, 12, 9, 11, 4, 3, 15, 7, 1 8, 1, 15, 4, 9, 16, 2, 13, 8, 1 9, 1, 2, 4, 8, 16, 15, 13, 9, 1 7, 16, 5, 9, 6, 4, 14, 15, 10, 1
(b) The coefficient matrix in this question is a special one to find coefficients of a polynomial . Find . What do you see? (Don't forget to perform every calculation modulo 17.)