1 Chapter 2 - 1 Facts about Functions. 2 Section 2.1 Functions: Definitions and Examples A function ƒ from A to B associates each element of A with exactly.

Slides:



Advertisements
Similar presentations
1.6 Functions. Chapter 1, section 6 Functions notation: f: A B x in A, y in B, f(x) = y. concepts: –domain of f, –codomain of f, –range of f, –f maps.
Advertisements

Relations Relations on a Set. Properties of Relations.
Cryptography and Network Security
Section 4.1: Primes, Factorization, and the Euclidean Algorithm Practice HW (not to hand in) From Barr Text p. 160 # 6, 7, 8, 11, 12, 13.
Number Theory and Cryptography
Factors, Fractions, and Exponents
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
Section Section Summary Recursive Algorithms Proving Recursive Algorithms Correct Recursion and Iteration (not yet included in overheads) Merge.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Proofs, Recursion, and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
1 Section 1.8 Functions. 2 Loose Definition Mapping of each element of one set onto some element of another set –each element of 1st set must map to something,
Functions.
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Divisibility October 8, Divisibility If a and b are integers and a  0, then the statement that a divides b means that there is an integer c such.
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
1 Section 2.3 Properties of Functions Let ƒ : A  B be a function. There are three properties that ƒ might possess. Injective (also called one-to-one):
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.
1 Section 10.1 What Is an Algebra? To most people the word algebra means high school algebra. But there are many kinds of algebra. An algebra consists.
2.1 Sets 2.2 Set Operations 2.3 Functions ‒Functions ‒ Injections, Surjections and Bijections ‒ Inverse Functions ‒Composition 2.4 Sequences and Summations.
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
1 Chapter Facts about Functions. 2 Section 2.3 Properties of Functions Let ƒ : A → B be a function. There are three properties that ƒ might possess.
The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
Copyright © Zeph Grunschlag, Basic Number Theory Zeph Grunschlag.
MSU/CSE 260 Fall Functions Read Section 1.8.
1 Section 2.1 Functions: Definitions and Examples A function ƒ from A to B associates each element of A with exactly one element of B. Write ƒ : A  B.
Functions1 Elementary Discrete Mathematics Jim Skon.
CompSci 102 Discrete Math for Computer Science January 31, 2012 Prof. Rodger Slides modified from Rosen AB a b c d x y z.
MT263F Discrete Structures Li Tak Sing ( 李德成 ) Lectures
Rational Numbers and Fields
Copyright © 2009 Pearson Education, Inc. Chapter 5 Section 1 - Slide 1 Chapter 1 Number Theory and the Real Number System.
Functions. L62 Agenda Section 1.8: Functions Domain, co-domain, range Image, pre-image One-to-one, onto, bijective, inverse Functional composition and.
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.
Information Security Lab. Dept. of Computer Engineering 87/121 PART I Symmetric Ciphers CHAPTER 4 Finite Fields 4.1 Groups, Rings, and Fields 4.2 Modular.
Foundations of Discrete Mathematics Chapter 4 By Dr. Dalia M. Gil, Ph.D.
1 Section Congruences In short, a congruence relation is an equivalence relation on the carrier of an algebra such that the operations of the algebra.
Tuesday’s lecture: Today’s lecture: One-way permutations (OWPs)
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
Application: Algorithms Lecture 20 Section 3.8 Wed, Feb 21, 2007.
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
FUNCTIONS COSC-1321 Discrete Structures 1. Function. Definition Let X and Y be sets. A function f from X to Y is a relation from X to Y with the property.
Application: Algorithms Lecture 19 Section 3.8 Tue, Feb 20, 2007.
Cryptography Lecture 14 Arpita Patra © Arpita Patra.
Functions (2) - 1ICOM 4075 (Spring, 2010) UPRM Department of Electrical and Computer Engineering University of Puerto Rico at Mayagüez ICOM 4075: Foundations.
Discrete Structures Li Tak Sing( 李德成 ) Lectures
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,
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
Section 2.3. Section Summary  Definition of a Function. o Domain, Cdomain o Image, Preimage  One-to-one (Injection), onto (Surjection), Bijection 
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
FUNCTIONS.
Fuw-Yi Yang1 Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann Chap 1 Integers Department of Computer Science and Information Engineering,
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
Recursive Algorithms Section 5.4.
Relations, Functions, and Matrices
Numerical Algorithms x x-1
Number Theory (Chapter 7)
Functions Section 2.3.
Mathematical Induction Recursion
Foundations of Discrete Mathematics
Lecture 20 Guest lecturer: Neal Gupta
Application: Algorithms
Application: Algorithms
Functions Section 2.3.
Cryptography Lecture 16.
Presentation transcript:

1 Chapter Facts about Functions

2 Section 2.1 Functions: Definitions and Examples A function ƒ from A to B associates each element of A with exactly one element of B. Write ƒ : A → B and call A the domain and B the codomain. Write ƒ(x) = y to mean ƒ associates x ∊ A with y ∊ B. Say, “ƒ of x is y” or “ƒ maps x to y.” If C ⊂ A, the image of C is the set ƒ(C) = {ƒ(x) | x ∊ C}. The range of ƒ is the image of A. We write range(ƒ) = ƒ(A) = {ƒ(x) | x ∊ A}. If D ⊂ B, the pre-image (or inverse image) of D is the set ƒ -1 (D) = {x | ƒ(x) ∊ D}.

3 Example The picture shows a function ƒ : A → B with domain A = {a, b, c, d} and codomain B = {1, 2, 3}. We have: ƒ(a) = ƒ(b) = 1 and ƒ(c) = ƒ(d) = 3. Some sample sets are: –range(ƒ) = {1, 3}, –ƒ({a, b}) = {1}, –ƒ -1 ({2}) = ∅, –ƒ -1 ({1, 2, 3}) = {a, b, c, d}. A B abcdabcd

4 Example Let ƒ : Z → Z be defined by ƒ(x) = 2x. Let E and O be the sets of even and odd integers, respectively. Some sample sets are: –range(ƒ) = ƒ(Z) = E; –ƒ(E) = {4k | k ∊ Z}; –ƒ(O) = {4k +2 | k ∊ Z}; –ƒ -1 (E) = Z; –ƒ -1 (O) = ∅.

5 Quiz (2 minutes) Let ƒ : N → N by ƒ(x) = if x is odd then x + 1 else x. Find each set, where E and O are the even and odd natural numbers. range(ƒ), ƒ(E), ƒ(O), ƒ -1 (N), ƒ -1 (E), ƒ -1 (O). Answers: E, E, E – {0}, N, N, ∅.

6 Floor and Ceiling The floor and ceiling functions have type R → Z, where floor(x) is the closest integer less than or equal to x and ceiling(x) is the closest integer greater than or equal to x. e.g., floor(2.6) = 2, floor(–2.1) = –3, ceiling(2.6) = 3, and ceiling(–2.1) = –2. Notation: ⌊x⌋ = floor(x) and ⌈x⌉ = ceiling(x).

7 Properties There are many interesting properties, all of which are easy to prove. Example. - ⌊x⌋ = ⌈- x⌉. Proof: If x ∊ Z, then - ⌊x⌋ = - x = ⌈- x⌉. If x ∉ Z, there is an n ∊ Z such that n – x > –(n + 1), which gives ⌈- x⌉ = – n. So - ⌊x⌋ = – n = ⌈- x⌉. QED.

8 Quiz (1 minute) Show that ⌈x + 1⌉ = ⌈x⌉ + 1. Proof: There is an integer n such that n < x ≤ n + 1. Add 1 to get n + 1 < x + 1 ≤ n + 2. So ⌈x + 1⌉ = n + 2 and ⌈x⌉ = n + 1. Therefore, ⌈x + 1⌉ = ⌈x⌉ + 1. QED.

9 Greatest Common Divisor (gcd) If x and y are integers, not both zero, then gcd(x, y) is the largest integer that divides x and y. For example, gcd(12, 15) = 3, gcd(–12, –8) = 4. Properties of gcd –gcd(a, b) = gcd(b, a) = gcd(a, –b). –gcd(a, b) = gcd(b, a – bq) for any integer q. –gcd(a, b) = ma + nb for some m, n ∊ Z. –If d | ab and gcd(d, a) = 1, then d | b.

10 Division algorithm For a, b ∊ Z, b ≠ 0 there are unique q, r ∊ Z such that a = bq + r where 0 ≤ r < | b |. Euclid’s algorithm for finding gcd(a, b) Assume a, b ∊ N, not both zero. while b > 0 do find q, r so that a = bq + r and 0 ≤ r < b; a := b; b := r od Output(a)

11 Example Find gcd(189, 33) 189 = 33 · = 24 · = 9 · = 6 · = 3 · Output(3). Quiz (1 minute). How many loop interations in Euclid’s algorithm to find gcd(117, 48)? Answer: 4 iterations. gcd(117, 48) = 3.

12 The mod Function For a, b ∊ Z with b > 0 apply the division algorithm to get a = bq +r with 0 ≤ r < b. The remainder r is the value of the mod function applied to a and b. To get a formula for r in terms of a and b solve the equation for q = a/b – r/b. Since q ∊ Z and 0 ≤ r/b < 1, it follows that q = ⌊a/b⌋. So we have r = a – bq = a – b · ⌊a/b⌋. The value of r is denoted “a mod b”. So if a, b ∊ Z with b > 0 then a mod b = a – b · ⌊a/b⌋.

13 Quiz (1 minute) It is 2am in Paris. What time is it in Portland (9 hours difference)? Answer: (12 hr clock): (2 – 9) mod 12 = (–7) mod 12 = –7 – 12 ⌊-7/12⌋ = –7 – 12(–1) = 5. (24 hr clock) (2 –9) mod 24 = (–7) mod 24 = –7 – 24 ⌊-7/24⌋ = –7 – 24(–1) = 17.

14 Quiz (1 minute) What are the elements in the set {x mod 5 | x ∊ Z}? Answer: {0, 1, 2, 3, 4}.

15 NnNn Notation: N n = {0, 1, …, n – 1}. So if n is fixed, the range of values for x mod n is N n.

16 Quiz (1 minute) Convert 13 to binary. Answer: For any x ≥ 0 we can write x = 2 ⌊x/2⌋ + x mod 2. So 13 = 2 · = 2 · = 2 · = 2 · The remainders from bottom to top are the binary digits from left to right: 1101.

17 Log Function If x and b are positive real numbers and b > 1, then log b x = y means b y = x. The graph of the log function is pictured below. Notice that log is an increasing function: s < t implies log b s < log b t. x y

18 Properties of log log b 1 = 0 log b b = 1 log b b x = x log b xy = log b x + log b y log b x y = ylog b x log a x = (log a b)(log b x)

19 Quiz (3 minutes) Estimate log 2 ( ) by finding upper and lower bounds. One answer: –log 2 ( ) = log 2 (5 2 ) + log 2 (2 5 ) = 2log log 2 2 = 2log –Since 4 < 5 < 8, we can apply log 2 to the inequality to get 2 < log 2 5 < 3. –Multiply by 2 to get 4 < 2log 2 5 < 6. So 9 < log 2 ( ) < 11. Another answer: Use 16 < 5 2 < 32. Then 4 < log 2 (5 2 ) < 5. So 9 < log 2 ( ) < 10.

20 Section 2.2 Constructing Functions Composition If g : A → B and ƒ : B → C, then the expression ƒ(g(x)) makes sense and the composition of ƒ and g, denoted ƒ ⃘ g : A → C, is the defined by (ƒ ⃘ g)(x) = ƒ(g(x)). Some examples: –floor(log 2 20) = floor(4…) = 4 –ceiling(log 2 20) = ceiling(4…) = 5 –head(tail( )) = head( ) = b.

21 The Sequence and Distribute Functions seq : N → lists(N) by seq(n) =. dist : A × lists(B) → lists(A × B) by dist(a, ) =. Example. How can we compute ƒ : N → lists(N) defined by ƒ(x) = ? Solution: Let ƒ(x) = tail(seq(x + 1)).

22 Quiz (3 minutes) How can we compute ƒ : N → lists(N × N) defined by ƒ(x) = ? Solution: Let ƒ(x) = dist(x, tail(seq(x))), or equivalently, tail(dist(x, seq(x))).

23 Map Function The map function takes a function ƒ and a list and returns the list of values obtained by applying ƒ to each element in the list. So map is defined by map(ƒ, ) =. Quiz (2 minutes). Evaluate the expression map(floor ⃘ log 2, tail(seq(8))). Answer:.

24 Example Find a definition for ƒ : N → lists(N) defined by ƒ(n) =. Solution: Transform the list into a composition of known functions. ƒ(n) = = = map(·, ) = map(·, dist(2, )) = map(·, dist(2, seq(n))). So define ƒ(n) = map(·, dist(2, seq(n))).

25 Example Find a definition for ƒ : N → lists(N) defined by ƒ(n) =. Solution: ƒ(n) = = = map(+, ) = map(+, dist(5, ) = map(+, dist(5, map(·, ) = map(+, dist(5, map(·, dist(4, ) = map(+, dist(5, map(·, dist(4, seq(n))))). So we can define ƒ(n) = map(+, dist(5, map(·, dist(4, seq(n))))).

26 Quiz (3 minutes) Find a definition for ƒ : N 3 → lists(N) defined by ƒ(a, b, n) =. Solution: This is just an abstraction of the previous example, where a = 5 and b = 4. So we can define ƒ(a, b, n) = map(+, dist(a, map(·, dist(b, seq(n))))).

27 The End of Chapter 2 - 1