Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices. Integers & Algorithms (2.5)

Similar documents
Ch 4.2 Divisibility Properties

3 The fundamentals: Algorithms, the integers, and matrices

Discrete Mathematics GCD, LCM, RSA Algorithm

4 Number Theory and Cryptography

Mat Week 8. Week 8. gcd() Mat Bases. Integers & Computers. Linear Combos. Week 8. Induction Proofs. Fall 2013

Student Responsibilities Week 8. Mat Section 3.6 Integers and Algorithms. Algorithm to Find gcd()

With Question/Answer Animations. Chapter 4

MATH Dr. Halimah Alshehri Dr. Halimah Alshehri

2.5 정수와알고리즘 (Integers and Algorithms)

Base-b representations of integers. (b 진법표현 ) Algorithms for computer arithmetic: Euclidean algorithm for finding GCD s.

CSE 20 DISCRETE MATH. Fall

The set of integers will be denoted by Z = {, -3, -2, -1, 0, 1, 2, 3, 4, }

COT 3100 Applications of Discrete Structures Dr. Michael P. Frank

CSE 20 DISCRETE MATH. Winter

Number Theory and Cryptography

Section Summary. Division Division Algorithm Modular Arithmetic

ICS141: Discrete Mathematics for Computer Science I

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications

Numbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary.

ENGIN 112 Intro to Electrical and Computer Engineering

Notes. Number Theory: Applications. Notes. Number Theory: Applications. Notes. Hash Functions I

Numbers. Çetin Kaya Koç Winter / 18

COMP239: Mathematics for Computer Science II. Prof. Chadi Assi EV7.635

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

Number Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers

Conversions between Decimal and Binary

The Euclidean Algorithm and Multiplicative Inverses

not to be republished NCERT REAL NUMBERS CHAPTER 1 (A) Main Concepts and Results

Chapter 4 Finite Fields

1 Computing System 2. 2 Data Representation Number Systems 22

A field F is a set of numbers that includes the two numbers 0 and 1 and satisfies the properties:

0,..., r 1 = digits in radix r number system, that is 0 d i r 1 where m i n 1

a the relation arb is defined if and only if = 2 k, k

Math.3336: Discrete Mathematics. Primes and Greatest Common Divisors

14:332:231 DIGITAL LOGIC DESIGN. Why Binary Number System?

Number Theory: Representations of Integers

EE260: Digital Design, Spring n Digital Computers. n Number Systems. n Representations. n Conversions. n Arithmetic Operations.

Basic elements of number theory

Basic elements of number theory

Chapter 9 - Number Systems

Number Theory and Divisibility

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications

Number theory (Chapter 4)

Applied Cryptography and Computer Security CSE 664 Spring 2017

Chapter 1. Greatest common divisor. 1.1 The division theorem. In the beginning, there are the natural numbers 0, 1, 2, 3, 4,...,

MAT 243 Test 2 SOLUTIONS, FORM A

ECE380 Digital Logic. Positional representation

This is a recursive algorithm. The procedure is guaranteed to terminate, since the second argument decreases each time.

CSE 20 DISCRETE MATH. Fall

4 Powers of an Element; Cyclic Groups

ENGIN 112 Intro to Electrical and Computer Engineering

1. (16 points) Circle T if the corresponding statement is True or F if it is False.

CSE 20: Discrete Mathematics

CHAPTER 1 REAL NUMBERS KEY POINTS

Finite Fields. Mike Reiter

CSE 311: Foundations of Computing. Lecture 12: Two s Complement, Primes, GCD

Multi-Exponentiation Algorithm

Number Theory Basics Z = {..., 2, 1, 0, 1, 2,...} For, b Z, we say that divides b if z = b for some. Notation: b Fact: for all, b, c Z:

Basic Concepts in Number Theory and Finite Fields

NUMBERS AND CODES CHAPTER Numbers

and LCM (a, b, c) LCM ( a, b) LCM ( b, c) LCM ( a, c)

8 Primes and Modular Arithmetic

Mathematical Induction

Number Bases. Ioan Despi. University of New England. August 4, 2013

Four Important Number Systems

Exercises Exercises. 2. Determine whether each of these integers is prime. a) 21. b) 29. c) 71. d) 97. e) 111. f) 143. a) 19. b) 27. c) 93.

Part I, Number Systems. CS131 Mathematics for Computer Scientists II Note 1 INTEGERS

CS220/MATH320 Applied Discrete Math Fall 2018 Instructor: Marc Pomplun. Assignment #3. Sample Solutions

Introduction to Information Security

ECE260: Fundamentals of Computer Engineering

Solutions to Assignment 1

Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations

Introduction Integers. Discrete Mathematics Andrei Bulatov

REVIEW Chapter 1 The Real Number System

Number Theory Proof Portfolio

Introduction CSE 541

CIS 6930/4930 Computer and Network Security. Topic 5.1 Basic Number Theory -- Foundation of Public Key Cryptography

Outline. Some Review: Divisors. Common Divisors. Primes and Factors. b divides a (or b is a divisor of a) if a = mb for some m

Outline. AIT 682: Network and Systems Security. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

CSE 241 Digital Systems Spring 2013

Number Theory. Modular Arithmetic

CSC 474 Network Security. Outline. GCD and Euclid s Algorithm. GCD and Euclid s Algorithm Modulo Arithmetic Modular Exponentiation Discrete Logarithms

Security II: Cryptography exercises

CISC-102 Winter 2016 Lecture 11 Greatest Common Divisor

Intermediate Math Circles February 26, 2014 Diophantine Equations I

CISC 1400 Discrete Structures

Standard forms for writing numbers

Chapter 5. Number Theory. 5.1 Base b representations

For your quiz in recitation this week, refer to these exercise generators:

Chapter 3: The Euclidean Algorithm and Diophantine. Math 138 Burger California State University, Fresno

W3203 Discrete Mathema1cs. Number Theory. Spring 2015 Instructor: Ilia Vovsha. hcp://

Finite Fields. SOLUTIONS Network Coding - Prof. Frank H.P. Fitzek

Algebra for error control codes

Induction and recursion. Chapter 5

Lecture 2. The Euclidean Algorithm and Numbers in Other Bases

The Fundamental Theorem of Arithmetic

CSE 20 DISCRETE MATH. Winter

Lecture 7 Number Theory Euiseong Seo

Logic gates. Quantum logic gates. α β 0 1 X = 1 0. Quantum NOT gate (X gate) Classical NOT gate NOT A. Matrix form representation

17.1 Binary Codes Normal numbers we use are in base 10, which are called decimal numbers. Each digit can be 10 possible numbers: 0, 1, 2, 9.

Transcription:

CSE 54 Discrete Mathematics & Chapter 2 (Part 3): The Fundamentals: Algorithms, the Integers & Matrices Integers & Algorithms (Section 2.5) by Kenneth H. Rosen, Discrete Mathematics & its Applications, Fifth Edition, Mc Graw-Hill, 23 Integers & Algorithms (2.5) Introduction Algorithm is a set a procedures that handle arithmetic operations Use binary representations to enter the world of computer arithmetic Good illustration of the complexity of an algorithm Role of the Euclidean algorithm Base b expansion and modular exponentiation, important in cryptography Ch. 2 (Part 3) Section 2.5

CSE 54 Discrete Mathematics & Representations of integers Theorem Let b be a positive integer grater than. Then if n is a positive integer, it can be expressed uniquely in the form n = a k b k + a k- b k- + + a b + a, where k is a nonnegative integer, a, a,,a k are nonnegative integers less than b, and a k. The representation of n given in theorem is known as the base b expansion of n. Example: What is the decimal expansion of the integer that has ( ) 2 as its binary expansion? ( ) 2 = *2 8 + *2 7 + *2 6 + *2 5 + *2 4 + *2 3 + *2 2 + *2 + *2 = 35 Ch. 2 (Part 3) Section 2.5 2

CSE 54 Discrete Mathematics & Hexadecimal expansions = base 6 expansion,,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 through 5. Example: What is the decimal expansion of the hexadecimal expansion of (2AEB) 6? (2AEB) 6 = 2*6 4 + *6 3 + 4*6 2 + *6 + *6 = (75627) Each hexadecimal digit can be represented using 4 bits. ( ) 2 = (E5) 6 (E 6 = () 2 ; 5 6 = () 2 ) Bytes: bit strings of length 8 represented by two hexadecimal digits. Representations of integers (cont.) Base conversion Example: Find the base 8 (or octal) expansion of (2345) First, divide 2345 by 8. 2345 = 8 * 543 + 543 = 8 * 92 + 7 92 = 8 * 24 + 24 = 8 * 3 + 3 = 8 * + 3 (2345) = (37) 8 Ch. 2 (Part 3) Section 2.5 3

CSE 54 Discrete Mathematics & Example: Find the hexadecimal expansion of ( ) 2 and the binary expansion of (A8D) 6.. Form blocks of 4 digits and add zeros at the start of the leftmost block if necessary. They are:,, and. 2. Convert each binary block into decimal () 2 = 3 6 ; () 2 = E 6 ; () 2 = B 6 ; () 2 = C 6 Therefore, ( ) 2 = (3EBC) 6. The conversion of (A8D) 6 into binary notation requires replacing each hexadecimal digit by a block of 4 binary digits. They are: A 6 = () 2, 8 6 = () 2, D 6 = () 2 Algorithms for integer operations Goal : 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- a n-2 a a ) 2, b = (b n- b n-2 b b ) 2 a + b? (sum of two n-bits numbers) First: a + b = c * 2 + s where s = rightmost bit in the binary expansion of a + b c = carry = or. Second: a + b + c = c * 2 + s where s = next bit of the sum expansion c = carry a + b = (s n s n- s n-2 s s ) 2 Ch. 2 (Part 3) Section 2.5 4

CSE 54 Discrete Mathematics & Example: Add a = () 2 and b = () 2 a + b = + = * 2 + c =, s = a + b + c = + + = * 2 + c =, s = a 2 + b 2 + c = + + = * 2 + c 2 =, s 2 = a 3 + b 3 + c 2 = + + = * 2 + c 3 =, s 3 = s 4 = c 3 = a + b = ( ) 2 = a = b = c Goal 2: Compute the product since b = b n- b n-2 b b then: ab = a (b 2 + b 2 + + b n- 2 n- ) = a (b 2 ) + a(b 2 ) + + a(b n- 2 n- ) Using this latter equation, we can compute a * b. ab j = a if b j = and 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. Ch. 2 (Part 3) Section 2.5 5

CSE 54 Discrete Mathematics & Example: Find the product of a = () 2 and b = () 2 ab 2 = () 2 * * 2 = () 2 ab 2 = () 2 * * 2 = () 2 (4 zeros-shift) ab 2 2 2 = () 2 * * 2 2 = () 2 add 2-zero bits To find the product, we need to perform: () 2 + () 2 + () 2 ab = () 2 Other exercise: check for example: 7 * 5 = 35 is true in binary expansion. Ch. 2 (Part 3) Section 2.5 6

CSE 54 Discrete Mathematics & The Euclidean algorithm Goal: Compute the great common divisor (gcd) of two integers avoiding the prime factorization of each number which is time-consuming. Illustration: Find gcd(9, 287). Divide 287 (the larger) by 9 (the smaller) 287 = 9 * 3 + 4 Any divisor of 9 and 287 must be a divisor of 287 9 * 3 =4 (Theorem, part & 2) Any divisor of 9 and 4 divides 287 = 9 * 3 + 4 gcd(9,287) = gcd(9,4) 2. Next divide 9 by 4 to obtain: 9 = 4 * 6 + 7 Using the same reasoning, our next step is to: 3. Divide 4 by 7: 4 = 7 * 2 since 7/4 gcd(4,7) = 7. But since gcd(287,9) = gcd(9,4) = gcd (4,7) = 7, we have solved the problem Ch. 2 (Part 3) Section 2.5 7

CSE 54 Discrete Mathematics & Lemma : 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 44 and 662 using the Euclidean algorithm. 662 = 44 * + 248 44 = 248 * + 66 248 = 66 * + 82 66 = 82 * 2 + 2 82 = 2 * 4 Therefore: gcd(44,662) = 2 (since 2 is the last nonzero remainder!) Ch. 2 (Part 3) Section 2.5 8