W7b 232 2023
W7b 232 2023
1 / 32
Composition of functions
g : A → B and f : B → C
A 1 B C
a
g f w
2 b
x
3 c
y
d
4 z
e
g(2) = e f(e) =w
Thus, f(g(2)) = f(e) = w
A 1 C
f O g w
2
x
3
y
4 z
2 / 32
Composition of functions
Definition
Let g : A → B and f : B → C
The composition of the functions f and g, denoted
f ◦g
is defined by
(f ◦ g)(a) = f (g(a))
f ◦g : A→C
Important:
To get f ◦ g we need
codomain of g = domain of f
Generally, f ◦ g 6= g ◦ f
and sometimes one or both may not exist at all.
3 / 32
Example 1:
4 / 32
Example 2:
g:Z→Z g(x) = 2x + 3
f :Z→Z f (x) = (x + 1)2
5 / 32
Exercise: Let
f :Z→Z f (x) = x 2 + 1
g :Z→Z g(x) = x + 2.
Find:
1. f + g
2. fg
3. f ◦ g
4. g ◦ f
6 / 32
Exercise: Let
f :Z→Z f (x) = x 2 + 1
g :Z→Z g(x) = x + 2.
Find:
1. f + g : Z → Z f + g(x) = x 2 + x + 3
2. fg : Z → Z fg(x) = x 3 + 2x 2 + x + 2
3. f ◦ g : Z → Z f ◦ g(x) = (x + 2)2 + 1
4. g ◦ f : Z → Z g ◦ f (x) = (x 2 + 1) + 2
7 / 32
Inverse and composition
8 / 32
Exercise
Let
g : A→B
f : B→C
be functions.
Show that
(a) If f is one-to-one and g is one-to-one, then f ◦ g is
one-to-one.
(b) If f is onto and g is onto, then f ◦ g is onto.
9 / 32
Proof of injectivity
g : A → B and f : B → C
To show:
If f is one-to-one and g is one-to-one, then f ◦ g is one-to-one.
Assume f and g are injective.
Then x = y ⇒ (f (x) = f (y)) ∧ (g(y) = g(y))
Show that then f (g(x)) 6= f (g(y )) ⇒ x 6= y
Proof by contrapositive:
Assume that x = y
Then g(x) = g(y ) = k for some k. It follows that
f (g(x)) = f (g(y )) = f (k )
which proves by contrapositive that f (g(x)) 6= f (g(y )) ⇒ x 6= y
10 / 32
Proof of surjectivity
g : A → B and f : B → C
To show:
If f is onto and g is onto, then f ◦ g is onto:
((f (B) = C) ∧ (g(A) = B)) → (f (g(A)) = C))
Proof by contrapositive:
f (g(A)) 6= C ⇒ ∃z∈C ∀x∈A : f (g(x)) 6= z
∃z∈C ∀x∈A : f (g(x)) 6= z
≡ (∃z∈C ∀y∈B f (y) 6= z) ∨ (∃y ∈B ∀x∈A g(x) 6= y )
≡ ¬((∀z∈C ∃y∈B f (y) = z) ∧ (∀y∈B ∃x∈A g(x) = y ))
6≡ (f (B) = C) ∧ (g(A) = B)
which concludes the proof that
((g(A) = B) ∧ (f (B) = C)) → (f (g(A)) = C)
11 / 32
Floor function
Definition
For x ∈ R, m ∈ Z, the floor function bxc is defined by
bxc = max{m ∈ Z|m ≤ x}
b3.6c = 3 b12.1c = 12
b15c = 15 b−3.4c = −4
-3 -2 -1 1 2 3 4
-2
-3
12 / 32
Ceiling function
Definition
For x ∈ R, n ∈ Z, the ceiling function dxe is defined by
dxe = min{n ∈ Z|n ≥ x}
d3.6e = 4 d12.1e = 13
d15e = 15 d−3.4e = −3
-3 -2 -1 0 1 2 3 4
-2
-3
13 / 32
Problem 1:
14 / 32
Problem 1:
Find a function w : N → N
that specifies the number of words needed to store n bytes.
Solution: w(n) = d kn e
15 / 32
Problem 2:
16 / 32
Problem 2:
17 / 32
Exercise:
True or false?
b2xc = 2bxc
18 / 32
Exercise:
True or false?
b2xc = 2bxc
19 / 32
Exercise:
True or false?
b2xc = 2bxc : false (2 = b2 12 c =
6 2b0.5c = 0)
20 / 32
Exercise:
True or false?
dbxce = bxc
21 / 32
Exercise:
True or false?
dbxce = bxc : true, dze = z for z ∈ Z
22 / 32
Exercise:
True or false?
bx + y c = dxe + by c
23 / 32
Exercise:
True or false?
bx + y c = dxe + by c : no, 0 = b.1 + .1c =
6 d.1e + b.1c = 1
24 / 32
Properties of floor and ceiling functions
25 / 32
Cardinality of sets
Definition
Sets A and B have the same cardinality iff there exists a
bijection from A to B; we write |A| = |B|.
Definition
If there exists a surjective function from A to B, the cardinality of
A is greater than or equal to the cardinality of B: |A| ≥ |B|. If
|A| ≥ |B| and A and B have different cardinality, we say that
|A| =6 |B|.
Definition
A set that is either finite or has the same cardinality as the set
of positive integers is called countable. A set that is not
countable is called uncountable. When an infinite set S is
countable, we denote the cardinality of S by ℵ0 , we say “S has
aleph null” and write |S| = ℵ0 .
26 / 32
Proving that a set is countable
Show that the set of odd positive integers is a countable set.
27 / 32
Z is countable
28 / 32
Hilbert’s Grand Hotel
29 / 32
Q+ is countable
Solution idea:
j
I align all fractions in a 2-dimensional table with mij = i
I traverse the cells of this table starting at 11 , continuing to 12 ,
sweeping up diagonally to 21 , sweeping diagonally from 13
to 13 etc.
I with sufficient time, each fraction can be reached, implying
an ordering of fractions that can be mapped to the positive
integers.
30 / 32
R is uncountable
31 / 32
Everybody should know
32 / 32