1 CMSC 250 Chapter 7, Functions. 2 CMSC 250 Function terminology l A relationship between elements...
-
Upload
eugene-stewart -
Category
Documents
-
view
215 -
download
1
Transcript of 1 CMSC 250 Chapter 7, Functions. 2 CMSC 250 Function terminology l A relationship between elements...
1CMSC 250
Chapter 7, Functions
2CMSC 250
Function terminology
A relationship between elements of two sets such that no element of the first set is related to more than one element of the second set
Domain: the set which contains the values to which the function is applied
Codomain: the set which contains the possible values (results) of the function
Range (or image): the set of actual values produced when applying the function to the values of the domain
3CMSC 250
More function terminology f: X Y
– f is the function name– X is the domain– Y is the co-domain– x X y Y f sends x to y– f(x) = y f of x; the value of f at x ; the image of x under f
A total function is a relationship between elements of the domain and elements of the co-domain where each and every element of the domain relates to one and only one value in the co-domain
A partial function does not need to map every element of the domain
4CMSC 250
Formal definitions
The range of f is {y Y | (x X)[f(x) = y]}–where X is the domain and Y is the co-domain
The inverse image of y Y is{x X | f(x) = y}–the set of things in the domain X that map to y
Arrow diagramsDetermining if something is a function using an arrow diagram
Equality of functions
( functions f,g with the same domain X and codomain Y) [f = g iff (x X)[f(x) = g(x)] ]
5CMSC 250
Discrete StructuresCMSC 250Lecture 38
April 30, 2008
6CMSC 250
Types of functions
F:X Y is a one-to-one (or injective) function iff(x1,x2 X)[F(x1) = F(x2) x1 = x2], or alternatively
(x1,x2 X)[x1 x2 F(x1) F(x2)]
F: X Y is not a one-to-one function iff(x1,x2 X)[(F(x1) = F(x2)) ^ (x1 x2)]
F: X Y is an onto (or surjective) function iff(y Y)(x X)[F(x) = y]
F: X Y is not an onto function iff(y Y)(x X)[F(x) y]
7CMSC 250
Proving functions one-to-one and onto
f: R R f(x) = 3x 4
Prove or give a counterexample that f is one-to-one– recall the definition (one of two definitions) of one-to-one is
Prove or give a counterexample that f is onto– recall the definition of onto is
])()([),( 212121 xxxfxfRxx
])([)()( yxfRxRy
8CMSC 250
One-to-one correspondence or bijection
F: X Y is bijective iff F: X Y is one-to-one and onto
If F: X Y is bijective then it has an inverse function
])()([)(
])()([)(
][)(
1
1
1
yxFxyFYy
xyFyxFXx
XYF
9CMSC 250
Proving something is a bijection
F: Q Q F(x) = 5x + 1/2– prove it is one-to-one– prove it is onto– then it is a bijection– so it has an inverse function
• find F1
10CMSC 250
The pigeonhole principle
Basic form:
A function from one finite set to a smaller finite set cannot be one-to-one; there must be at least two elements in the domain that have the same image in the codomain.
11CMSC 250
Examples Using this class as the domain:
– must two people share a birth month? – must two people share a birthday?
Let A = {1,2,3,4,5,6,7,8}– if I select 5 different integers at random from this set, must two
of the numbers sum exactly to 9?– if I select 4 integers?
There exist two people in New York City who have the same number of hairs on their heads.
There exist two subsets of {1,…,10} with three elements which sum to the same value.
12CMSC 250
Discrete StructuresCMSC 250Lecture 39
May 2, 2008
13CMSC 250
Another (more useful) form of the pigeonhole principle
The generalized pigeonhole principle:– For any function f from a finite set X to a finite set Y and for any
positive integer k, if n(X) > k * n(Y), then there is some y Y such that y is the image of at least k+1 distinct elements of X.
Contrapositive form:– For any function f from a finite set X to a finite set Y and for any
positive integer k, if for each y Y, f–1(y) has at most k elements, then X has at most k n(y) elements.
14CMSC 250
Examples
Using the generalized form:– assume 50 people in the room, how many must share the same birth
month?
– n(A)=5 n(B)=3 F: P (A) P (B)
how many elements of P (A) must map to a single element of P (B)?
15CMSC 250
Composition of functions
f: X Y1 and g: Y Z where Y1 Y– g ○ f: X Z where (x X)[g(f(x)) = g ○ f(x)]
f(x) g(y)
g(f(x))
y
Y1
Y ZX
x z
16CMSC 250
Composition on finite sets- example
ExampleX = {1,2,3}, Y1 = {a,b,c,d}, Y = {a,b,c,d,e}, Z = {x,y,z}
f(1) = c g(a) = y g○f(1) = g(f(1)) = z
f(2) = b g(b) = y g○f(2) = g(f(2)) = y
f(3) = a g(c) = z g○f(3) = g(f(3)) = y
g(d) = x
g(e) = x
17CMSC 250
Composition for infinite sets- example
f: Z Z f(n) = n + 1
g: Z Z g(n) = n2
g ○ f(n) = g(f(n)) = g(n+1) = (n+1)2
f ○ g(n) = f(g(n)) = f(n2) = n2 + 1
Note: g ○ f f ○ g
18CMSC 250
Identity function
iX the identity function for the domain X
iX : X X (xX) [iX(x) = x]
iY the identity function for the domain Y
iY : Y Y (yY) [iY(y) = y]
composition with the identity functions
19CMSC 250
Composition with inverse
Recall: if f is a bijection then f1 exists.
Let f: X Y be a bijection.
What is f ○ f1?
What is f1 ○ f?
20CMSC 250
One-to-one in composition
If f: X Y and g: Y Z are both one-to-one, then g ○ f: X Z is one-to-one.
If f: X Y and g: Y Z are both onto, then g ○ f: X Z is onto.
21CMSC 250
Cardinality
Comparing the “sizes” of sets:– finite sets ( or there is a positive integer n such that there is a
bijective function from the set to {1,2,…,n})– infinite sets (there is no such n such that there is a bijective
function from the set to {1,2,…,n})
sets A,B, A and B have the same cardinality iff there is a one-to-one correspondence from A to B
In other words, Cardinality(A) = Cardinality(B) ( a function f ) [f: A B f is a bijection]
22CMSC 250
Countable sets
A set S is called countably infinite iff Cardinalit(S) = Cardinality(Z+).
A set is called countable iff it is finite or countably infinite.
A set which is not countable is called uncountable.
23CMSC 250
Discrete StructuresCMSC 250Lecture 40
May 5, 2008
24CMSC 250
Countability of sets of integers and the rationals
N is this a countably infinite set? Z is this countably infinite set? Neven is this a countably infinite set? Card(Q+) =?= Card(Z)
25CMSC 250
Real numbers
We’ll take just a part of this infinite set
Reals between 0 and 1 (noninclusive)X = {x R | 0 < x < 1}
All elements of X can be written as 0.a1a2a3… an…
26CMSC 250
Cantor’s proof
Assume the set X = {x R | 0 < x < 1} is countable Then the elements in the set can be listed
0.a11a12a13a14…a1n…
0.a21a22a23a24…a2n…
0.a31a32a33a34…a3n…
… … … … Select the digits on the diagonal Build a number d, such that d differs in its nth position from
the nth number in the list
1if2
1if1
nn
nnn a
ad
27CMSC 250
All reals
Cardinality({x R | 0 < x < 1}) = Cardinality(R)