Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c)2001-2004 Michael P. Frank Modified by (c) 2004-2005 Haluk Bingöl Module #4.

Slides:



Advertisements
Similar presentations
Lecture adapted from CS3511,Discrete Methods Kees van Deemter
Advertisements

Functions Section 2.3 of Rosen Fall 2008
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
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.
modified from UCI ICS/Math 6D, Fall Sets+Functions-1 Sets “Set”=Unordered collection of Objects “Set Elements”
Functions Goals Introduce the concept of function Introduce injective, surjective, & bijective functions.
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.
Functions. Let A and B be sets A function is a mapping from elements of A to elements of B and is a subset of AxB i.e. can be defined by a set of tuples!
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Functions.
Sets Set Operations Functions. 1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products.
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.
Foundations of Discrete Mathematics Chapter 3 By Dr. Dalia M. Gil, Ph.D.
February 12, 2015Applied Discrete Mathematics Week 2: Functions and Sequences 1Exercises Question 1: Given a set A = {x, y, z} and a set B = {1, 2, 3,
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
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
Fall 2002CMSC Discrete Structures1 … and the following mathematical appetizer is about… Functions.
10/26/20151 … and the following mathematical appetizer is about… Functions.
Discrete Mathematics CS 2610 September 12, Agenda Last class Functions  Vertical line rule  Ordered pairs  Graphical representation  Predicates.
4.1 CompSci 102© Michael Frank Today’s topics FunctionsFunctions – –Notations and terms – –One-to-One vs. Onto – –Floor, ceiling, and identity Reading:
Functions Section 2.3 of Rosen Spring 2012 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions: Use Piazza.
MSU/CSE 260 Fall Functions Read Section 1.8.
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,
321 Section, Week 3 Natalie Linnell. Functions A function from A to B is an assignment of exactly one element of B to each element of A. We write f(a)
1.4 Sets Definition 1. A set is a group of objects . The objects in a set are called the elements, or members, of the set. Example 2 The set of positive.
Example Prove that: “IF 3n + 2 is odd, then n is odd” Proof by Contradiction: -p = 3n + 2 is odd, q = n is odd. -Assume that ~(p  q) is true OR -(p 
강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics)  함수 (Functions)
Functions Reading: Chapter 6 (94 – 107) from the text book 1.
Basic Structures: Functions Muhammad Arief download dari
CompSci 102 Discrete Math for Computer Science January 31, 2012 Prof. Rodger Slides modified from Rosen AB a b c d x y z.
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/21 Module.
Functions Section 2.3. Section Summary Definition of a Function. – Domain, Cdomain – Image, Preimage Injection, Surjection, Bijection Inverse Function.
Functions. L62 Agenda Section 1.8: Functions Domain, co-domain, range Image, pre-image One-to-one, onto, bijective, inverse Functional composition and.
MATH 224 – Discrete Mathematics
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/18 Module.
Basic Structures: Sets, Functions, Sequences, and Sums.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
CSC102 - Discrete Structures Functions
1 Functions CS 202 Epp section ??? Aaron Bloomfield.
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.
1 Lecture 5 Functions. 2 Functions in real applications Curve of a bridge can be described by a function Converting Celsius to Fahrenheit.
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.
Discrete Mathematics Lecture # 17 Function. Relations and Functions  A function F from a set X to a set Y is a relation from X to Y that satisfies the.
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/18 Module.
Relations, Functions, and Matrices
COT 3100, Spring 2001 Applications of Discrete Structures
Functions.
… and the following mathematical appetizer is about…
Functions Section 2.3.
Discrete Math (2) Haiming Chen Associate Professor, PhD
Discrete Mathematics and its Applications
… and the following mathematical appetizer is about…
Functions CS 202 Epp section 7.1.
Rosen 5th ed., §1.8 ~44 slides, ~2 lectures
Dept. of Mathematics 이산수학 Discrete Mathematics Dr. Chae, Gab-Byung
… and the following mathematical appetizer is about…
Functions Rosen 6th ed., §2.3.
Discrete Mathematics and its Applications
Functions Section 2.3.
Discrete Mathematics and its Applications
Presentation transcript:

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl Module #4 - Functions Bogazici University Department of Computer Engineering CmpE 220 Discrete Mathematics 04. Functions Haluk Bingöl

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl Module #4 - Functions Module #4: Functions Rosen 5 th ed., §1.8 ~31 slides, ~1.5 lectures

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 3/34 Module #4 - Functions Functions

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 4/34 Module #4 - Functions On to section 1.8… Functions From calculus, you are familiar with the concept of a real-valued function f, which assigns to each number x  ℝ a particular value y=f(x), where y  ℝ. But, the notion of a function can also be naturally generalized to the concept of assigning elements of any set to elements of any set. (Also known as a map.)

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 5/34 Module #4 - Functions Function: Formal Definition Def. For any sets A, B, we say that a function f from (or “mapping”) A to B (f:A  B) is a particular assignment of exactly one element f(x)  B to each element x  A. Some further generalizations of this idea: A partial (non-total) function f assigns zero or one elements of B to each element x  A. Functions of n arguments; relations (ch. 6).

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 6/34 Module #4 - Functions Graphical Representations Functions can be represented graphically in several ways: A B a b f f x y Plot Bipartite Graph Like Venn diagrams AB

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 7/34 Module #4 - Functions Functions We’ve Seen So Far Remark. A proposition can be viewed as a function from “situations” to truth values {T,F} A logic system called situation theory. Ex. –p=“It is raining.”; s=our situation here, now p(s)  {T,F}. Remark. A propositional operator can be viewed as a function from ordered pairs of truth values to truth values: Ex. –  ((F,T)) = T. – → ((T,F)) = F.

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 8/34 Module #4 - Functions More functions so far… Remark. A predicate can be viewed as a function from objects to propositions (or truth values). Ex. –P : ≡ “is 7 feet tall”; P(Mike) = “Mike is 7 feet tall.” = False. Remark. A bit string B of length n can be viewed as a function from the numbers {1,…,n} (bit positions) to the bits { 0, 1 }. Ex. –B= 101  B(3)= 1.

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 9/34 Module #4 - Functions Still More Functions Remark. A set S over universe U can be viewed as a function from the elements of U to {T, F}, saying for each element of U whether it is in S. Ex. –S={3}  S(0)=F, S(3)=T. Remark. A set operator such as , ,  can be viewed as a function from pairs of sets to sets. Ex. –  (({1,3},{3,4})) = {3}

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 10/34 Module #4 - Functions B A : Set of all functions Def. The set of all possible functions f:A  B is B A. Theo. For finite A, B, |B A | = |B| |A|. Remark. The power set of S is 2 S. Let 2:  {0,1}. Then a subset T  S is just a function from S to 2.

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 11/34 Module #4 - Functions Some Function Terminology Def. Let f:A  B, and f(a)=b (where a  A & b  B). Then A is the domain of f. B is the codomain of f. b is the image of a under f. a is a pre-image of b under f. In general, b may have more than 1 pre-image. The range R  B of f is R={b |  a f(a)=b }. We also say the signature of f is A → B.

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 12/34 Module #4 - Functions Range versus Codomain Remarks. The range of a function might not be its whole codomain.The range of a function might not be its whole codomain. The codomain is the set that the function is declared to map all domain values into.The codomain is the set that the function is declared to map all domain values into. The range is the particular set of values in the codomain that the function actually maps elements of the domain to.The range is the particular set of values in the codomain that the function actually maps elements of the domain to.

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 13/34 Module #4 - Functions Range vs. Codomain - Example Ex. Suppose I declare to you that: “f is a function mapping students in this class to the set of grades {A,B,C,D,E}.” At this point, you know f’s codomain is: __________, and its range is ________. Suppose the grades turn out all As and Bs. Then the range of f is _________, but its codomain is __________________. {A,B,C,D,E} unknown! {A,B} still {A,B,C,D,E}!

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 14/34 Module #4 - Functions Operators (general definition) Def. An n-ary operator over (or on) the set S is any function from the set of ordered n-tuples of elements of S, to S itself. Ex. If S={T,F},  can be seen as a unary operator, and ,  are binary operators on S. Ex.  and  are binary operators on the set of all sets.

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 15/34 Module #4 - Functions Constructing Function Operators If  (“dot”) is any operator over B, then we can extend  to also denote an operator over functions f:A  B. Ex. Given any binary operator  :B  B  B, and functions f,g:A  B, we define (f  g):A  B to be the function defined by:  a  A, (f  g)(a) = f(a)  g(a).

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 16/34 Module #4 - Functions Function Operator Example ,× (“plus”,“times”) are binary operators over ℝ. (Normal addition & multiplication.) Therefore, we can also add and multiply functions Def. Let f, g: ℝ  ℝ. (f  g): ℝ  ℝ, where (f  g)(x) = f(x)  g(x) (f × g): ℝ  ℝ, where (f × g)(x) = f(x) × g(x)

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 17/34 Module #4 - Functions Function Composition Operator Def. Let g:A  B and f:B  C. The composition of f and g, denoted by f ○ g, is defined by (f ○ g)=f(g(a)). Remark. ○ (like Cartesian , but unlike +, ,  ) is non-commuting. (Generally, f ○ g  g ○ f.) A g B f C. a. g(a). f(g(a))

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 18/34 Module #4 - Functions Images of Sets under Functions Def. Let f:A  B, and S  A. The image of S under f is simply the set of all images (under f) of the elements of S. f(S) :  {f(s) | s  S} :  {b |  s  S: f(s)=b}. Note the range of f can be defined as simply the image (under f) of f’s domain!

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 19/34 Module #4 - Functions One-to-One Functions Def. A function is one-to-one (1-1), or injective, or an injection, iff every element of its range has only 1 pre-image. Formally: given f:A  B, “f is injective” :  (  x,y: x  y  f(x)  f(y)). Only element of the domain is mapped to any given one element of the range. Only one element of the domain is mapped to any given one element of the range. Domain & range have same cardinality. What about codomain? Memory jogger: Each element of the domain is injected into a different element of the range. Compare “each dose of vaccine is injected into a different patient.”

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 20/34 Module #4 - Functions One-to-One Illustration Bipartite (2-part) graph representations of functions that are (or not) one-to-one: One-to-one Not one-to-one Not even a function!

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 21/34 Module #4 - Functions Sufficient Conditions for 1-1ness For functions f over numbers, we say: f is strictly (or monotonically) increasing iff x>y  f(x)>f(y) for all x,y in domain; f is strictly (or monotonically) decreasing iff x>y  f(x) y  f(x)<f(y) for all x,y in domain; If f is either strictly increasing or strictly decreasing, then f is one-to-one. Ex. f(x) = x 3f(x) = x 3 f(x) = 1/x (Converse is not necessarily true)f(x) = 1/x (Converse is not necessarily true)

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 22/34 Module #4 - Functions Onto (Surjective) Functions Def. A function f:A  B is onto or surjective or a surjection iff its range is equal to its codomain (  b  B,  a  A: f(a)=b). Remark. An onto function maps the set A onto (over, covering) the entirety of the set B, not just over a piece of it. Ex. Let f: ℝ  ℝ. f(x) = x 3 is onto,f(x) = x 3 is onto, f(x) =x 2 is not onto. (Why?)f(x) =x 2 is not onto. (Why?)

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 23/34 Module #4 - Functions Illustration of Onto Some functions that are, or are not, onto their codomains: Onto (but not 1-1) Not Onto (or 1-1) Both 1-1 and onto 1-1 but not onto

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 24/34 Module #4 - Functions Bijections Def. A function f is said to be a bijection, (or a one-to-one correspondence, or reversible, or invertible,) iff it is both one-to-one and onto. Def. For bijections f:A  B, there exists an inverse of f, written f  1 :B  A, which is the unique function such that (where I A is the identity function on A)

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 25/34 Module #4 - Functions The Identity Function Def. For any domain A, the identity function I:A  A (variously written, I A, 1, 1 A ) is the unique function such that  a  A, I(a)=a. Some identity functions you’ve seen:  ing 0, ·ing by 1,  ing with T,  ing with F,  ing with ,  ing with U. Remark. The identity function is always both one- to-one and onto (bijective).

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 26/34 Module #4 - Functions The identity function: Identity Function Illustrations Domain and range x y y = I(x) = x

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 27/34 Module #4 - Functions A Cool (Literally) Application In a computer, the function mapping the machine’s state at clock cycle #t to its state at clock cycle #t+1 is called the computer’s transition function. If the transition function happens to be reversible (a bijection), then the computer’s operation, in theory, requires no energy expenditure!

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 28/34 Module #4 - Functions Graphs of Functions We can represent a function f:A  B as a set of ordered pairs {(a,f(a)) | a  A}. Note that  a, there is only 1 pair (a,b). Later (ch.6): relations loosen this restriction. For functions over numbers, we can represent an ordered pair (x,y) as a point on a plane. A function is then drawn as a curve (set of points), with only one y for each x.

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 29/34 Module #4 - Functions Aside About Representations It is possible to represent any type of discrete structure (propositions, bit- strings, numbers, sets, ordered pairs, functions) in terms of virtually any of the other structures (or some combination thereof). Probably none of these structures is truly more fundamental than the others (whatever that would mean). However, strings, logic, and sets are often used as the foundation for all else. E.g. in 

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 30/34 Module #4 - Functions A Couple of Key Functions In discrete math, we will frequently use the following two functions over real numbers: Def. The floor function  ·  : ℝ→ℤ, where  x  (“floor of x”) means the largest (most positive) integer  x. Formally,  x  : ≡ max({i  Z|i≤x}). Def. The ceiling function  ·  : ℝ→ℤ, where  x  (“ceiling of x”) means the smallest (most negative) integer  x. Formally,  x  : ≡ min({i  Z|i≥x})

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 31/34 Module #4 - Functions Visualizing Floor & Ceiling Real numbers “fall to their floor” or “rise to their ceiling.” Note that if x  Z,  x     x  &  x     x  Note that if x  Z,  x  =  x  = x. 0 1 22 3  1.6  =2  1.4  =  2  1.4  1.4  =  1  1.6  =1 33  3  =  3  =  3

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 32/34 Module #4 - Functions Plots with floor/ceiling Note that for f(x)=  x , the graph of f includes the point (a, 0) for all values of a such that a  0 and a<1, but not for the value a=1. We say that the set of points (a,0) that is in f does not include its limit or boundary point (a,1). Sets that do not include all of their limit points are generally called open sets. In a plot, we draw a limit point of a curve using an open dot (circle) if the limit point is not on the curve, and with a closed (solid) dot if it is on the curve.

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 33/34 Module #4 - Functions Plots with floor/ceiling: Example Plot of graph of function f(x) =  x/3  : x f(x) Set of points (x, f(x)) +3 22 +2 33

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 34/34 Module #4 - Functions Review of §1.8 (Functions) Function variables f, g, h, … Notations: f:A  B, f(a), f(A). Terms: image, preimage, domain, codomain, range, one-to-one, onto, strictly (in/de)creasing, bijective, inverse, composition. Function unary operator f  1, binary operators , , etc., and ○. The R  Z functions  x  and  x .

Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 35/34 Module #4 - Functions References Rosen Discrete Mathematics and its Applications, 5e Mc GrawHill, 2003Rosen Discrete Mathematics and its Applications, 5e Mc GrawHill, 2003