Chapter5 - Functions
Chapter5 - Functions
UNIT 5
FUNCTIONS
Zaharin Yusoff (Prof Dr)
SCHOOL
UNIT 4 – Properties of the Integers
The Well-Ordering Principle:
Mathematical Induction Chapter 4:
Recursive Definitions
4.1 4.5
The Division Algorithm: Prime Numbers
pg 193 241
The Greatest Common Divisor: The
Euclidean Algorithm
The Fundamental Theorem of
Arithmetic (product of primes)
UNIT 5 – Relations and Functions
Chapter 5:
Cartesian Products and Relations
5.1 5.3 & 5.6
Functions: Plain and One-to-One
pg 247 267,
Onto Functions: Stirling Numbers of
pg 278 289
the Second Kind
Function Composition and Inverse
Functions
UNIT 6 – Relations: The Second Time Around Chapter 7:
Relations Revisited: Properties of Relations 7.1 7.2
― Binary, Reflexive, Symmetric, Transitive Pg 337 356
Computer Recognition: Zero-One Matrices and
Directed Graphs
UNIT 5 – Relations and Functions
UNIT 5 – Relations and Functions
Functions nm
[mapping from all elements of A,
not 1–many, i.e. unique element on RHS)
1–1 functions n!
[mapping from all elements of A, (n – m) !
not 1-many, i.e. unique element on RHS]
⎮A⎮ ≤⎮B⎮
onto functions n
Σk=0 (−1)k nCn−k (n−k)m
[mapping from all elements of A,
not 1-many, i.e. unique element on RHS]
⎮A⎮ ≥⎮B⎮
bijective functions
n!
[1–1 and onto]
⎮A⎮ =⎮B⎮
n!
others n –[(
m
+ n
Σk=0 (−1)k nCn−k (n−k)m ) – n ! ]
[not 1–1 nor onto] (n – m) !
Computer Representation
…...….
…...….
…...….
b) A second function related to the floor function in part (a) is the ceiling function.
The function g: R ® Z is defined by
g(x) = éxù = the least integer greater than or equal to x.
é3ù = 3, é3.01ù = é3.7ù = 4 = é4ù , é–3ù = –3, é–3.01ù = é–3.7ù = –3
Recall: B
For finite sets A, B with ⎮A⎮ = m and ⎮B⎮= n, A
there are 2mn possible relations from A to B,
including the empty relation as well as the
relation A × B itself.
n. n. … n = nm
m places
If f: A ® B and A1 Í A, then A B
f (A1) = {b Î B ½b = f (a), for some a Î A1}, A1 Image = f(A1)
n. n-1. … n-m
m places
Examples:
• The function f: R ® R defined by f(x) = x3 is an onto function. Range
If r is any real number in the codomain of f, then the real
number 3Ör is in the domain of f and f (3Ör) = (3Ör)3 = r.
Hence codomain of f = R = range of f, thus f is onto. Domain Image =
Codomain =
Range
• The function g: R ® R, where g (x) = x2 for each real number x, is not an onto function.
No negative real number appears in the range of g.
e.g. For –9 to be in the range of g,
we would have to be able to find a real number r with g(r) = r2 = –9.
However, r2 = –9 ⇒ r = 3i or r = –3i, where 3i, –3i Î C, but 3i, –3i Ï R.
So here the range of g = g (R) = [0, +¥) Ì R, and the function g is not onto.
• But the function h: R ® [ 0, +¥ ) defined by h(x) = x2 is an onto function.
• The function f: Z ® Z, where f (x) = 3x + 1 for x Î Z is not onto.
The range f = {…, –8, –5, –2, 1, 4, 7, …} Ì Z,
for example, does not include 8.
The equation 3x + 1 = 8 gives x = 7/3, A
which is a rational number 7/3, and is not an integer. w B
1
2 x
• However, the following are onto functions:
g: Q ® Q, where g(x) = 3x + 1 for x Î Q 3 y
h: R ® R, where h(x) = 3x + 1 for x Î R f z
• If A, B are finite sets, then for an onto function f: A ® B to possibly exist we must
have ½A½ ³ ½B½where ½A½ = m ³ n = ½B½ [if less, there will be ‘spare’ elements in B]
More Examples: x B
A 1
• If A = {1, 2, 3, 4} and B = {x, y, z}, then 2 y
f1 = {(1, z), (2, y), (3, x), (4, y)} and 3
f2 = {(1, x), (2, x), (3, y), (4, z)} g z
4
are both functions from A onto B.
However, the function g = {(1, x), (2, x), (3, y), (4, y)} is not onto,
because g (A) = {x, y} Ì B [z has no preimage in A]
Possible images for
• If A = {x, y, z} and B = {1, 2}, each element of A
then all functions f: A ® B are onto
except the constant functions
f1 = {(x, 1), (y, 1), (z, 1)}
2. 2. 2 = 23
f2 = {(x, 2), (y, 2), (z, 2)}
So there are ½B½½A½ – 2 = 23 – 2 = 6 onto functions from A to B. Possible images for
each element of A
• In general, if ½A½ = m ≥ 2 and ½B½=2,
then there are 2m – 2 onto functions from A to B.
3. 3. 3. 3 = 34
• But is not the final answer, as not all of these latter 3(24) functions
are distinct.
From A to {1, 2}, we removed the constant function {(w, 2), (x, 2), (y, 2), (z, 2)}, and
the same one from A to {2, 3}. Consequently, we have removed twice each of the
constant functions f: A ® B, where f (A) is one of the sets {1}, {2}, or {3}. As such, we
need to add 3 back, giving the total number of onto functions from A to B as:
• …. As such, we need to add 3 back, giving the total number of onto functions from
A to B as:
= = = 8,400
Functions (Counting)
Functions nm
[mapping from all elements of A,
not 1–many, i.e. unique element on RHS)
1–1 functions n!
[mapping from all elements of A, (n – m) !
not 1-many, i.e. unique element on RHS]
⎮A⎮ ≤⎮B⎮
onto functions n
Σk=0 (−1)k nCn−k (n−k)m
[mapping from all elements of A,
not 1-many, i.e. unique element on RHS]
⎮A⎮ ≥⎮B⎮
bijective functions
n!
[1–1 and onto]
⎮A⎮ =⎮B⎮
n!
others n –[(
m
+ n
Σk=0 (−1)k nCn−k (n−k)m ) – n ! ]
[not 1–1 nor onto] (n – m) !
5.6 Function Composition and
Inverse Functions
(pg. 278 289)
Function Composition and Inverse Functions
• For c, d ∈ Z, if c + d = d + c = 0
then d is the additive inverse of c.
(c is also the additive inverse of d). We now want to look at
the inverse of functions
• For t, u ∈ R, and t ≠ 0, if ut = tu = 1
then u is called the multiplicative inverse of t
(t is also the multiplicative inverse of u)
Example
If A = {1, 2, 3, 4} and B = {w, x, y, z}, then
f = {(1, w), (2, x), (3, y), (4, z)}
is a one-to-one correspondence from A (on)to B, and
g = {(w, 1), (x, 2), (y, 3), (z, 4)}
is a one-to-one correspondence from B (on)to A.
But sometimes f ¹ g even though f (a) = g (a), "a Î A. This occurs when f, g are
functions with a common domain A – but the codomains are not the same.
Example:
Let f: Z ® Z, g: Z ® Q where f (x) = x = g (x), for all x Î Z.
Then f, g share the common domain Z, and have the same range Z,
and act the same on every element of Z. Yet f ¹ g !
Here f is a one-to-one and onto correspondence,
whereas g is one-to-one but not onto;
so the codomains do make a difference.
Example:
Let A = {1, 2, 3, 4}, A B C
B = {a, b, c}, and
C = {w, x, y, z} 1 w
a
with f: A ® B and g: B ® C given by x
2
f = {(1, a), (2, a), (3, b), (4, c)} b
g = {(a, x), (b, y), (c, z)}. y
3
For each element of A we find: c
(g o f) (1) = g (f (1))= g (a) = x 4 z
f g
(g o f) (2) = g (f (2))= g (a) = x
(g o f) (3) = g (f (3))= g (b) = y
(g o f) (4) = g (f (4))= g (c) = z
So
g o f = {(1, x), (2, x), (3, y), (4, z)}.
Note: The composition f o g is not defined.
(because domain of f = A ≠ C = codomain of g)
Example:
Example:
Let f, g, h: R ® R, where f (x) = x2, g(x) = x + 5, and h(x) = Öx2 +2.
Then ((h o g) o f )(x) = (h o g) (f (x))
= (h o g) (x2) = h (g (x2))
= h (x2+ 5) = Ö (x2 + 5)2 + 2
= Ö(x4 + 10x2 + 27).
Example
With A = {1, 2, 3, 4} and f: A ® A defined by
f = {(1, 2), (2, 2), (3, 1), (4, 3)},
we have f 2 = f o f = {(1, 2), (2, 2), (3, 2), (4, 1)}
and f 3 = f o f 2 = f o f o f = {(1, 2), (2, 2), (3, 2), (4, 2)}
…..
For sets A, B, if R is a relation from A to B, then the converse of R, denoted Rc ,
is the relation from B to A defined by Rc = {(b, a)½(a, b) Î R}.
Example
For A = {1, 2, 3} and B = {w, x, y}, let f: A ® B be given by
f = {(1, w), (2, x), (3, y)}.
Then f c = {(w, 1), (x, 2), (y, 3)}
is a function from B to A, and we observe that
f c o f = 1A and f o f c = 1B.
If f: A ® B, then f is said to be invertible if there is a function g: B ® A such that
g o f = 1A and f o g = 1B. (here g is also invertible)
Example
Let f, g: R ® R be defined by f (x) = 2x + 5, g (x) = (1/2)(x – 5).
Then (g o f) (x) = g (f (x)) = g (2x + 5) = (1/2)[(2x + 5) – 5] = x,
and (f o g ) (x) = f (g (x)) = f ((1/2)(x – 5)) = 2[(1/2)(x – 5)] + 5 = x,
so f o g = 1R and g o f = 1R.
Consequently, f and g are both invertible functions.
We shall call the function g the inverse of f and shall adopt the notation g = f –1.
The above also implies that f –1 = f c – the inverse is the same as the converse
Whenever f is an invertible function, so is the function f -1, and (f –1) –1 = f
Example
The function f1: R ® R defined by f1 (x) = x2 is not invertible (it is neither one-to-
one nor onto), but f2: [0, +¥) ® [0, +¥) defined by f2(x) = x2 is invertible with f2–
1
(x) = Öx
THANK YOU TERIMA KASIH
MERCI ARIGATO/ OKINI
GRAZZIE GO MA SSEUM NI DA
GRACIAS SHUKRIYA
SPASIBA XIE-XIE NI
DANKE KAMSIAH / MMKOI
MANGE TAK JABAI INAU
NAN DHRI NGGO BUTE KABU
CAM ON KOP KUN KAH