0% found this document useful (0 votes)
7 views32 pages

W7b 232 2023

The document provides an introduction to the composition of functions, defining how to combine two functions f and g, and illustrating with examples. It discusses properties of functions, including injectivity and surjectivity, and includes exercises for practice. Additionally, it covers the concepts of floor and ceiling functions, cardinality of sets, and proofs related to countability.

Uploaded by

Narendra Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views32 pages

W7b 232 2023

The document provides an introduction to the composition of functions, defining how to combine two functions f and g, and illustrating with examples. It discusses properties of functions, including injectivity and surjectivity, and includes exercises for practice. Additionally, it covers the concepts of floor and ceiling functions, cardinality of sets, and proofs related to countability.

Uploaded by

Narendra Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

COMP232

Introduction to Discrete Mathematics


W7b: Composition of functions

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:

g : set of items → N assigns to each item its bar code


f : N→R assigns to each bar code a price
f ◦g exists, function that assigns to each item a price

g◦f does not exist, since codomain of f 6= domain of g

4 / 32
Example 2:

g:Z→Z g(x) = 2x + 3
f :Z→Z f (x) = (x + 1)2

codomain of g = domain of f =⇒ f ◦ g exists.


(f ◦g)(x) = f (g(x)) = f (2x +3) = (2x +3+1)2 = 4x 2 +16x +16

codomain of f = domain of g =⇒ g ◦ f exists.


(g ◦ f )(x) = g(f (x)) = g((x + 1)2 ) = g(x 2 + 2x + 1) =
2(x 2 + 2x + 1) + 3 = 2x 2 + 4x + 5

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

Let f : A → B be an invertible function, then f −1 : B → A


(f −1 ◦ f ) and (f ◦ f −1 ) exist.
(f −1 ◦ f ) : A → A
(f ◦ f −1 ) : B → B
f (a) = b ⇐⇒ f −1 (b) = a
(f −1 ◦ f )(a) = f −1 (f (a)) = f −1 (b) = a
(f ◦ f −1 )(b) = f (f −1 (b)) = f (a) = b
thus,
(f −1 ◦ f ) = iA , the identity function on A,
(f ◦ f −1 ) = iB , the identity function on B.

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:

Assume that in each word of computer memory we can store k


bytes.
Find a function w : N → N
that specifies the number of words needed to store n bytes.

14 / 32
Problem 1:

Assume that in each word of computer memory we can store k


bytes.

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:

A bank must round the calculations involving money to cents.


i.e., 5.33453 is rounded to 5.33 and
5.13618 is rounded to 5.14
Give a function round : R → R that rounds any real number to
2 decimal points.

16 / 32
Problem 2:

A bank must round the calculations involving money to cents.


i.e., 5.33453 is rounded to 5.33 and
5.13618 is rounded to 5.14
Give a function round : R → R that rounds any real number to
2 decimal points.

Solution: round(x) = (b(x ∗ 100 + 0.5)c)/100

17 / 32
Exercise:

True or false?
b2xc = 2bxc

18 / 32
Exercise:

True or false?
b2xc = 2bxc

Depends on domain for x! Without domain specified:

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

For all real numbers x and integers m


1. x − 1 ≤ bxc ≤ x ≤ dxe ≤ x + 1
2. d−xe = −bxc
3. b−xc = −dxe
4. bx + mc = bxc + m
5. dx + me = dxe + m

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.

Proof by showing that f (n) : Z+ → O f (n) = 2n − 1


(definition of odd integers) is a bijection, where
O = {x|x is an odd positive integer}.
I Proof by contrapositive that f (n) is injective:
Assume that f (n) = f (m). Then 2n − 1 = 2m − 1 and
m = n.
I Direct proof that f (n) is surjective
(showing a unique preimage of each positive odd integer):
Let t ∈ O. successor (t) = s is a positive, even integer:
s = 2k = t + 1 for k ∈ Z+ .
Since for every t ∈ O there exists a k ∈ Z+ with
k = t+1
2 =f
−1 (t), this is a well defined injective function

that maps a unique positive integer k to each odd positive


integer t such that f (k ) = t, f (n) is surjective.

27 / 32
Z is countable

We prove that Z is countable by mapping all positive integers


into successive odd positive integers and every negative
integer into successive even positive integers :
0 → 2, 1 → 1, −1 → 4, 2→ 3, −2 → 6, 3 → 5, −3 → 8, . . .
2(n − 1) + 1 if n is positive,
f (n) : Z → Z+ , f (n) =
2(−n + 1) if n is not positive
Prove that f (n) is a bijection by cases:
I (O = {x|x is an odd integer},
E = {x|x is an even integer}, {0}) form a partition on Z+.
I n is not positive: show
f (n) : Z− ∪ {0} → E f (n) = 2(−n + 1) is a bijection
I n is positive: show
f (n) : Z+ → O f (n) = 2n − 1 is a bijection

28 / 32
Hilbert’s Grand Hotel

Hilbert’s Grand Hotel is a paradox. The Grand Hotel has a


countably infinite number of rooms, each occupied by a guest.
A new guest is accommodated by moving each current guest in
a room with number n to room number n + 1 and lodge the new
guest in room 1.

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

Proof by contradiction due to Cantor:


I Assume R is countable. Then the reals r with 0 ≤ r ≤ 1
are also countable.
I order the reals with 0 ≤ r ≤ 1
I construct a new real with decimal di = 4 if the ith decimal
of the ith real in our set is not equal to 4, 5 if it was indeed
equal to 4.
I this new real is not equal to any of the reals listed, thus our
assumption that the reals are countable is false.

31 / 32
Everybody should know

I The definition of a function


I The definition of
domain, codomain, range, image, preimage,
one-to-one, onto function,
one-to-one correspondence (bijection),
inverse function, composition of functions.
I Given a function, determine its type.
I Given two functions, find their composition.
I Properties of floor and ceiling functions.

32 / 32

You might also like