Discrete Mathematics: Functions
Discrete Mathematics: Functions
Discrete Mathematics: Functions
Functions
Definition of a function
A function takes an element from a set and
maps it to a UNIQUE element in another set
f maps R to Z
Domain R Z Co-domain
f
f(4.3)
4.3 4
Ayşe A “a” 1
Barış B “bb“ 2
Canan C “cccc” 3
Davut D “dd” 4
Emine F “e” 5
Range
a 1 “a” 1
e 2 “bb“ 2
i 3 “cccc” 3
o 4 “dd” 4
u 5 “e” 5
a 1 a 1
e 2 e 2
i 3 i 3
o 4 o 4
5 5
A one-to-one function
Onto functions
A function is onto if each element in the co-
domain is an image of some pre-image
Formal definition: A function f is onto if for
all y C, there exists x D such that f(x)=y.
a 1 a 1
e 2 e 2
i 3 i 3
o 4 o 4
u 5
An onto function
Onto vs. one-to-one
Are the following functions onto, one-to-
one, both, or neither?
a 1 a 1
a 1
b 2 b 2
b 2
c 3 c 3
c 3
4 d 4
4
1-to-1, not onto Both 1-to-1 and onto Not a valid function
a 1 a 1
b 2 b 2
c 3 c 3
d d 4
Onto, not 1-to-1 Neither 1-to-1 nor onto
Bijections
Consider a function that is
both one-to-one and onto: a 1
b 2
c 3
Such a function is a one-to-one
d 4
correspondence, or a bijection
Identity functions
A function such that the image and the pre-
image are ALWAYS equal
f(x) = 1*x
f(x) = x + 0
R f R
f-1
f(4.3)
4.3 8.6
f-1(8.6)
a 1 a 1
b 2 b 2
c 3 c 3
4 d
A B C
g f
g(a) f(b)
a f(g(a))
b = g(a)
(f ○ g)(a)
Compositions of functions
g(1) f(5)
f(g(1))=13
1
g(1)=5
(f ○ g)(1)
round(x) = x+0.5
Ceiling and floor properties
Let n be an integer
(1a) x = n if and only if n ≤ x < n+1
(1b) x = n if and only if n-1 < x ≤ n
(1c) x = n if and only if x-1 < n ≤ x
(1d) x = n if and only if x ≤ n < x+1
(2) x-1 < x ≤ x ≤ x < x+1
(3a) -x = - x
(3b) -x = - x
(4a) x+n = x+n
(4b) x+n = x+n
Ceiling property proof
Prove rule 4a: x+n = x+n
Where n is an integer
Will use rule 1a: x = n if and only if n ≤ x <
n+1
Direct proof!
Let m = x
Thus, m ≤ x < m+1 (by rule 1a)
Add n to both sides: m+n ≤ x+n < m+n+1
By rule 4a, m+n = x+n
Since m = x, m+n also equals x+n
Thus, x+n = m+n = x+n
Factorial
Factorial is denoted by n!
n! = n * (n-1) * (n-2) * … * 2 * 1
Thus, 6! = 6 * 5 * 4 * 3 * 2 * 1 = 720