Greatest Common Divisors & Least Common Multiples  Definition 4 Let a and b be integers, not both zero. The largest integer d such that d|a and d|b is.

Slides:



Advertisements
Similar presentations
CSNB143 – Discrete Structure
Advertisements

Chapter Matrices Matrix Arithmetic
February 26, 2015Applied Discrete Mathematics Week 5: Mathematical Reasoning 1 Addition of Integers Example: Add a = (1110) 2 and b = (1011) 2. a 0 + b.
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
Study Guides Quantitative - Arithmetic - Numbers, Divisibility Test, HCF and LCM Mycatstudy.com.
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
CSE115/ENGR160 Discrete Mathematics 03/13/12 Ming-Hsuan Yang UC Merced 1.
Number Theory and Cryptography
Prime An integer greater than one is called a prime number if its only positive divisors (factors) are one and itself. Examples: The first six primes are.
1 Section 2.5 Integers and Algorithms. 2 Euclidean algorithm for finding gcd Where L is a larger number, and S is a smaller number, to find gcd(L,S):
Matrices MSU CSE 260.
MATRICES. Matrices A matrix is a rectangular array of objects (usually numbers) arranged in m horizontal rows and n vertical columns. A matrix with m.
3.8 Matrices.
Division in the Integers Theorem 1. If n and m are integers and n>0, then m=qn+r for unique integers q and r with 0
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
CSCI 1900 Discrete Structures
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 2): The Fundamentals: Algorithms, the.
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
9/2/2015Discrete Structures1 Let us get into… Number Theory.
CSE 504 Discrete Mathematics & Foundations of Computer Science
Quantitative - Arithmetic - Numbers, Divisibility Test, HCF and LCM
February 25, 2002Applied Discrete Mathematics Week 5: Mathematical Reasoning 1 Addition of Integers How do we (humans) add two integers? Example: 7583.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 3): The Fundamentals: Algorithms, the.
February 24, 2015Applied Discrete Mathematics Week 4: Number Theory 1 Modular Arithmetic Let a be an integer and m be a positive integer. We denote by.
3.4/3.5 The Integers and Division/ Primes and Greatest Common Divisors Let each of a and b be integers. We say that a divides b, in symbols a | b, provided.
ECON 1150 Matrix Operations Special Matrices
Matrices Square is Good! Copyright © 2014 Curt Hill.
Chapter 3: The Fundamentals: Algorithms, the Integers, and Matrices
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
8.1 Matrices & Systems of Equations
1 C ollege A lgebra Systems and Matrices (Chapter5) 1.
Chapter 4 – Matrix CSNB 143 Discrete Mathematical Structures.
Matrices Matrices A matrix (say MAY-trix) is a rectan- gular array of objects (usually numbers). An m  n (“m by n”) matrix has exactly m horizontal.
Chapter Integers and Algorithms Representations of integers
Chapter 2 (Part 1): The Fundamentals: Algorithms, the Integers & Matrices The Integers and Division (Section 2.4)
Module #9: Matrices Rosen 5 th ed., §2.7 Now we are moving on to matrices, section 7.
Foundations of Discrete Mathematics Chapter 4 By Dr. Dalia M. Gil, Ph.D.
CSCI 171 Presentation 9 Matrix Theory. Matrix – Rectangular array –i th row, j th column, i,j element –Square matrix, diagonal –Diagonal matrix –Equality.
Matrices Section 2.6. Section Summary Definition of a Matrix Matrix Arithmetic Transposes and Powers of Arithmetic Zero-One matrices.
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
CompSci 102 Discrete Math for Computer Science February 7, 2012 Prof. Rodger Slides modified from Rosen.
AF2. Turn off your phones Primes, gcd, some examples, reading.
CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Section 2.4. Section Summary  Sequences. o Examples: Geometric Progression, Arithmetic Progression  Recurrence Relations o Example: Fibonacci Sequence.
Module #9 – Number Theory 6/11/20161 Chapter 3 Algorithms, Integers and Matrices.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
CS 285- Discrete Mathematics Lecture 11. Section 3.8 Matrices Introduction Matrix Arithmetic Transposes and Power of Matrices Zero – One Matrices Boolean.
A very brief introduction to Matrix (Section 2.7) Definitions Some properties Basic matrix operations Zero-One (Boolean) matrices.
Chapter 3 The Fundamentals: Algorithms, the integers, and matrices Section 3.4: The integers and division Number theory: the part of mathematics involving.
Agenda Review:  Relation Properties Lecture Content:  Divisor and Prime Number  Binary, Octal, Hexadecimal Review & Exercise.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
The Euclidean Algorithm
CS 210 Discrete Mathematics The Integers and Division (Section 3.4)
CSE 504 Discrete Mathematics & Foundations of Computer Science
Discrete Structures – CNS2300
CMSC Discrete Structures
CSE 504 Discrete Mathematics & Foundations of Computer Science
Number Theory and Cryptography
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Applied Discrete Mathematics Week 4: Number Theory
Sequences and Summations
Foundations of Discrete Mathematics
Week #5 – 23/25/27 September 2002 Prof. Marie desJardins
CS100: Discrete structures
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Divisibility and Modular Arithmetic
Applied Discrete Mathematics Week 4: Functions
Presentation transcript:

Greatest Common Divisors & Least Common Multiples  Definition 4 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 2

 Definition 5: 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. 3

 Definition 7: 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: and ? Solution: lcm( , ) = 2 max(3,4). 3 max(5,3). 7 max(2,0) =

 Theorem 7: Let a and b be positive integers. Then ab = gcd(a,b).lcm(a.b). 5

Integers & Algorithms  Representations of integers  Theorem 1 Let b be a positive integer grater than 1. Then if n is a positive integer, it can be expressed uniquely in the form n = a k b k + a k-1 b k-1 +…+ a 1 b + a 0, where k is a nonnegative integer, a 0, a 1, …,a k are nonnegative integers less than b, and a k  0. The representation of n given in theorem 1 is known as the base b expansion of n. 6

Integers & Algorithms  Example: What is the decimal expansion of the integer that has ( ) 2 as its binary expansion? Solution: ( ) 2 = 1* * * * * * * * *2 0 = 351 7

Integers & Algorithms  Hexadecimal expansions = base 16 expansion 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F The letters A through F represent the digits corresponding to the number 10 through 15.  Example: What is the decimal expansion of the hexadecimal expansion of (2AE0B) 16 ? Solution: (2AE0B) 16 = 2* * * * *16 0 = (175627) 10 Each hexadecimal digit can be represented using 4 bits. ( ) 2 = (E5) 16 (E 16 = (1110) 2 ; 5 16 = (0101) 2 )  Bytes: bit strings of length 8 represented by two hexadecimal digits. 8

Integers & Algorithms  Representations of integers (cont.)  Base conversion Example: Find the base 8 (or octal) expansion of (12345) 10 Solution: First, divide by = 8 * = 8 * = 8 * = 8 * = 8 *  (12345) 10 = (30071) 8 9

Integers & Algorithms Example: Find the hexadecimal expansion of ( ) 2 and the binary expansion of (A8D) 16. Solution: 1. Form blocks of 4 digits and add zeros at the start of the leftmost block if necessary. They are: 0011, 1110, 1011 and Convert each binary block into decimal (0011) 2 = 3 16 ; (1110) 2 = E 16 ; (1011) 2 = B 16 ; (1100) 2 = C 16 Therefore, ( ) 2 = (3EBC) 16. The conversion of (A8D) 16 into binary notation requires replacing each hexadecimal digit by a block of 4 binary digits. They are: A 16 = (1010) 2, 8 16 = (1000) 2, D 16 = (1101) 2 10

Integers & Algorithms  Algorithms for integer operations  Goal 1: Compute the sum of two integers expressed with their binary expansions. The complexity will be based on the number of bits used. a = (a n-1 a n-2 … a 1 a 0 ) 2, b = (b n-1 b n-2 … b 1 b 0 ) 2 a + b? (sum of two n-bits numbers) First: a 0 + b 0 = c 0 * 2 + s 0 where s 0 = rightmost bit in the binary expansion of a + b c 0 = carry = 0 or 1. Second: a 1 + b 1 + c 0 = c 1 * 2 + s 1 where s 1 = next bit of the sum expansion c 1 = carry … a + b = (s n s n-1 s n-2 … s 1 s 0 ) 2 11

Integers & Algorithms Example: Add a = (1110) 2 and b = (1011) 2 Solution: a 0 + b 0 = = 0 *  c 0 = 0, s 0 = 1 a 1 + b 1 + c 0 = = 1 *  c 1 = 1, s 1 = 0 a 2 + b 2 + c 1 = = 1 *  c 2 = 1, s 2 = 0 a 3 + b 3 + c 2 = = 1 *  c 3 = 1, s 3 = 1  s 4 = c 3 = 1  a + b = (1 1001) = a 1011= b 1 001= c

Integers & Algorithms  Goal 2: Compute the product since b = b n-1 b n-2 …b 1 b 0 then: ab = a (b b … + b n-1 2 n-1 ) = a (b ) + a(b ) + … + a(b n-1 2 n-1 ) Using this latter equation, we can compute a * b. ab j = a if b j = 1 and 0 otherwise. Each time we multiply a term by 2, we shift its binary expansion one place to the left and add a zero at the tail end of the expansion. 13

Integers & Algorithms  Example: Find the product of a = (110) 2 and b = (101) 2 Solution: ab = (110) 2 * 1 * 2 0 = (110) 2 ab = (110) 2 * 0 * 2 1 = (0000) 2 (4 zeros-shift) ab = (110) 2 * 1 * 2 2 = (11000) 2 14 add 2-zero bits

Integers & Algorithms To find the product, we need to perform: (110) 2 + (0000) 2 + (11000) 2 ab = (11110) 2 Other exercise: check for example: 7 * 5 = 35 is true in binary expansion

Integers & Algorithms  The Euclidean algorithm  Goal: Compute the great common divisor (gcd) of two integers avoiding the prime factorization of each number which is time-consuming. 16

Integers & Algorithms  Illustration: Find gcd(91, 287) 1. Divide 287 (the larger) by 91 (the smaller) 287 = 91 *  Any divisor of 91 and 287 must be a divisor of 287 – 91 * 3 =14 (Theorem 1, part 1 & 2)  Any divisor of 91 and 14 divides 287 = 91 *  gcd(91,287) = gcd(91,14) 2. Next divide 91 by 14 to obtain: 91 = 14 * Using the same reasoning, our next step is to: 3. Divide 14 by 7: 14 = 7 * 2 since 7/14  gcd(14,7) = 7. But since gcd(287,91) = gcd(91,14) = gcd (14,7) = 7, we have solved the problem 17

Integers & Algorithms Lemma 1: Let a = bq + r, where a, b, q and r are integers. Then we can write: gcd(a,b) = gcd(b,r)  Example: Determine the gcd of 414 and 662 using the Euclidean algorithm. Solution: 662 = 414 * = 248 * = 166 * = 82 * = 2 * 41 Therefore: gcd(414,662) = 2 (since 2 is the last nonzero remainder !) CSE 504, Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices 18

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices19  Definition 1 A matrix is a rectangular array of numbers. A matrix with m rows and n columns is called an m x n matrix. The plural of matrix is matrices. 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.

20  Definition 2 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.

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices21  Matrix Arithmetic  Definition 3 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:

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices22  Definition 4 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.

23  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 * * * 3 = 7. When all the elements of AB are computed, we see that Matrix multiplication is not commutative.

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices24  Example: Let Does AB = BA? Solution: We find that Hence, AB  BA.

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices25  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?

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices26  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: multiplications. 2) First A 1 A 2 requires 30 * 20 * 40 = multiplications (A 1 A 2 )A 3 requires 30 * 40 * 10 = Total: multiplications.  (1) is more efficient!

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices27  Transposes and power matrices  Definition 5 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

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices28  Definition 6 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.

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices29  Definition 7 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.

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices30  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:

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices31  Definition 8 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.

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices32  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:

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices33  Definition 9 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 ).

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices34  Example: Find the Boolean product of A and B, where Solution:

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices35 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}

CSE 504, Chapter 2 (Part 4): The Fundamentals: Algorithms, the Integers & Matrices36  Definition 10 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.

37  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.

THANK YOU