Functions Rosen 2.3, 2.5 f( ) = A B Lecture 5: Oct 1, 2.

Slides:



Advertisements
Similar presentations
Functions, Pigeonhole Principle Lecture 14: Nov 4 A B f( ) =
Advertisements

Functions Section 2.3 of Rosen Fall 2008
Functions Lecture 12 A B f( ) =. Functions function, f, from set A to set B associates an element, with an element The domain of f is A. The codomain.
Terminology Domain: set which holds the values to which we apply the function Co-domain: set which holds the possible values (results) of the function.
Discrete Mathematics Lecture 7 Alexander Bukharovich New York University.
Lecture 3 Set Operations & Set Functions. Recap Set: unordered collection of objects Equal sets have the same elements Subset: elements in A are also.
CSE115/ENGR160 Discrete Mathematics 02/16/12 Ming-Hsuan Yang UC Merced 1.
Terminology Domain: set which holds the values to which we apply the function Co-domain: set which holds the possible values (results) of the function.
Functions f( ) = A B Lecture 15: Nov 4.
Pigeonhole.
Functions Goals Introduce the concept of function Introduce injective, surjective, & bijective functions.
Functions Lecture 12 A B f( ) =. Functions function, f, from set A to set B associates an element, with an element The domain of f is A. The codomain.
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,
Discrete Mathematics Lecture 7 Harper Langston New York University.
CS 2210 (22C:019) Discrete Structures Sets and Functions Spring 2015 Sukumar Ghosh.
Functions.
Chapter 7 Functions Dr. Curry Guinn. Outline of Today Section 7.1: Functions Defined on General Sets Section 7.2: One-to-One and Onto Section 7.3: The.
1 CMSC 250 Chapter 7, Functions. 2 CMSC 250 Function terminology l A relationship between elements of two sets such that no element of the first set is.
Functions A B f( ) =. This Lecture We will define a function formally, and then in the next lecture we will use this concept in counting. We will also.
Cardinality of Sets Section 2.5.
2.1 Sets 2.2 Set Operations 2.3 Functions ‒Functions ‒ Injections, Surjections and Bijections ‒ Inverse Functions ‒Composition 2.4 Sequences and Summations.
FUNCTION Discrete Mathematics Asst. Prof. Dr. Choopan Rattanapoka.
Functions. Copyright © Peter Cappello2 Definition Let D and C be nonempty sets. A function f from D to C, for each element d  D, assigns exactly 1 element.
ICS 253: Discrete Structures I
1 Lecture 3 (part 3) Functions – Cardinality Reading: Epp Chp 7.6.
Week 7 - Friday.  What did we talk about last time?  Set disproofs  Russell’s paradox  Function basics.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
Functions Section 2.3 of Rosen Spring 2012 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions: Use Piazza.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
1 Discrete Structures – CNS 2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 1 The Foundations: Logic, Sets,
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.1 and 7.2.
Agenda Week 10 Lecture coverage: –Functions –Types of Function –Composite function –Inverse of a function.
COMPSCI 102 Introduction to Discrete Mathematics.
Discrete Structures Li Tak Sing ( 李德成 ) Lectures
Basic Structures: Sets, Functions, Sequences, and Sums.
Great Theoretical Ideas in Computer Science.
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.3, 7.4 and 7.5.
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.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Section 2.5. Cardinality Definition: A set that is either finite or has the same cardinality as the set of positive integers (Z + ) is called countable.
1 Lecture 5 Functions. 2 Functions in real applications Curve of a bridge can be described by a function Converting Celsius to Fahrenheit.
FUNCTIONS.
Functions 7/7/2016COCS - Discrete Structures1. Functions A function f from a set A to a set B is an assignment of exactly one element of B to each element.
Russell’s Paradox Is W in W? In words, W is the set that contains all the sets that don’t contain themselves. If W is in W, then W contains itself. But.
Functions Goals Introduce the concept of function
ICS 253: Discrete Structures I
Function Hubert Chan (Chapter 2.1, 2.2) [O1 Abstract Concepts]
Discrete Mathematics Lecture 6
Discrete Mathematics CS 2610
Functions 1.
CS 2210:0001 Discrete Structures Sets and Functions
Applied Discrete Mathematics Week 2: Functions and Sequences
Functions.
Function Hubert Chan (Chapter 2.1, 2.2) [O1 Abstract Concepts]
2.4 Sequences and Summations
Cardinality of Sets Section 2.5.
… and the following mathematical appetizer is about…
Functions.
Functions Section 2.3.
Discrete Math (2) Haiming Chen Associate Professor, PhD
Lecture 7 Functions.
Functions.
CSE15 Discrete Mathematics 02/27/17
… and the following mathematical appetizer is about…
CS 220: Discrete Structures and their Applications
ICS 253: Discrete Structures I
… and the following mathematical appetizer is about…
Functions Rosen 6th ed., §2.3.
Cardinality Definition: The cardinality of a set A is equal to the cardinality of a set B, denoted |A| = |B|, if and only if there is a one-to-one correspondence.
Functions Section 2.3.
Presentation transcript:

Functions Rosen 2.3, 2.5 f( ) = A B Lecture 5: Oct 1, 2

Functions function, f, from set A to set B associates an element , with an element The domain of f is A. The codomain of f is B. For every input there is exactly one output.

Functions domain = R codomain = R+-{0} domain = R+-{0} codomain = R

Functions f(S) = |S| f(string) = length(string) domain = the set of all sets codomain = non-negative integers f(S) = |S| domain = the set of all strings codomain = non-negative integers f(string) = length(string) not a function, since one input could have more than one output f(student-name) = student-ID f(x) = is-prime(x) domain = positive integers codomain = {T,F}

Let f1 and f2 be functions from A to R. Then the sum and the product of f1 and f2 are also functions from A to R defined by: (f1 + f2)(x) = f1(x) + f2(x) (f1f2)(x) = f1(x) f2(x) Example: f1(x) = 3x, f2(x) = x + 5 (f1 + f2)(x) = f1(x) + f2(x) = 3x + x + 5 = 4x + 5 (f1f2)(x) = f1(x) f2(x) = 3x (x + 5) = 3x2 + 15x

Functions We already know that the range of a function f:AB is the set of all images of elements aA. If we only regard a subset SA, the set of all images of elements sS is called the image of S. If f(a)=b, b is the image of a and a is preimage of b We denote the image of S by f(S): f(S) = {f(s) | sS}

Increasing/decreasing functions If f(x)≤f(y) (f(x)≥f(y)), whenever x<y and x, y are in the domain of f Strictly increasing (decreasing): If f(x)<f(y) (f(x) > f(y)) whenever x<y, and x, y are in the domain of f A function that is either strictly increasing or decreasing must be one-to-one

A B f( ) = |A| ≤ |B| Injections (One-to-One) ≤ 1 arrow in is an injection iff no two inputs have the same output. ≤ 1 arrow in f( ) = A B |A| ≤ |B|

A B f( ) = |A| ≥ |B| Surjections (Onto) 1 arrow in is a surjection iff every output is possible. f( ) = 1 arrow in A B |A| ≥ |B|

A B f( ) = |A| = |B| Bijections (one-and-one correspondence) is a bijection iff it is surjection and injection. exactly one arrow in f( ) = A B |A| = |B| Identity function:

In-Class Exercises Function Domain Codomain Injective? Surjective? Bijective? f(x)=sin(x) Real f(x)=2x Positive real f(x)=x2 Non-negative real Reverse string Bit strings of length n No No No Yes Yes Yes No Yes No Yes Yes Yes Whether a function is injective, surjective, bijective depends on its domain and the codomain.

Inverse Sets A B Given an element y in B, the inverse set of y := f-1(y) = {x in A | f(x) = y}.

A B f( ) = Inverse Function exactly one arrow in Informally, an inverse function f-1 is to “undo” the operation of function f. exactly one arrow in f( ) = A B There is an inverse function f-1 for f if and only if f is a bijection.

Composition of Functions Two functions f:X->Y’, g:Y->Z so that Y’ is a subset of Y, then the composition of f and g is the function g。f: X->Z, where g。f(x) = g(f(x)). f g Y’ X Z Y

In-Class Exercises Function f Function g g。f injective? g。f surjective? bijective? f:X->Y f surjective g:Y->Z g injective g surjective f injective f bijective g bijective f-1:Y->X No No No No Yes No No No No Yes Yes Yes Yes Yes Yes

Pigeonhole Principle If more pigeons than pigeonholes,

then some hole must have at least two pigeons! Pigeonhole Principle then some hole must have at least two pigeons! Pigeonhole principle A function from a larger set to a smaller set cannot be injective. (There must be at least two elements in the domain that have the same image in the codomain.)

Example Question: Let A = {1,2,3,4,5,6,7,8} If five integers are selected from A, must a pair of integers have a sum of 9? Consider the pairs {1,8}, {2,7}, {3,6}, {4,5}. The sum of each pair is equal to 9. If we choose 5 numbers from this set, then by the pigeonhole principle, both elements of some pair will be chosen, and their sum is equal to 9.

Birthday Paradox In a group of 366 people, there must be two people having the same birthday. Suppose n <= 365, what is the probability that in a random set of n people, some pair of them will have the same birthday? We can think of it as picking n random numbers from 1 to 365 without repetition. There are 365n ways of picking n numbers from 1 to 365. There are 365·364·363·…·(365-n+1) ways of picking n numbers from 1 to 365 without repetition. So the probability that no pairs have the same birthday is equal to 365·364·363·…·(365-n+1) / 365n This is smaller than 50% for 23 people, smaller than 1% for 57 people.

♠ ♥ ♣ ♦ Generalized Pigeonhole Principle If n pigeons and h holes, then some hole has at least pigeons. ♠ ♥ ♣ ♦

Subset Sum Two different subsets of the 90 25-digit numbers shown above have the same sum.

Subset Sum 90 numbers, each with at most 25 digits. So the total sum is at most 90x1025 Let A be the set of all subsets of the 90 numbers. (pigeons) Let B be the set of integers from 0 to 90x1025. (pigeonholes) By pigeonhole principle, there are two different subsets with the same sum. This is an example of a non-constructive proof.

Cardinality Functions are useful to compare the sizes of two different sets. Question: Are all infinite sets having the same cardinality? Two sets A and B have the same cardinality if and only if there is a bijection between A and B. A set is countable if it has the same cardinality as the set of positive integers. When an infinite set S is countable, we denote the cardinality of S by ℕ0, i.e., |S|= ℕ0

Integers vs Positive Integers Is the set of integers countable? Define a bijection between the positive integers and all integers 1 2 3 4 5 6 7 8 . . . 0 1 −1 2 −2 3 −3 4 . . . n/2, if n is even; −(n − 1)/2, if n is odd. f(n) = So, the set of integers is countable.

Odd Positive Integers vs Positive Integers Is the set of odd positive integers countable? Define a bijection between the positive integers and odd positive integers 1 2 3 4 5 6 7 8 . . . 1 3 5 7 9 11 13 15 . . . f(n) = 2n − 1 So, the set of odd positive integers is countable.

Rational Numbers vs Positive Integers Question: Is the set of rational number countable? The set of “pair of integers” (a,b) is not smaller than the set of rational number. We want to show that the set of “pair of integers” is countable, by defining a bijection to the set of positive integers. This would then imply the set of rational is countable.

Rational Numbers vs Positive Integers (0, 0), (0, 1), (0,−1), (0, 2), (0,−2), (0, 3), (0,−3), . . . (1, 0), (1, 1), (1,−1), (1, 2), (1,−2), (1, 3), (1,−3), . . . (−1, 0),(−1, 1),(−1,−1),(−1, 2),(−1,−2),(−1, 3), (−1,−3), . . . (2, 0), (2, 1), (2,−1), (2, 2), (2,−2), (2, 3), (2,−3), . . . (−2, 0),(−2, 1),(−2,−1),(−2, 2),(−2,−2), (−2, 3),(−2,−3), . . . If you map the set of positive integers to the top row first, then you will not be able to reach the second row. The trick is to visit the rational numbers diagonal by diagonal. Each diagonal is finite, so eventually every pair will be visited. Therefore, there is a bijection from the set of positive integers, to the set of pair of integers, and so the set of rational numbers is countable.

Challenge for the Bored!!! Real Numbers vs Positive Integers Question 1: Is the set of real number countable? Theorem: No surjection mapping positive integers to real numbers. Also, show that power sets can be proved to be uncountable. Challenge for the Bored!!!

Take Home Assignment I Assignment I Uploaded Deadline: Next Lecture – Oct 8, 9