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.

Slides:



Advertisements
Similar presentations
Chapter Matrices Matrix Arithmetic
Advertisements

Applied Informatics Štefan BEREŽNÝ
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
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.
CSE115/ENGR160 Discrete Mathematics 03/15/11
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
WHOLE NUMBERS; INTEGERS Whole numbers: Z 0,+ = the natural numbers  {0}. Integers:
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Integers Number Theory = Properties of Integers
© 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
1 Properties of Integers Objectives At the end of this unit, students should be able to: State the division algorithm Apply the division algorithm Find.
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.
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.
MATH 224 – Discrete Mathematics
Chapter 3: The Fundamentals: Algorithms, the Integers, and Matrices
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
Chapter Integers and Algorithms Representations of integers
Number Theory 이재원 School of Information Technology Sungshin W. University.
Chapter 2 (Part 1): The Fundamentals: Algorithms, the Integers & Matrices The Integers and Division (Section 2.4)
CSE 311: Foundations of Computing Fall 2014 Lecture 12: Primes, GCD.
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.
Chapter 2 … part1 Matrices Linear Algebra S 1. Ch2_2 2.1 Addition, Scalar Multiplication, and Multiplication of Matrices Definition A matrix is a rectangular.
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.
Ref: Pfleeger96, Ch.31 Properties of Arithmetic Reference: Pfleeger, Charles P., Security in Computing, 2nd Edition, Prentice Hall, 1996.
CSCI 115 Chapter 1 Fundamentals. CSCI 115 §1.1 Sets and Subsets.
Matrices and Determinants
CSE 311: Foundations of Computing Fall 2013 Lecture 11: Modular arithmetic and applications.
Divisibility and Modular Arithmetic
AF2. Turn off your phones Primes, gcd, some examples, reading.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
Chapter 4 With Question/Answer Animations 1. Chapter Summary Divisibility and Modular Arithmetic - Sec 4.1 – Lecture 16 Integer Representations and 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.
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.
CSE 311 Foundations of Computing I Lecture 12 Modular Arithmetic and Applications Autumn 2012 CSE
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,
CSE15 Discrete Mathematics 03/15/17
Integers and Division Section 3.4.
CMSC Discrete Structures
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
Number Theory.
Foundations of Discrete Mathematics
Week #5 – 23/25/27 September 2002 Prof. Marie desJardins
Modular Arithmetic and Change of Base
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Copyright © Zeph Grunschlag,
Divisibility and Modular Arithmetic
Number Theory.
Presentation transcript:

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 that there exists an integer m for which b=am. Other ways of saying the same thing: –a is a divisor of b –a is a factor of b –b is a multiple of a –a goes evenly into b

Theorem For all integers a, b, and c: 1.If a | b and a | c, then a | (b + c). 2.If a | b then a | bc. 3.If a | b and b | c, then a | c. Corollary: If a | b and a | c, then for all integers m and n we have a | (mb+nc).

Primes A prime is ….

The Fundamental Theorem of Arithmetic Every positive integer is either a prime or can be expressed as a product of primes in a unique way A composite is defined to be a positive integer > 1 which is not a prime.

Divisibility by 3 and 9 Theorem: An integer is divisible by 3 if and only if the sum of the digits in its decimal representation is divisible by 3. Theorem: An integer is divisible by 9 if and only if the sum of the digits in its decimal representation is divisible by 9.

Divisibility by 7 Theorem: A number of the form 10x + y is divisible by 7 if and only if x – 2y is divisible by 7. Examples:

Theorem If n is a composite, then n has a prime divisor less than or equal to Let us use this fact to prove that 197 is prime.

Performing Prime Factorizations Use the above theorem, applied iteratively Example: 980

Theorem There are infinitely many primes

The Sieve of Eratosthenes

The “Division Algorithm” Let a be an integer and d a positive integer. Then there exist unique integers q and r for which (i) a = dq + r, and (ii) 0 ≤ r < d Our symbolism for q is a div d (the quotient), and for r it is a mod d (the remainder).

Greatest Common Divisor and Least Common Multiple

Theorem: Let p be a prime appearing m times in the prime factorization of a and n times in the prime factorization of b. Then (a) p appears times in the prime factorization of gcd(a,b), and (b) p appears times in the prime factorization of lcm(a,b).

Modular Arithmetic Define, for integers a and b and positive integer m, a  b (mod m)  m | (b – a) Theorems: 1. a  b (mod m)  a mod m = b mod m 2. a  b (mod m) 

Theorem If a  b (mod m) and c  d (mod m) then (a) a+c  b+d (mod m), and (b) ac  bd (mod m)

General Principle for Modular Arithmetic When the answer to your computation is to be a “mod m” result, you may discard multiples of m freely as you compute! Note that the remainder mod 9 of any integer is the same as the remainder mod 9 of the sum of its digits. Example: –What is (23459  ) mod 9?

Example Today is On what day of the week will today’s date fall… –Next year? –Ten years from now? When will today’s date next fall on a ?

Definition Two integers a and b are said to be relatively prime provided gcd(a,b) = 1

Theorem For two positive integers a and b, the product gcd(a,b) lcm(a,b) is equal to the product ab.

Does the mod n Function work well as a hashing function? KEYS: Etc. n = 15

Linear Congruential Pseudo- Random Number Generators x n = (ax n-1 + c) mod m Example: m = 2 31 –1, a = 7 5, c = 0 Example: m = 11, a = 5, c = 2, x 0 =3

Theorem: If a and b are positive integers, then gcd(a,b) = gcd(a, b mod a) 3.6 Integers and Algorithms

The Euclidean Algorithm procedure gcd(a, b: positive integers) x := a y := b while y  0 begin r := x mod y x := y y := r end { The gcd of a and b is now stored in the variable x }

Theorem Let b  Z, b > 1. Then any positive integer n can be uniquely expressed as n = a k b k +a k-1 b k-1 +…+a 1 b+a 0 where k is a non-negative integer, and a 0, a 1, …, a k are non-negative integers < b, and a k  0. This is our authority for using the “base b” expansion of the positive integer n, where specific symbols (like the arabic digits) are assigned to the integers a with 0 ≤ a < b and we can write the number n as a k a k-1 a k-2 …a 1 a 0

Examples Binary Octal Decimal Hexadecimal

Converting from Decimal to Binary Example: 190

Conversions Continued Decimal to hexadecimal Decimal to octal

Conversions Continued Hexadecimal to Decimal Octal to Decimal

Conversions Continued Binary to and from Hexadecimal Binary to and from Octal

Conversions Continued Octal to and from Hexadecimal – Just use binary as a go-between

3.8 – Matrices A matrix is a rectangular array of numbers Notation

Special Cases If m = 1 we have a row matrix If n = 1 we have a column matrix Shorthand notation: A = [a ij ]

Matrix Arithmetic Addition and Subtraction Scalar product

Matrix Multiplication If A = [a ij ] and B = [b ij ], where A is an m by n matrix and B is an n by p matrix, then their product AB is the m by p matrix C = [c ij ] whose entries are given by

Example of Matrix Multiplication

Algorithm for Matrix Multiplication procedure multiply(A: m by n matrix, B: n by p matrix) for i:=1 to m do for j:=1 to p do begin c ij = 0 for k:=1 to n do c ij = c ij + a ik b kj end { The matrix [c ij ] is the matrix product of A and B }

Matrix-Chain Multiplication What is the most efficient way to compute a three-way product ABC, where A is m by n, B is n by p, and C is p by q? Grouping as (AB)C, we get mnp + mpq multiplications Grouping as A(BC), we get npq + mnq multiplications Theoretically, the result is the same, so we should choose the order which gives the fewest multiplications. Example: 5 by 3 times 3 by 4 times 4 by 2

The Identity Matrix For any positive integer n, the n by n matrices under matrix multiplication have an identity. It is

Powers of a Square Matrix For an n by n matrix A = [a ij ], we can define A 2 =AA, A 3 =AA 2, etc. Example:

Transpose Matrix For an m by n matrix A = [a ij ], we can define the transpose A t of A to be the n by m matrix whose rows are the columns of A and whose columns are the rows of A. i.e. if B = [b ij ] is A’s transpose, then for all relevant values of i and j, b ij = a ji Example:

Symmetric Matrices A square matrix A is said to be symmetric if A = A t

Zero-One Matrices

Zero-One Matrix Multiplication

Examples

Zero-One Matrix Powers Example:

Inverses