Top Banner

Click here to load reader

of 36

The Integers and Division. 2 Example: Let n and d be positive integers. How many positive integers not exceeding n are divisible by d? Solution: They.

Dec 25, 2015

Download

Documents

Camilla Morgan
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • Slide 1
  • The Integers and Division
  • Slide 2
  • 2 Example: Let n and d be positive integers. How many positive integers not exceeding n are divisible by d? Solution: They are of the form {dk}, where k is a positive integer. 0 < dk n 0 < k n/d There are n/d positive integers not exceeding n that are divisible by d.
  • Slide 3
  • 3 The Division Algorithm Let a be an integer and d a positive integer. Then !(q, r) Z 2 ; 0 r < d: a = dq +r.
  • Slide 4
  • 4 Definition : d is called the divisor, a the dividend, q the quotient and r the remainder. q = a div d, r = a mod d. Example: 101 = 11.9 + 2 Quotient = 101 div 11 Remainder = 2 = 101 mod 11
  • Slide 5
  • 5 Greatest Common Divisors & Least Common Multiples Definition: Let a and b be integers, not both zero. The largest integer d such that d|a and d|b is called the greatest common divisor of a and b. It is denoted gcd (a, b). Example: gcd (24, 36) Div (24) = {1,2,3,4,6,8,12,24} Div (36) = {1,2,3,4,6,8,9,12,18,36} Com(24,36) = = {1,2,3,4,6,12} gcd(24,36) = 12
  • Slide 6
  • 6 Definition: The integers a and b are relatively prime (rp) if gcd(a, b) =1. Example: 17 and 22 are rp since gcd(17,22) = 1.
  • Slide 7
  • 7 Definition: The least common multiple (lcm) of the positive integers a and b is the smallest positive integer that is divisible by both a and b. where max(x,y) denotes the maximum of x and y. Example : What is the least common multiple of: 2 3 3 5 7 2 and 2 4 3 3 ? Solution: lcm(2 3 3 5 7 2,2 4 3 3 ) = 2 max(3,4). 3 max(5,3). 7 max(2,0) = 2 4 3 5 7 2
  • Slide 8
  • 8 Theorem: Let a and b be positive integers. Then ab = gcd(a,b).lcm(a.b).
  • Slide 9
  • 9 Modular Arithmetic Definition: Let (a, b) Z 2,, m Z + then a is a congruent to b modulo m if m divides a b. Notation: a b (mod m). Theorem: Let a and b be integers, and let m be a positive integer. Then a b (mod m) if and only if a mod m = b mod m.
  • Slide 10
  • 10 Example: 17 5 (mod 6) 24 14 (mod 6)? Since: 6|(17 5) = 12 17 5 (mod 6) 6 does not divide 10 24 is not congruent to 14 (mod 6) Theorem: Let m be a positive integer. The integers a and b are congruent modulo m if and only if k Z; a = b + km
  • Slide 11
  • 11 Applications of Congruences 1. Hashing Functions 2. Pseudorandom Numbers 3. Cryptology (Caesar Cepher)
  • Slide 12
  • 12 1. Hashing Functions Assignment of memory location to a student record h(k) = k mod m Example: h (064212848) = 064212848 mod 111 = 14 when m = 111 Key: social security # # of available memory location
  • Slide 13
  • 13 2. Pseudorandom Numbers Needed for computer simulation Linear congruential method : x n+1 = (ax n + c) mod m Put them between 0 and 1 as: y n = x n /m
  • Slide 14
  • 14 3. Cryptology (Caesar Cepher) a) Encryption: Making messages secrets by shifting each letter three letters forward in the alphabet B E X A Mathematical expression: f(p) = (p + 3) mod 26 0 p 25
  • Slide 15
  • 15 Example: What is the secret message produced from the message Meet you in the park Solution: 1. Replace letters with numbers: meet = 12 4 4 19 you = 24 14 20 in = 8 13 the = 19 7 4 park = 15 0 17 10 2. Replace each of these numbers p by f(p) = (p + 3) mod 26 meet = 15 7 7 22 you = 1 17 23 in = 11 16 the = 22 10 7 park = 18 3 20 13 3. Translate back into letters: PHHW BRX LQ WKH SDUN
  • Slide 16
  • 16 b) Decryption (Deciphering) f(p) = (p + k) mod 26 (shift cepher) f -1 (p) = (p k) mod 26 Caesars method and shift cipher are very vulnerable and thus have low level of security (reason frequency of occurrence of letters in the message) Replace letters with blocks of letters.
  • Slide 17
  • Matrices
  • Slide 18
  • 18 Definition: A matrix is a rectangular array of numbers. A matrix with m rows and n columns is called an m x n matrix. A matrix with the same number of rows as columns is called square. Two matrices are equal if they have the same number of rows and the same number of columns and the corresponding entries in every position are equal. Example: The matrix is a 3 X 2 matrix.
  • Slide 19
  • 19 Definition: Let The ith row of A is the 1 x n matrix [a i1, a i2, , a in ]. The jth column of A is the n x 1 matrix The (i, j)th element or entry of A is the element a ij, that is, the number in the ith row and jth column of A. A convenient shorthand notation for expressing the matrix A is to write A = [a ij ], which indicates that A is the matrix with its (i, j)th element equal to a ij.
  • Slide 20
  • 20 Matrix Arithmetic Definition Let A = [a ij ] and B = [b ij ] be m x n matrices. The sum of A and B, denoted by A + B, is the m x n matrix that has a ij + b ij as its (i, j)th element. In other words, A + B = [a ij + b ij ]. Example:
  • Slide 21
  • 21 Definition: Let A be an m x k matrix and B be a k x n matrix. The product of A and B, denoted by AB, is the m x n matrix with its (i, j)th entry equal to the sum of the products of the corresponding elements from the ith row of A and the jth column of B. In other words, if AB = [c ij ], then C ij = a i1 b 1j + a i2 b 2j + + a ik b kj.
  • Slide 22
  • 22 Example: Let Find AB if it is defined. Solution: Since A is a 4 x 3 matrix and B is a 3 x 2 matrix, the product AB is defined and is a 4 x 2 matrix. To find the elements of AB, the corresponding elements of the rows of A and the columns of B are first multiplied and then these products are added. For instance, the element in the (3, 1)th position of AB is the sum of the products of the corresponding elements of the third row of A and the first column of B; namely 3 * 2 + 1 * 1 + 0 * 3 = 7. When all the elements of AB are computed, we see that Matrix multiplication is not commutative.
  • Slide 23
  • 23 Example: Let Does AB = BA? Solution: We find that Hence, AB BA.
  • Slide 24
  • 24 Matrix chain multiplication Problem: How should the matrix-chain A 1 A 2 A n be computed using the fewest multiplication of integers, where A 1 A 2 A n are m 1 x m 2, m 2 x m 3, , m n x m n+1 matrices respectively and each has integers as entries?
  • Slide 25
  • 25 Example: A 1 = 30 x 20 (30 rows and 20 columns) A 2 = 20 x 40 A 3 = 40 x 10 Solution: 2 possibilities to compute A 1 A 2 A 3 1) A 1 (A 2 A 3 ) 2) (A 1 A 2 )A 3 1) First A 2 A 3 requires 20 * 40 * 10 = 8000 multiplications A 1 (A 2 A 3 ) requires 30 * 20 * 10 = 6000 multiplications Total: 14000 multiplications. 2) First A 1 A 2 requires 30 * 20 * 40 = 24000 multiplications (A 1 A 2 )A 3 requires 30 * 40 * 10 = 12000 Total: 36000 multiplications. (1) is more efficient!
  • Slide 26
  • 26 Transposes and power matrices Definition The identity matrix of order n is the n x n matrix I n = [ ij ], where ij = 1 if i = j and ij = 0 if i j. Hence
  • Slide 27
  • 27 Definition Let A = [a ij ] be an m x n matrix. The transpose of A, denoted A t, is the n x m matrix obtained by interchanging the rows and the columns of A. In other words, if A t = [b ij ], then b ij = a ij for i = 1, 2, , n and j = 1, 2, , m. Example: The transpose of the matrix is
  • Slide 28
  • 28 Definition A square matrix A is called symmetric if A = A t. Thus A = [a ij ] is symmetric if a ij = a ji for all i and j with 1 i n and 1 j n. Example: The matrix is symmetric.
  • Slide 29
  • 29 Zero-one matrices It is a matrix with entries that are 0 or 1. They represent discrete structures using Boolean arithmetic. We define the following Boolean operations:
  • Slide 30
  • 30 Definition Let A = [a ij ] and B = [b ij ] be m x n zero-one matrices. Then the join of A and B is the zero-one matrix with (i, j)th entry a ij b ij. The join of A and B is denoted A B. The meet of A and B is the zero-one matrix with (i, j)th entry a ij b ij. The meet of A and B is denoted by A B.
  • Slide 31
  • 31 Example: Find the join and meet of the zero-one matrices Solution: We find that the joint of A and B is: The meet of A and B is:
  • Slide 32
  • 32 Definition: Let A = [a ij ] be an m x k zero-one matrix and B = [b ij ] be a k x n zero-one matrix. Then the Boolean product of A and B, denoted by A B, is the m x n matrix with (i, j)th entry [c ij ] where c ij = (a i1 b 1j ) (a i2 b 2j ) (a ik b kj ).
  • Slide 33
  • 33 Example: Find the Boolean product of A and B, where Solution:
  • Slide 34
  • 34 Algorithm The Boolean Product procedure Boolean product (A,B: zero-one matrices) for i := 1 to m for j := 1 to n begin c ij := 0 for q := 1 to k c ij := c ij (a iq b qj ) end {C = [c ij ] is the Boolean product of A and B}
  • Slide 35
  • 35 Definition Let A be a square zero-one matrix and let r be a positive integer. The rth Boolean power of A is the Boolean product of r factors of A. The rth Boolean product of A is denoted by A [r]. Hence (This is well defined since the Boolean product of matrices is associative.) We also define A [0] to be I n.
  • Slide 36
  • 36 Example: Let. Find A [n] for all positive integers n. Solution: We find that We also find that Additional computation shows that The reader can now see that A [n] = A [5] for all positive integers n with n 5.