Module #9 – Number Theory 6/11/20161 Chapter 3 Algorithms, Integers and Matrices.

Slides:



Advertisements
Similar presentations
Chapter Matrices Matrix Arithmetic
Advertisements

The Integers and Division. Outline Division: Factors, multiples Exercise 2.3 Primes: The Fundamental Theorem of Arithmetic. The Division Algorithm Greatest.
1 Section 2.4 The Integers and Division. 2 Number Theory Branch of mathematics that includes (among other things): –divisibility –greatest common divisor.
February 19, 2015Applied Discrete Mathematics Week 4: Number Theory 1 The Growth of Functions Question: If f(x) is O(x 2 ), is it also O(x 3 )? Yes. x.
CSE115/ENGR160 Discrete Mathematics 03/13/12 Ming-Hsuan Yang UC Merced 1.
Number Theory and Cryptography
1 Matrices Rosen 6 th ed., §3.8 2 Matrices A matrix is a rectangular array of numbers.A matrix is a rectangular array of numbers. An m  n (“m by n”)
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
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.
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.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Integers Number Theory = Properties of Integers
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
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 3): The Fundamentals: Algorithms, the.
Mathematics of Cryptography Part I: Modular Arithmetic
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.
Chapter 3: The Fundamentals: Algorithms, the Integers, and Matrices
2015 년 봄학기 강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics) 행렬 (Matrices)
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
Copyright © Zeph Grunschlag, Basic Number Theory Zeph Grunschlag.
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/21 Module.
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.
2009/9 1 Matrices(§3.8)  A matrix is a rectangular array of objects (usually numbers).  An m  n (“m by n”) matrix has exactly m horizontal rows, and.
Copyright © 2009 Pearson Education, Inc. Chapter 5 Section 1 - Slide 1 Chapter 1 Number Theory and the Real Number System.
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.
Discrete Mathematics 1 Kemal Akkaya DISCRETE MATHEMATICS Lecture 16 Dr. Kemal Akkaya Department of Computer Science.
Foundations of Discrete Mathematics Chapter 4 By Dr. Dalia M. Gil, Ph.D.
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.
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.
Matrices and Determinants
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.
Chapter 4 With Question/Answer Animations 1. Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
Discrete Mathematics Chapter 2 The Fundamentals : Algorithms, the Integers, and Matrices. 大葉大學 資訊工程系 黃鈴玲.
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,
CS 210 Discrete Mathematics The Integers and Division (Section 3.4)
CSE 504 Discrete Mathematics & Foundations of Computer Science
CSE15 Discrete Mathematics 03/15/17
Integers and Division Section 3.4.
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 3: Algorithms
Applied Discrete Mathematics Week 4: Number Theory
Applied Discrete Mathematics Week 4: Number Theory
Rosen 5th ed., §2.7 ~18 slides, ~1 lecture
Foundations of Discrete Mathematics
Enough Mathematical Appetizers!
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Copyright © Zeph Grunschlag,
Divisibility and Modular Arithmetic
Discrete Mathematics and its Applications
Rosen 5th ed., §2.7 ~18 slides, ~1 lecture
Number Theory.
Module #9: Basic Number Theory
Presentation transcript:

Module #9 – Number Theory 6/11/20161 Chapter 3 Algorithms, Integers and Matrices

Module #9 – Number Theory 6/11/20162 Section 3.4: The Integers and Division DivisionDivision Let a,b  Z with a  0.Let a,b  Z with a  0. a|b  “a divides b” :  “  c  Z: b=ac” So: a is a factor or a divisor of b, and b is a multiple of a.a|b  “a divides b” :  “  c  Z: b=ac” So: a is a factor or a divisor of b, and b is a multiple of a. a doesn’t divide b is denoted by a | b.a doesn’t divide b is denoted by a | b. –Example: 3   12  True, but 3  7  False.

Module #9 – Number Theory 6/11/20163 Facts: the Divides Relation  a,b,c  Z:  a,b,c  Z: 1. (a|b  a|c)  a | (b + c) 1. (a|b  a|c)  a | (b + c) 2. a|b  a|bc 3. (a|b  b|c)  a|c Examples: 1. 3  12  3  9  3  (12+9)  3  21 (21 ÷ 3=7) 1. 3  12  3  9  3  (12+9)  3  21 (21 ÷ 3=7) 2. 2  6  2  (6×3)  2  18 (18 ÷2= 9) 2. 2  6  2  (6×3)  2  18 (18 ÷2= 9) 3. 4  8  8  64  4  64 (64 ÷ 4 = 16 ) 3. 4  8  8  64  4  64 (64 ÷ 4 = 16 )

Module #9 – Number Theory 6/11/20164 Composite and Prime Numbers A positive integer p>1 is prime if the only positive factors of p are 1 and pA positive integer p>1 is prime if the only positive factors of p are 1 and p ☻ Some primes: 2,3,5,7,11,13... Non-prime integers greater than 1 are called composite, because they can be composed by multiplying two integers greater than 1.Non-prime integers greater than 1 are called composite, because they can be composed by multiplying two integers greater than 1.

Module #9 – Number Theory 6/11/20165 Fundamental Theorem of Arithmetic Every positive integer greater than 1 has a unique representation as a prime or as the product of two or more primes where the prime factors are written in order of non- decreasing size. (tree or division)Every positive integer greater than 1 has a unique representation as a prime or as the product of two or more primes where the prime factors are written in order of non- decreasing size. (tree or division) 100 = 2·2·5·5= = 2·2·5·5= = = = 2·2·2·2·2·2·2·2·2·2=2 10

Module #9 – Number Theory 6/11/20166 Theorem If n is composite integer, then n has prime divisorIf n is composite integer, then n has prime divisor ≤ Ex: 49  prime numbers less than are 2,3,5,7Ex: 49  prime numbers less than are 2,3,5,7 16  prime numbers less than are 2,3 16  prime numbers less than are 2,3 An integer n is prime if it is not divisible by any prime ≤An integer n is prime if it is not divisible by any prime ≤ Ex: 13 where = 3.6 so the prime numbers are 2,3 but non of them divides 13 so 13 is primeEx: 13 where = 3.6 so the prime numbers are 2,3 but non of them divides 13 so 13 is prime

Module #9 – Number Theory 6/11/20167 To find the prime factor of an integer n:To find the prime factor of an integer n: 1- find 2- list all primes ≤ 2, 3, 5, 7,…root of n 2, 3, 5, 7,…root of n 3- find all prime factors that divides n.

Module #9 – Number Theory 6/11/20168

Module #9 – Number Theory 6/11/20169 The Division “Algorithm” let a be an integer and d a positive integer, then there are unique integers q and r such that:a = d × q + r, 0  r < dlet a be an integer and d a positive integer, then there are unique integers q and r such that:a = d × q + r, 0  r < d d is called divisor, and a is called dividendd is called divisor, and a is called dividend q is the quotient, and r is the remainder (positive integer)q is the quotient, and r is the remainder (positive integer)  q = a div d, r =a mod d

Module #9 – Number Theory 6/11/ Examples What are the quotient and remainder when 101 is divided by 11?What are the quotient and remainder when 101 is divided by 11? 101 = 11 × 9 + 2, q = 9, r = = 11 × 9 + 2, q = 9, r = 2 What are the quotient and the remainder when -11 is divided by 3?What are the quotient and the remainder when -11 is divided by 3? -11 = 3 × (-4) + 1,q = -4, r = 1-11 = 3 × (-4) + 1,q = -4, r = 1 Note: -11  3 × (-3) - 2 because r  0 (can't be negative)Note: -11  3 × (-3) - 2 because r  0 (can't be negative)

Module #9 – Number Theory 6/11/ Modular Congruence Let a, b  Z, m  Z +. Thm: a is congruent to b modulo m a is congruent to b modulo m written “a  b (mod m)”, iff 1) a mod m = b mod m 1) a mod m = b mod m 2) m | a  b i.e. (a  b) mod m = 0. 2) m | a  b i.e. (a  b) mod m = 0.

Module #9 – Number Theory 6/11/ Examples Is 17 congruent to 5 modulo 6 ? 17 mod 6 = 5 and5 mod 6 = 5 17 mod 6 = 5 and5 mod 6 = 5 and 6 | (17-5)  6 | 12 where 12 ÷ 6 = 2 Then 17 ≡ 5 (mod 6) Is 24 congruent to 14 modulo 6? Since, 24 mod 6 = 0 and14 mod 6 = 2 Then, 24 ≡ 14 (mod 6) and 6 | (24-14)  6 | 10

Module #9 – Number Theory 6/11/ Useful Congruence Theorems Let a,b,c,d  Z, m  Z +. Then if a  b (mod m) and c  d (mod m), then:Let a,b,c,d  Z, m  Z +. Then if a  b (mod m) and c  d (mod m), then: ▪ a+c  b+d (mod m), and ▪ ac  bd (mod m)

Module #9 – Number Theory 6/11/ Ex. : let 7 ≡ 2 (mod 5) and let 7 ≡ 2 (mod 5) and 11 ≡ 1 (mod 5) 11 ≡ 1 (mod 5)Then: (7 + 11) ≡ (2 + 1) (mod 5)  18 ≡ 3 (mod 5) (7 + 11) ≡ (2 + 1) (mod 5)  18 ≡ 3 (mod 5) and and ( 7 × 11) ≡ (2 × 1) (mod 5)  77 ≡ 2 (mod 5) ( 7 × 11) ≡ (2 × 1) (mod 5)  77 ≡ 2 (mod 5)

Module #9 – Number Theory 6/11/ Greatest Common Divisor (GCD) The greatest common divisor gcd(a,b) of integers a,b (not both 0) is the largest (most positive) integer d that is a divisor both of a and of b.The greatest common divisor gcd(a,b) of integers a,b (not both 0) is the largest (most positive) integer d that is a divisor both of a and of b.

Module #9 – Number Theory 6/11/ Ways to find GCD 1.find all positive common divisors of both a and b, then take the largest divisor Ex: find gcd (24, 36)? Divisors of 24: 1, 2, 3, 4, 6, 8, 12, 24 Divisors of 36: 1, 2, 3, 4, 6, 9, 12, 18,36 Common divisors: 1, 2, 3, 4, 6, 12 MAXIMUM = 12  gcd (24, 36) = 12

Module #9 – Number Theory 6/11/ use prime factorization: Take the min power of common factors Take the min power of common factorsExample Find gcd (24, 36) Find gcd (24, 36) 24 = 2 × 2 × 2 × 3 = 2 3 × 3 24 = 2 × 2 × 2 × 3 = 2 3 × 3 36 = 2 × 2 × 3 × 3 = 2 2 × = 2 × 2 × 3 × 3 = 2 2 × 3 2 gcd(24,36) = 2 2 × 3=12 gcd(24,36) = 2 2 × 3=12

Module #9 – Number Theory 6/11/ Ex: find gcd (120, 500)? Ex: find gcd (120, 500)? 120 = 2 3 × 3 × = 2 2 × 5 3  gcd (120, 500) = 2 2 × 5 = 20 Ex: find gcd (17, 22)? No common divisors so gcd (17, 22) = 1 so, the numbers 17 and 22 are called relatively prime.

Module #9 – Number Theory 6/11/ Least Common Multiple lcm(a,b) of positive integers a, b, is the smallest positive integer that is a multiple both of a and of b.lcm(a,b) of positive integers a, b, is the smallest positive integer that is a multiple both of a and of b.

Module #9 – Number Theory 6/11/ Find lcm(6,10) ? Take the max power of all Factors 6 = 2×3 10 = 2×5 10 = 2×5 Lcm(6,10) = 2×3×5=30 Lcm(6,10) = 2×3×5=30 Find Lcm (24, 36)? 24 = 2 3 × = 2 2 × 3 2  Lcm (24, 36) = 2 3 × 3 2 = 72

Module #9 – Number Theory 6/11/ Section 3.1: Algorithms A finite set of instructions for performing a computation or for solving a problemA finite set of instructions for performing a computation or for solving a problemExamples: -Finding the largest integer in a finite sequence of integers -Locating an element in a finite set -Sorting elements in a finite sequence

Module #9 – Number Theory 6/11/ Finding the maximum element procedure max(a 1,a 2,……..,a n : integers) max:=a 1 for i:=2 to n if max<a i then max:=a i if max<a i then max:=a i {max is the largest element}

Module #9 – Number Theory 6/11/ Linear Search Algorithm procedure linearsearch (x:integer, a 1,a 2,..,a n :integers) i:=1 While(i≤n and x ≠ a i ) i = i+1 i = i+1 If i ≤ n then location:= i else location:= 0 {location is the subscript of the term that equals x or the location is 0 if x is not found }

Module #9 – Number Theory 6/11/ Bubble Sort Algorithm procedure bubblesort(a 1,a 2,…..,a n ) for i:=1 to n-1 for j:=1 to n-i for j:=1 to n-i if a j > a j+1 then interchange a j and a j+1 if a j > a j+1 then interchange a j and a j+1 {a1,…..,an is in increasing order}

Module #9 – Number Theory 3.6 Integers and Algorithms Introduction: The term algorithm originally referred to procedures for performing arithmetic operations using the decimal representations of integers. These algorithms, adapted for use with binary representations, are the basis for computer arithmetic. 6/11/201625

Module #9 – Number Theory There are many important algorithms involving integers besides those used in arithmetic, We will describe an algorithm for finding the base b expansion of a positive integer for any base b. 26

Module #9 – Number Theory Representations of Integers In everyday life we use decimal notation to In everyday life we use decimal notation to express integers. express integers. For example, 965 is used to Denote 9· · · · However, it is often convenient to use bases other than

Module #9 – Number Theory Computers usually use binary notation Computers usually use binary notation (with 2 as the base) when carrying out arithmetic, (with 2 as the base) when carrying out arithmetic, and octal (base 8) or hexadecimal (base 16) and octal (base 8) or hexadecimal (base 16) notation when expressing characters, such as notation when expressing characters, such as letters or digits. In fact, we can use any letters or digits. In fact, we can use any positive integer greater than 1 as the base positive integer greater than 1 as the base when expressing integers. when expressing integers. 6/11/201628

Module #9 – Number Theory BINARY EXPANSIONS What is the decimal expansion of the integer that has (l ) 2 as its binary expansion? Solution: We have (l l) 2 = 1 · · · · · · · · · · · · · 2 0 = 351. = /11/201629

Module #9 – Number Theory HEXADECIMAL EXPANSIONS Sixteen is another base used in computer science. The base 16 expansion of an integer is called its hexadecimal expansion. hexadecimal digits used are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F, where the letters A through F represent the digits corresponding to the numbers 10 through 15 (in decimal notation). (in decimal notation). 6/11/201630

Module #9 – Number Theory 6/11/ EXAMPLE 2 What is the decimal expansion of the hexadecimal expansion of (2AE0B) 16 ? Solution: We have (2AE0B) 16 = · = ( ) 10. = ( ) 10.

Module #9 – Number Theory EXAMPLE 1: Find the binary expansion of (241) 10 Solution: First divide 241 by 2 to obtain 241 = Successively dividing quotients by 2 gives 120 = 2 · = 2 · = 2 · = 2 · = 2 · = 2 · = 2 · = 2 · = 2 · Therefore, (241) 10 = ( ) 2 1 = 2 · Therefore, (241) 10 = ( ) 2 6/11/ BASE CONVERSION

Module #9 – Number Theory EXAMPLE 2 : Find the base 8 expansion of (12345) 10 Solution: First, divide l2345 by 8 to obtain = = Successively dividing quotients by 8 gives: 1543 = , 1543 = , 192 = 8 · , 192 = 8 · , 24 = 8 · 3 + 0, 24 = 8 · 3 + 0, 3 = 8 · = 8 · Therefore, (12345) 10 = ( ) 8. 6/11/201633

Module #9 – Number Theory EXAMPLE 4 Find the hexadecimal expansion of (177130) 10 Solution: = 16 · = 16 · = 16 · , = 16 · , 691 = 16 · , 691 = 16 · , 43 = 16 · , 43 = 16 · , 2 = 16 · = 16 · Therefore, ( ) 10 = (2B3EA) 16 ( ) 10 = (2B3EA) 16 6/11/201634

Module #9 – Number Theory 6/11/ Section 3.8: Matrices A matrix is a rectangular array of objects (usually numbers). An m  n matrix has exactly m rows, and n columns. m rows, and n columns. An n  n matrix is called a square matrix, whose order is n. 3  2  2 2  2

Module #9 – Number Theory 6/11/ Matrix Equality Two matrices A and B are equal iff they have the same number of rows, the same number of columns, and all corresponding elements are equal.Two matrices A and B are equal iff they have the same number of rows, the same number of columns, and all corresponding elements are equal.

Module #9 – Number Theory 6/11/ Row and Column Order The rows in a matrix are usually indexed 1 to m from top to bottom. The columns are usually indexed 1 to n from left to right. Elements are indexed by row, then column.The rows in a matrix are usually indexed 1 to m from top to bottom. The columns are usually indexed 1 to n from left to right. Elements are indexed by row, then column.

Module #9 – Number Theory 6/11/ Matrix Sums The sum A+B of two matrices A, B (which must have the same number of rows, and the same number of columns) is the matrix given by adding corresponding elements.The sum A+B of two matrices A, B (which must have the same number of rows, and the same number of columns) is the matrix given by adding corresponding elements. A+B = [a i,j +b i,j ]A+B = [a i,j +b i,j ]

Module #9 – Number Theory 6/11/ Matrix Products For an m  k matrix A and a k  n matrix B, the product AB is the m  n matrix: product AB is the m  n matrix: I.e., element (i, j ) of AB is given by the vector dot product of the i th row of A and the j th column of B (considered as vectors). (considered as vectors). Note: Matrix multiplication is not commutative!

Module #9 – Number Theory 6/11/ Matrix Product Example An example matrix multiplication to practice in class:An example matrix multiplication to practice in class: 2×3 ×4 3×4 ×4 2×4

Module #9 – Number Theory 6/11/ Identity Matrices The identity matrix of order n, I n, is the order-n matrix with 1’s along the upper-left to lower-right diagonal and 0’s everywhere else. A I n = AThe identity matrix of order n, I n, is the order-n matrix with 1’s along the upper-left to lower-right diagonal and 0’s everywhere else. A I n = A

Module #9 – Number Theory 6/11/ Powers of Matrices If A is an n  n square matrix and p  0, then: A p  AAA···A (A 0  I n )A p  AAA···A (A 0  I n ) Example:Example: p times

Module #9 – Number Theory 6/11/ If A is an m  n matrix, the transpose of A is the n  m matrix given by A tIf A is an m  n matrix, the transpose of A is the n  m matrix given by A t Matrix Transposition

Module #9 – Number Theory 6/11/ Symmetric Matrices A square matrix A is symmetric iff A=A t.A square matrix A is symmetric iff A=A t. Which is symmetric?Which is symmetric? A B C A B C

Module #9 – Number Theory 6/11/ Zero-One Matrices All elements of a zero-one matrix are 0 or 1 –Representing False & True respectively. The join of A, B (both m  n zero-one matrices):The join of A, B (both m  n zero-one matrices): A  B :  [a ij  b ij ] The meet of A, B:The meet of A, B: A  B :  [a ij  b ij ]

Module #9 – Number Theory 6/11/ Example A = B= A = B= We find the join between A  B = We find the meet between A  B =

Module #9 – Number Theory 6/11/ Boolean Products Let A be an m  k zero-one matrix, Let B be a k  n zero-one matrix,Let A be an m  k zero-one matrix, Let B be a k  n zero-one matrix, The Boolean product of A and B is like normal matrix product, But using  instead +The Boolean product of A and B is like normal matrix product, But using  instead + And using instead  And using instead  A⊙BA⊙B

Module #9 – Number Theory 6/11/ Boolean Powers For a square zero-one matrix A, and any k  0, the kth Boolean power of A is simply the Boolean product of k copies of A.For a square zero-one matrix A, and any k  0, the kth Boolean power of A is simply the Boolean product of k copies of A. A [k]  A ⊙ A ⊙ … ⊙ AA [k]  A ⊙ A ⊙ … ⊙ A k times

Module #9 – Number Theory 6/11/ Example A = B=A = B= A ⊙ B=

Module #9 – Number Theory 6/11/ ThenThen