Discrete Mathematics
MH1812
Topic 9.1 - Functions I
Dr. Wang Huaxiong
MH1812: Discrete Mathematics 1
Topic Overview
MH1812: Discrete Mathematics 2
What’s in store…
I ntroduction to Functions
I njectivity
S urjectivity
MH1812: Discrete Mathematics 3
By the end of this lesson, you should be able to…
• Explain the concepts of functions.
• Explain the concepts of injective functions.
• Explain the concepts of surjective functions.
MH1812: Discrete Mathematics 4
Introduction to Functions
MH1812: Discrete Mathematics 5
Introduction to Functions: Definition
Let X and Y be sets. A function f from X to Y is
a rule that assigns every element x of X to a
unique y in Y. We write f: X Y and f(x) = y.
(∀𝑥 ∈ 𝑋 ∃𝑦 ∈ 𝑌, 𝑦 = 𝑓(𝑥)) ∧ (∀𝑥1 , 𝑥2 ∈ 𝑋, 𝑓 𝑥1 ≠ 𝑓(𝑥2 ) → 𝑥1 ≠ 𝑥2 )
X= Domain
Y= Codomain
y= Image of x under f
x= Preimage of y under f
Range = Subset of Y with preimages
MH1812: Discrete Mathematics 6
Introduction to Functions: Example 1
(∀𝑥 ∈ 𝑋 ∃𝑦 ∈ 𝑌, 𝑦 = 𝑓(𝑥)) ∧ (∀𝑥1 , 𝑥2 ∈ 𝑋, 𝑓 𝑥1 ≠ 𝑓(𝑥2 ) → 𝑥1 ≠ 𝑥2 )
Domain X = {a,b,c}
Codomain Y = {1,2,3,4} Arrow Diagram of f:
f = {(a,2), (b,4), (c,2)} X Y
Preimage of 2 is {a,c}
a• •1
Range = {2,4} •2
b•
•3
c•
•4
MH1812: Discrete Mathematics 7
Introduction to Functions: Example 2
Let f be the function from Z to Z that assigns
the square of an integer to this integer.
Then
f: Z Z, f(x) = x2 Z Z
•4
Domain and codomain of f: Z •3
2 •2
Range ( f ) = {0, 1, 4, 9, 16, 25, ….} 1 •1
0 •0
1 • 1
2
MH1812: Discrete Mathematics 8
Introduction to Functions: Functions vs. Non-functions
(∀𝑥 ∈ 𝑋 ∃𝑦 ∈ 𝑌, 𝑦 = 𝑓(𝑥)) ∧ (∀𝑥1 , 𝑥2 ∈ 𝑋, 𝑓 𝑥1 ≠ 𝑓(𝑥2 ) → 𝑥1 ≠ 𝑥2 )
X = {a,b,c} to Y = {1,2,3,4}
X f Y X g Y X h Y
1 1 1
a a a
2 2 2
b b b
3 3 3
c c c
4 4 4
No! No! Yes!
(b has no image) (c has two images) (Each element of X has
exactly one image)
MH1812: Discrete Mathematics 9
Introduction to Functions: Image of a Set
Let f be a function from X to Y and S X. The
image of S is the subset of Y that consists of the
images of the elements of S: f(S) = {f(s)sS}.
f: X Y
s
S f(s)
f(S)
X Y
MH1812: Discrete Mathematics 10
Injectivity
MH1812: Discrete Mathematics 11
Injectivity: One-to-one Function
A function f is one-to-one (or injective), if and only if
f(x) = f(y) implies x = y for all x and y in the domain of f.
In words…
“All elements in the domain
of f have different images”.
Mathematical Description
f: A B is one-to-one x1, x2A (f(x1) = f(x2) ⟹ x1 = x2)
or
f: A B is one-to-one x1, x2A (x1 x2 ⟹ f(x1) f(x2))
MH1812: Discrete Mathematics 12
Injectivity: One-to-one Example
A B A B
1 1
a a
2 2
b b
3 3
c c
4 4
One-to-one Not one-to-one
(All elements in A have a (a and b have the same image)
different image)
MH1812: Discrete Mathematics 13
Injectivity: One-to-one Example
f: R R, f(x) = 4x 1 g: R R, g(x) = x2
f(x) Does each element g(x)
in R have a
different image? 4
x1
x
x2
x
2 2
Yes! No!
To show x1, x2 R (f(x1) = f(x2) x1 = x2), Take x1 = 2 and x2 = 2.
take some x1, x2 R with f(x1) = f(x2). Then g(x1) = 22 = 4 = g(x2) and x1 x2.
Then 4x11 = 4x2 1 4x1 = 4x2 x1 = x2.
MH1812: Discrete Mathematics 14
Surjectivity
MH1812: Discrete Mathematics 15
Surjectivity: Onto Function
A function f from X to Y is onto (or surjective), if and only if
for every element y∈Y there is an element x∈X with f(x) = y.
In words…
“Each element in the codomain
of f has a preimage”.
Mathematical Description
f: X Y is onto y ∈Y x ∈X, f(x) = y
MH1812: Discrete Mathematics 16
Surjectivity: Onto Example
X Y X Y
a a
1 1
b b
2 2
c c
3 3
d d
Onto Not onto
(All elements in Y have a (1 has no preimage)
preimage)
MH1812: Discrete Mathematics 17
Surjectivity: Onto Example
g: R R, g(x) = x2
Does each element in R have a preimage?
No! g(x)
• To show yR such that xR g(x) y
R0
• Take y = 1
• Then any xR holds g(x) = x2 1 = y
x
But g:R R0, g(x) = (where R0
x2
denotes the set of non-negative real 1
numbers) is onto!
MH1812: Discrete Mathematics 18
Topic Summary
MH1812: Discrete Mathematics 19
Let’s recap…
• Functions:
– Domain
– Codomain
– Image
– Preimage
– Range
• Injective functions (one-to-one)
• Surjective functions (onto)
MH1812: Discrete Mathematics 20