Chapter Integers and Algorithms Representations of integers

Slides:



Advertisements
Similar presentations
22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
Advertisements

CSE115/ENGR160 Discrete Mathematics 03/13/12 Ming-Hsuan Yang UC Merced 1.
Number Theory and Cryptography
 Instructor: Rob Nash  Readings: Berger, Chapter 1; Rosen, Chapter 3.
Congruence class arithmetic. Definitions: a ≡ b mod m iff a mod m = b mod m. a  [b] iff a ≡ b mod m.
Chapter II. THE INTEGERS
CSE115/ENGR160 Discrete Mathematics 03/17/11 Ming-Hsuan Yang UC Merced 1.
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):
Chapter 4: Elementary Number Theory and Methods of Proof
Chapter 1 1 Number Systems. 2 Objectives  Understand why computers use binary (Base-2) numbering.  Understand how to convert Base-2 numbers to Base-
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
Integers Number Theory = Properties of Integers
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
Module #8: Basic Number Theory
© 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.
Number Systems - Part II
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.
MATH 224 – Discrete Mathematics
Section 4.3: Fermat’s Little Theorem Practice HW (not to hand in) From Barr Text p. 284 # 1, 2.
Chapter 3: The Fundamentals: Algorithms, the Integers, and Matrices
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
Fast Exponentiation (3/31) What is the most efficient way to compute (mod 32591)? We will need an efficient algorithm in order to do “RSA cryptography”,
MAT 320 Spring 2008 Section 1.2.  Start with two integers for which you want to find the GCD. Apply the division algorithm, dividing the smaller number.
Number Theory 이재원 School of Information Technology Sungshin W. University.
If the numerator of a fraction is less than the denominator, the fraction represents a number less than 1 and is called a proper fraction. Improper Fractions,
Foundations of Discrete Mathematics Chapter 4 By Dr. Dalia M. Gil, Ph.D.
이산수학 (Discrete Mathematics) 2.5 정수와 알고리즘 (Integers and Algorithms) 2006 년 봄학기 문양세 강원대학교 컴퓨터과학과.
Cryptography and Network Security Chapter 4. Introduction  will now introduce finite fields  of increasing importance in cryptography AES, Elliptic.
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
Application: Algorithms Lecture 20 Section 3.8 Wed, Feb 21, 2007.
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.
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,
Application: Algorithms Lecture 19 Section 3.8 Tue, Feb 20, 2007.
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.
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.
Fuw-Yi Yang1 Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann Chap 1 Integers Department of Computer Science and Information Engineering,
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
CSE15 Discrete Mathematics 03/15/17
Congruence class arithmetic
Integers and Division Section 3.4.
CMSC Discrete Structures
CSE 102 Introduction to Computer Engineering
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
Modular Arithmetic I Lecture 9: Oct 4.
Number Theory.
Foundations of Discrete Mathematics
Week #5 – 23/25/27 September 2002 Prof. Marie desJardins
Exponential Functions
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Copyright © Zeph Grunschlag,
Application: Algorithms
Application: Algorithms
Divisibility and Modular Arithmetic
Decimal / Binary Conversions
Number Theory.
Number Theory and Cryptography
Presentation transcript:

Chapter 3 3.6 Integers and Algorithms Representations of integers Algorithms for integer operations Modular Exponentiation The Euclidean Algorithm

Representations of integers Theorem 1: Let b be a positive integer greater than 1. Then if n is a positive integer, it can be expressed uniquely in the form where k is a nonnegative integer, a0, a1, …,ak are nonnegative integers less than b, and ak ≠0.

Example 1: What is the decimal expansion of the integer that has (1 0101 1111)2 as its binary expansion? Example 2: What is the decimal expansion of the hexadecimal expansion of (2AE0B)16 ?

Example 3: Find the base 8, or octal, expansion of (12345)10 Example 4: Find the hexadecimal expansion of (177130)10?

Algorithm 1: Construction Base b Expansions procedure base b expansion(n:positive integer) q: = n k: =0 while q ≠ 0 begin ak : =q mod b q: = k: =k+1 end {the base b expansion of n is (ak-1 . . . a1 a0)b}

Algorithms for integer operations Algorithm 2: Addition of Integers Procedure add(a , b:positive integers) {the binary expansions of a and b are (an-1 . . . a1 a0)2 and (bn-1 . . . b1 b0)2 respectively} c : =0 for j: =0 to n-1 Begin d : = sj : = aj+bj+c-2d c : =d end sn:=c {the binary expansion of the sum if (sn sn-1. . . s1 s0)2 }

Algorithms for integer operations Example 7: Add a=(1110)2 and b=(1011)2.

Algorithms for integer operations Algorithm 3 : Multiplying Integers procedure multiply(a, b : positive integers) {the binary expansions of and b are(an-1 . . . a1 a0)2 and (bn-1 . . . b1 b0)2 respectively} for j:=0 to n-1 Begin if bj =1 then cj=a shifted j places else cj:=0 end {c0 c1 . . . cn-1 are the partial products} p :=0 for j:=0 to n-1 p: = p +cj {p is the value of ab}

Algorithms for integer operations Example 9: Find the product of a= (110)2 and b=(101)2

Algorithms for integer operations Algorithm 4 : Computing div and mod procedure division algorithm(a :integers ,d: positive integer) q: =0 r: =|a| while r≧d begin r := r-d q :=q+1 end if a<0 then if r=0 then q:=-q else r := d-r q := -(q+1) {q = a div d is the quotient, r = a mod d is the remainder}

Modular Exponentiation In cryptography it is important to be able to find bn mod m efficiently, where b, n and m and large integers. It’s impractical to first compute bn and then find its remainder when divided by m because bn will be a huge number. Instead, we can use an algorithm that employ expansion of the exponent n , say n = (ak-1 . . . a1 a0)2 . Before we present this algorithm, we illustrate its basic idea. We will explain how to use the binary expansion of n to compute bn .First , note that

Modular Exponentiation To compute bn , we find the values of b, b2,(b2)2=b4, (b4)2=b8, . . . , . We multiply the terms in this list, where aj=1 . This gives us . For example, to compute 311 we first note that 11 = (1011)2, so that 311= 383231. By successively squaring, we find that 32=9, 34=81, 38=6561. Consequently,311=383231=6561*9*3= 177,147

Modular Exponentiation Algorithm 5: Modular Exponentiation procedure modular exponentiation(b:integer , n=(ak-1 . . . a1 a0)2 ,m: positive integer) x: = 1 power := b mod m for i=0 to k-1 begin if ai =1 then x :=(x*power) mod m power :=(power*power) mod m End {x equals bn mod m} Example 11: Use Algorithm 5 to find 3644 mod 645.

The Euclidean Algorithm Lemma 1: Let a=bq+r ,where a, b, q, and r are integers. Then gcd(a,b)=gcd(b,r). Algorithm 6: The Euclidean Algorithm procedure gcd(a.b:integers) x: = a y: = b while y0 begin r := x mod y x := y y := r end {gcd(a,b) is x}

The Euclidean Algorithm Example 12: Find the GCD of 414 and 662 using the Euclidean Algorithm.