1 / 49

ENGG2013 Unit 11 Row-Rank

ENGG2013 Unit 11 Row-Rank. Feb, 2011. Last week. Caesar Cipher Modulo arithmetic: divide and take the remainder Encryption: y = x + 3 mod 26 Decryption: x = y – 3 mod 26 Hill cipher Matrix with entries 0,1,2,…,or 25. Need to compute matrix inverse mod 26. Today.

dolf
Télécharger la présentation

ENGG2013 Unit 11 Row-Rank

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ENGG2013 Unit 11Row-Rank Feb, 2011.

  2. Last week • Caesar Cipher • Modulo arithmetic: divide and take the remainder • Encryption: y = x + 3 mod 26 • Decryption: x = y – 3 mod 26 • Hill cipher • Matrix with entries 0,1,2,…,or 25. • Need to compute matrix inverse mod 26 ENGG2013

  3. Today • More examples on linear algebra mod n • Rank of a matrix • Row-rank • How to compute row-rank by RREF ENGG2013

  4. TASTE FROM DISCRETE MATH ENGG2013

  5. Continuous vs discrete vs finite 0.25 2 e Continuous –1 0 1 The real number line Discrete 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ….. Finite, for example 0, 1. (binary bit) ENGG2013

  6. Example of Finite mathematics Fix a one-to-one correspondence between the English alphabetsand the integers mod 26. Caesar’s cipher: shift a letter to the right by 3, x  x+3 mod 26 ENGG2013

  7. A psychological barrier • In discrete and finite math., we need to forget the fractions and decimal nimbers. • In application like Caesar cipher, 0.25 has no meaning. • Geometry is often missing. We need to re-define some operations like taking inverse in a pure algebraic way. ENGG2013

  8. Review • What is the meaning of “square root of 5”? ENGG2013

  9. Square root of a positive real number • Geometric meaning: • Algebraic meaning: “Square root of 5” is a real number x which satisfies the equation x2 = 5. 1 0 1 2 5 ENGG2013

  10. Review • What is the meaning of “1/3”? • What is the meaning of “(2/5)-1” ENGG2013

  11. Multiplicative inverse of a real number • Geometric meaning: 1/3 is the length obtained if we divide a line segment of unit length into three equal parts. • Algebraic meaning: “One third” is a real number x which satisfies the equation 3x = 1. 0 1/3 1 ENGG2013

  12. Multiplicative inverse of a real number • Geometric meaning: What is (2/5)-1? • Algebraic meaning: “(2/5)-1” is a real number x which satisfies the equation (2/5)x = 1. (2/5)-1 = 5/2 = 2.5 Area = 1 2/5 x ENGG2013

  13. What is a number? • We will adopt the viewpoint that A number is the root of some polynomial (with integer coefficients). • For example: • “2” is a number which satisfies x2 – 2=0. • “3/4” is a number which satisfies 4x – 3=0. • “10” is a number which satisfies x – 10=0 More precisely, the above numbers are “algebraic number”.Some numbers such as  and e are not algebraic,  and e are examples of “transcendental numbers”. ENGG2013

  14. Square root mod 10 • Geometric meaning: N/A • Algebraic meaning: Square root of 5 mod 10 is an integer x between 0 and 9 which satisfies x2 = 5 mod 10. Example: 5 mod 10 is equal to 5. Example: 4 mod 10 is either 2 or 8. Example: 3 mod 10 does not exist ENGG2013

  15. Multiplicative inverse mod 10 • Geometric meaning: N/A • Algebraic meaning: What is the multiplicative inverse of 3 mod 10? What we are going to do is: If we can find an integer x between 0 and 9 such that 3x=1 mod 10, then we say that this x is the multiplicative inverse of 3 mod 10, and write 3-1 = x mod 10. ENGG2013

  16. Find it by exhaustive search Simply try all 10 possibilities one by one: 38 = 24 = 4 mod 10 31 = 3 mod 10 39 = 27 = 7 mod 10 32= 6 mod 10 30 = 27 = 0 mod 10 33 = 9 mod 10 Answer: 3-1 = 7 mod 10 34 = 12 = 2 mod 10 35 = 15 = 5 mod 10 36 = 18 = 8 mod 10 37 = 21 = 1 mod 10 Aha! ENGG2013

  17. Multiplicative inverse mod 5 • Geometric meaning: N/A • Algebraic meaning: What is the multiplicative inverse of 3 mod 5? Try to find an integer x between 0 and 4 such that 3x=1 mod 5. If succeed, we say that this x is the multiplicative inverse of 3 mod 5, and write 3-1 = x mod 5. ENGG2013

  18. Find it by exhaustive search Simply try all 5 possibilities one by one: 31 = 3 mod 5 32= 6 = 1 mod 5 33 = 9 = 4 mod 5 Answer: 3-1 = 2 mod 5 34 = 12 = 2 mod 5 30 = 0 mod 5 ENGG2013

  19. Multiplicative inverse mod n in general • Given an integer b and integer n. • Definition: If we can find an integer x between 0 and n-1 such that bx=1 mod n, then we say that this x is the multiplicative inverse of b mod n, and write b-1 = x mod n. Two keywords ENGG2013

  20. First keyword “if”: inverse may not exist • What is the multiplicative inverse of 2 mod 10? • Try to find an integer x between 0 and 9, such that 2x=1 mod 10. 27 = 14 = 4 mod 10 21 = 2 mod 10 22 = 4 mod 10 28 = 16 = 6 mod 10 23 = 6 mod 10 29 = 18 = 8 mod 10 24 = 8 mod 10 20 = 0 mod 10 25 = 10 = 0 mod 10 None of them is equal to 1. 2-1 mod 10 does not exist. 26 = 12 = 2 mod 10 ENGG2013

  21. Property 1 • If the greatest common divisor of b and n are larger than 1, then we cannot find any multiplicative inverse of b mod n. • Reason: • Let d be the greatest common divisor of b and n. Suppose d > 1. • For any integer x, bx is a multiple of d.But n is also a multiple of d. • The remainder of n divided by bx is also amultiple of d, which by assumption is not 1. ENGG2013

  22. Property 2, “the”:multiplicative inverse is unique • Suppose that the gcd of b and n is 1. (This assumption makes sense because of property 1). • Suppose that b has two multiplicative inverses mod n, say x1 and x2, such that bx1= 1 mod n and bx2 = 1 mod n. • Let q1 be the quotient when we divide bx1 by n and q2 be the quotient when we divide bx2 by n. We have: • bx1 = q1 n + 1, • bx2 = q2 n + 1. • Subtracting the above two equations, we get b(x1 – x2) = (q1 – q2) n • b(x1 – x2) is divisible by n • Because n and b has no common factor, (x1 – x2) is divisible by n. • Because x1 and x2 are both between 0 and n – 1 , we must have x1 = x2 • Therefore, there is only one solution to bx = 1 mod n. ENGG2013

  23. Example: Multiplicative inverse mod 10 • 0-1 mod 10 does not exist. • 1-1 = 1 mod 10, because 11=1 mod 10. • 2-1 mod 10 does not exist, because gcd(2,10)=2. • 3-1 = 7 mod 10, because 37=21=1 mod 10. • 4-1 mod 10 does not exist, because gcd(4,10)=2. • 5-1 mod 10 does not exist, because gcd(5,10)=2. • 6-1 mod 10 does not exist, because gcd(6,10)=2. • 7-1 = 3 mod 10, because 73=21= mod 10. • 8-1 mod 10 does not exist, because gcd(8,10)=2. • 9-1 = 9 mod 10, because 91=81=1 mod 10. ENGG2013

  24. 2x2 Hill cipher • Encryption matrix • Encryption is done by matrix multiplication • Need to find a decryption matrix D such that a,b,c,d are integersbetween 0 and 25. ENGG2013

  25. Formula for 2x2 matrix inverse • Example: Suppose that the encryption matrix is given by Task: Find the matrix inverse of E mod 26. This is an integer between 0 and 25. The multiplicative inverse calculated as in pp.12-15 ENGG2013

  26. Find the multiplicative inverse of det by exhaustive search • det(E) = 23 – 19= – 3 = 23 mod 26. • Find an integer x between 0 and 25 such that 23x = 1 mod 26. • By property 1, we only need to search for x which has no common factor with 26. 231 = 23 mod 26 239 = 25 mod 26 233 = 17 mod 26 2311 = 19 mod 26 We can skip 13 235 = 11 mod 26 2315 = 7 mod 26 237 = 5 mod 26 2317 = 1 mod 26 Stop. The multiplicative inverseof 23 is found. ENGG2013

  27. The inverse mod 26 • det(E) -1 = 23-1 = 17 mod 26, • because 2317=391 = 1526+1 • The inverse of E mod 26 is • Check: ENGG2013

  28. Encryption by Hill cipher • The encryption and decryption matrix must be kept secret. • Encryption of “HATE”: • convert the English letters to integers between 0 and 25 HATE  7, 0, 19, 4. • group the letters into blocks of length 2, and then multiply by the matrix E. • Convert 14, 7, 22, 5 to the ciphertext “OHWF” ENGG2013

  29. Decryption by Hill cipher • Decryption of “OHWF”, • convert the English letters to integers between 0 and 25 OHWF  14, 7, 22, 5. • group the letters into blocks of length 2, and then multiply by the decryption matrix D. • Convert 7, 0, 19, 4 to “HATE”. ENGG2013

  30. RANK ENGG2013

  31. Back to the “real” world • In the remainder of this lecture, all variables are real numbers. • In a system of linear equations, the notion of “rank” measures the number of essentially different equations. They are multiple of each other.We can remove one of themwithout altering the solutions. ENGG2013

  32. A larger example • In a large system of linear equations, how to find and remove redundant equations? ENGG2013

  33. The representation using augmented matrix • Recall that the augmented matrix representation of a system of linear equations. The third equation is the sumof the first and second equation The third row is equal to the sumof the first and second rows ENGG2013

  34. Recall: Linearly dependence • Definition: m vectors v1, v2, …, vm (each of them have n components) are linearly dependent if there are m real numbers, a1, a2, …, am, not all zero, such that the linear combination is equal to zero a1 v1+ a2 v2+ … + am vm= 0 ENGG2013

  35. Simple fact • If one of the m vectors v1, v2, …, vm is the zero vector 0, then v1, v2, …, vm are linearly dependent. • Reason: Suppose v1= 0. 1 v1+ 0 v2+ … + 0 vm= 0 Not all coefficients are zero. In fact, the first coefficient is not zero. ENGG2013

  36. Theorem v1, v2, …, vm are linearly dependent if and only if one of them is a linear combination of the others. Proof () Suppose that v1, v2, …, vm are linearly dependent. By definition, we can find m real numbers, a1, a2, …, am, not all zero such that a1 v1+ a2 v2+ … + am vm= 0. Suppose that ai0.Then vi = (-1/ai)(a1 v1+ …+ai-1 vi-1+ ai+1 vi+1+ … + am vm) The i-th vector vi is a linear combination of the others. ENGG2013

  37. Theorem v1, v2, …, vm are linearly dependent if and only if one of them is a linear combination of the others. Proof () Suppose that vi is a linear combination of the other vector: vi = c1 v1+ …+ci-1 vi-1+ ci+1 vi+1+ … + cm vm for some constants c1, …,ci-1, ci+1,…cm.Then 0= c1 v1+ …+ci-1 vi-1– vi+ ci+1 vi+1+ … + cm vm The i-th coefficient is non-zero (it is equal to -1). The zero vector can be expressed as a linear combination of v1, v2, …, vm, in which not all coefficients are zero. ENGG2013

  38. Another way to say the same thing • If v1, v2, …, vm are linearly independent then none of them can be written as a linear combination of the others, and vice versa. ENGG2013

  39. Definition: Row-rank of a matrix • Given a matrix M, the row-rank of M is the maximum number of linearly independent rows in M. • Example: • Because the third row is the sum of the other two rows, i.e., is a linear combination of the other two rows., by the theorem in p.32, the three rows are linearly dependent. • The first and second row are linearly independent. • Therefore the maximum number of linearly independent rows is 2. •  the row-rank of this matrix is equal to 2. ENGG2013

  40. Example • What is the row-rank of ? • What is the row-rank of ? Ans: 2 Ans: 4 ENGG2013

  41. Theorem Elementary row operations do not affect the row-rank Proof: Let A be an nm matrix. Let the i-th row of a matrix A be ri. • Exchanging two rows does not affect the maximal number linearly independent rows. • Pick any k rows in A. Because of (1) above, we may exchange the rows and re-label them as r1, r2, …, rk. We want to see the effect of multiplying the p-th row (1  p  k) by a nonzero constant c. ENGG2013

  42. Proof (step 2) Elementary row operations do not affect the row-rank Suppose r1, r2 … rp, …, rk are linearly dependent. By definition a1r1+a2r2 +…+ aprp+ …+ akrk= 0.(not all a1, a2, …, akare zero). Divide an multiply simultaneously by c,a1r1+a2r2 +…+ (ap/c) (crp)+ …+akrk= 0. Not all a1, a2, …, ap/c, …, ak are zero. Therefore r1, r2 ,…, crp, …, rk are linearly dependent. ENGG2013

  43. Proof (step 2 cont’d) Suppose r1, r2 … crp, …, rk are linearly dependent. By def., b1r1+b2r2 +…+ bp (crp)+ …+ bkrk= 0.(not all b1, b2, …, bkare zero). Just bring the constant c out of the parenthesis,b1r1+b2r2 +…+ (cbp) rp+ …+bkrk= 0. Not all b1, b2, …, cbp, …, bk are zero. r1, r2,…, rp, …, rk are linearly dependent. Therefore, r1, r2,…, rp, …, rk are linearly dependent if and only if r1, r2,…, crp, …, rk ENGG2013

  44. Proof (step 3) • What is the effect of adding d times the 2-nd row to the 1-st row? (Because exchange of rows does not affect the row-rank, considering adding d times r2 to r1 is sufficient. There is no loss of generality.) Suppose r1, r2 …, rk are linearly independent. By def., e1r1+e2r2 +…+ ekrk= 0is possible only when e1= e2= …= ek= 0. ENGG2013

  45. Proof (step 3) Now we want to check whether (r1+dr2), r2 , r3 , …,rkare linearly independent. If f1(r1+dr2)+f2r2 +f3r3 +… …+ fkrk= 0, for some constants f1, f2, …, fk then f1r1+(f1d+f2)r2 +f3r3 +… …+ fkrk= 0. But this is possible only if f1= (f1d+f2)= …= fk= 0. • All coefficients f1, f2 …, fk are 0 • (r1+dr2), r2 ,r3,rkare linearly independent. f2=0 ENGG2013

  46. Proof (step 3 reverse direction) Suppose r1+dr2, r2 …, rk are linearly independent. By def., g1(r1+dr2)+g2r2 +… …+ gkrk= 0is possible only when g1= g2= …= gk= 0. We want to check whether r1, r2 ,r3,…,rkare linearly independent. Ifh1r1+h2r2 +…+ hkrk= 0, then h1(r1+dr2–dr2)+h2r2 +…+ hkrk= 0 h1(r1+dr2)+(–h1d+h2)r2 +…+ hkrk= 0. But this is possible only when h1= (–h1d+h2)= … = hk= 0 • All coefficients h1, h2… hk are 0 • r1, r2 ,r3,…,rkare linearly independent. h2=0 ENGG2013

  47. An algorithm for computing row-rank • Algorithm for computing the row-rank of M. • Apply elementary row operations to M, and transform it to a matrix in RREF. • Count the number of non-zero rows in the resulting RREF. • Because • Row reductions does not change the row-rank. • The row-rank of a matrix in reduced row-echelon form is easy to calculate: just count the number of nonzero rows. ENGG2013

  48. RREF for rank computation • For mxn matrix, computing the row-rank of a matrix using the definition in p.39 requires checking 2m-1 combinations. This is not feasible even if the number of rows, m, is moderately large. • By reduction to RREF, the running times is of the order m3. This is polynomial time in m. • However, in Matlab, the computation of rank is done by SVD (singular value decomposition),because SVD is more stable numerically. (type “doc rank” in Matlab for more details) ENGG2013

  49. Notes • For modulo arithmetic, you can find out more in • http://en.wikipedia.org/wiki/Modular_arithmetic • http://en.wikibooks.org/wiki/High_School_Mathematics_Extensions/Primes/Modular_Arithmetic • Or any introductory book on number theory • In some books “a=b mod n” is written as “ab mod n”, (pronounced as “a is congruent to b mod n”) • In some webpages or books, you may see the symbols They stands for the set of integers and the set of rational numbers respectively. • The letter “Z” comes from German “Zahlen”, which means “numbers”. “Q” comes from English “quotients”.http://en.wikipedia.org/wiki/Integer ENGG2013

More Related