Download presentation
Presentation is loading. Please wait.
1
Functions 1
2
Function terminology A function maps elements of one set (called the domain) to another set (called the codomain). 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 Image: the set of actual values produced when applying the function to the values of the domain Formally the image of f is {y Y | (x X)[f(x) = y]}
3
More function terminology
f: X Y f is the function name X is the domain Y is the co-domain f(x) = y means f maps x to y Functions: f: R-> R f(x) = sqrt (-x sqared) not a function f(x) only real when x=0 g: Q -> Z g(m/n)=m when n neq 0 g(1/2) = g(3/6) = 3 therefore this is not a function because ½=3/6 but 1 neq 3 f: Sigma star -> Z g(s) = sum of the digits g(e) = 0 g(001001) = 2 g(111) = 3 g(110) = 2 g(101100) = 3 g(00000) = 0 g(s) = count of digits before the first 0 or the end (whichever comes first) g(e) = 0 g(111) = 3 g(101100) = 1 g(001001) = 0 g(110) = 2 g(00000) = 0 h(s)= length of string h(e) = 0 h(111)=3 h(101100) = 6 h(001001) = 6 h(110) = 3 h(00000) = 5 Hamming distance = measure of difference of two strings (with same length) H(s,t) = number of positions in which they differ H( , ) = 2 (3rd position & 4th position) Boolean Functions D = {all 3 tuples of 0’s and 1’s} C={0,1} C(s) = carry of add S(s) = sum of add arrow diagram S((0,1,1)) =0 C((0,1,1)) = 1 S((1,1,1))=1 C((1,1,1))=1
4
Formal definitions Image of function (in class)
Inverse image of a point (in class) f=g if f and g have the same domain f and g have the same codomain For all x (in domain), f(x)=g(x) One that is a total function (exactly mapping every element in the domain to one and only one in the codomain (with one element of the codomain not in the range)) label domain, codomain, range, f = {(x1,y1)(x2,y1)(x3,y4)(x4,y5)} inverse image of y1 = {x1,x2} Are these total functions D={1,2,3} C={a,b,c,d} f = {(1a)(2b)} no every element in the domain must go somewhere (3 doesn’t) D={1,2,3} C={a,b,c,d} f={(1a)(2b)(3c)(3d)} no every element of the domain must have only one (3 doesn’t) D={1,2,3} C={a} f={(1a)(2a)(3a)} YES an element of the codomain can have more than one image D={1,2,3} C={a,b,c,d} f={(1a)(2b)(3c)} YES an element of the codomain doesn’t need to have an image
5
Types of functions F: X Y is one-to-one (or injective) if
(x1,x2 X)[F(x1) = F(x2) x1 = x2], or alternatively (x1,x2 X)[x1 x2 F(x1) F(x2)] F: X Y is onto (or surjective) if (y Y)(x X)[F(x) = y] F: X Y is not one-to-one if (x1,x2 X)[(x1 x2) ^ (F(x1) = F(x2))] F: X Y is not onto if (y Y)(x X)[F(x) y] Draw pictures – arrow diagrams and analogy that if the function is not one to one someone is “cheating” (has two images) and that if the function is not onto there is someone who is “lonely – a wall flower) (has no image) not 1-1 & not onto D={xyzw} C={abcd} f={(xa)(ya)(zc)(wc)} is 1-1 & not onto D={xyz} C={abcd} f={(xa)(yc)(zb)} not 1-1 & is onto D={xyz} C={ab} f={(xa)(ya)(zb)} is 1-1 & is onto D={x,y,z} C={a,b,c} f={(xa)(yc)(zb)} also called a ONE-TO-ONE Correspondance or a BIJECTION not a function D={xyz} C={abcd} f={(xa)(yb)(yd)(zc)}
6
Proving functions one-to-one and onto
f(x) = 3x 4, f(x) = x^2+2 f: R R f: R Z f: Z R f: Z Z To prove 1-1 Assume f(x1)=f(x2) 3x1-4 = 3x2-4 substitution 3x1=3x2 adding 4 to both sides x1=x2 dividing both sides by 3 f(x1)=f(x2) -> x1=x2 QED prove onto: Since it is for all y, select y = 3x-4 find then that x = (y+4)/3 x in R since quotient of two R’s is R substitute that in and determine that f(x)=y f(x) = f((y+4)/3) = 3((y+4)/3) –4=(y+4)-4=y prove h:Z -> Z is 1-1 h(x)=4x^2-16: use the contrapositive form of the definition select x1 = 2, and x2=-2 h(2) = 0 h(-2) = contradiction prove g:Z -> Z is onto g(x) = 3x-4 select one y y=0 3x-4 =0 x=4/3 problem since 4/3 not in Z there is no integer x such that f(x) = y
7
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
8
Proving something is a bijection
F(x) = 5x + ½ f: R R f: R Z f: Z R f: Z Z proof of one-to-one Let x1, x2 be gp in X Assume F(x1) = F(x2) x1+1=x2+1 by substitution x1=x2 by subtracting 1 from both sides forall x1, x2 in X, F(x1)=F(x2) -> x1=x2 by def of 1-1 this function is proof of onto Let y be gp of Z select x in X where x = y-1 F(x) = F(y-1) = y-1+1 = y forall y in Y, exists x in X such that F(x) = y by def of onto – this function is
9
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.
10
Examples Using this class as the domain: Let A = {1,2,3,4,5,6,7,8}
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 that sum to the same value. domain = students in the class co-domain = {jan,feb,mar,…,dec} yes n(D) > n(C) domain = this class co- domain = 366 possible bithdays no n(D) <= n(C) domain = the integers selected from A co-domain = the pairs of integers {1,8}{2,7}{3,6}{4,5} if I select 5 – yes if I select 4 – no (domain is not larger than the co-domain) - Another example: Assume you have a set of 10 integers between 1 and 21 (inclusively) Can you be sure that two distinct element pairs of the numbers in your set add to the same sum?? A={x in Z|1<=x<=21} n(A) = B=set of possible sums={y in Y|3 <=y<=41} n(B) = =39 C=set of pairs of elements from A ={{a,b}|a in A and b in A and a neq b} n(C) = (10 choose 2) = 45 function maps C to B n(C) > n(B) so can’t be one-to-one Another example: if I have 700 people, must 2 have the same first and last initials (monograms the same) domain=D = people n(D)= codomain=C=pairs of initials n(C)= 26*26 = n(D) > n(C) >676 two people must share a monogram
11
Generalized Pigeonhole Principle
The generalized pigeonhole principle: If X,Y are finite, and |X|>k|Y|, and f:X→Y then there is some y Y such that y is the image of at least k+1 distinct elements of X. Examples/Applications of these:
12
Examples Using the generalized form:
assume 50 people in the room, how many must share the same birth month? |A|=5, |B|=3 F: P (A) P (B) how many elements of P (A) must map to a single element of P (B)? B: 100 people -> 12 months >k* > 4*12 (because 50>48) exists y in Y such that y is the image of 5 people n(A)=5 n(P(A))=2^5 = 32 n(B)=3 n(P(B))=2^3 = 8 n(P(A)) > k*n(P(B)) > k* > 3*8 (because 32 > 24 (but 32 not > 32)) There must be at least 4 elements of the domain mapping to a single element in the codomain G:X->Y n(Y)=9 Y={11,22,…,99} k=5 n(X) <= k*n(Y) n(X) <= 5*9 n(X) <= 45 k is the number of “big busses”, 25k is the number of students who can be on “big busses” 5-k is the number of “small busses”, 15(5-k) is the number of student who can be on “small busses” 25k+15(5-k) = 25k-15k+75 = 10k k+75 >= k >= k>= 2.5 k=3 (there must be 3 big busses) Another Example: If you have 16 socks in your drawer:6black, 4blue and 8red how many do you have to pick to be sure you have a pair get a pair (4) if you replace one of the black ones with a white sock (5)
13
Composition on finite sets- example
X = {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 draw diagram
14
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
15
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 Draw Pictures of f(ix(x)) and iy(f(x))
16
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 ?
17
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. Proof of one-to-one: Proof of onto: def of one-to-one applied to both f and g def of onto applied to both forall x in X, f(x1) = f(x2) x1=x forall y in Z exists x in X, f(x) = y assume x1 and x2 are gp in X Assume z is GP in Z assume g.f(x1)=g.f(x2) since g is onto, there exists a y in Y such that g(y)=z g(f(x1)) = g(f(x2)) since f is onto, there exists a x in X such that f(x) = y Since g is one to one, f(X1) = f(X2) for that y Since f is one to one, X1=X by substitution exists x in X g(f(x)) = z close conditional world and generalize from GP which means exists x in X g.f(x) = z and apply definition generalize from the gp and apply definiton
18
Cardinality Sets A and B have the same cardinality iff there is a one- to-one correspondence from A to B. We denote A and B have the same cardinality by |A| = |B|.
19
Countable sets A set S is called countably infinite iff |S| = |N|.
A set is called countable iff it is finite or countably infinite. A set which is not countable is called uncountable.
20
Countable Sets? Which of these sets are countably infinite? N Neven Z
Q+ Q Draw Diagrams f:Z(>=0)-> Z : f(x) = {x/2 when x is even or –((x+1)/2) when x is odd} g:Z(even) -> Z: g(x) = x/2 for the Z case : f(n) = { n/2 when n is even or (n-1)/2 when n is odd Any subset of a countable set is countable. Card(Z+) = Card(Z0) = Card(Z) = Card(Zeven)
21
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… Show dividing every interval into 10 sub intervals 0<=x<1 divides into 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 0.1<=x<0.2 divides into 0.10, 0.11, 0.12, 0.13, 0.14,0.15, 0.16, 0.17, 0.18, 0.19 0.12 <=x < 0.13 divides into 0.120, 0.121, 0.122, 0.123, 0.124, 0.125, 0.126, , 0.128, 0.129 etc
22
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 … … … … … d = …
23
All reals Cardinality({x R | 0 < x < 1}) = Cardinality(R)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.