Module 5 Functions

Module 3 Functions
L3.1 Properties of Functions
1
Definition
Definition 1:
Let A and B be sets.
A function f from A to B is an assignment of exactly one
element of B to each element of A.
We write f(a) = b if b is the unique element of B assigned by the
function f to the element a of A.
If f is a function from A to B, we write f: A  B.
2
Example 1 - Function
Example 1:
Let f be the function from Z to Znonneg
that assigns the square of an integer to
this integer,
Then, f: Z  Znonneg, f(x) = x2
f(-2) = 4
f(0) = 0
Z

2
1
0
1
2

Znonneg

•4
•3
•2
•1
•0
f(2) = 4
3
Floor and Ceiling Functions
Definition:
The floor function assigns to a real number x the largest integer
that is less than or equal to x. This value is denoted as x.
In other words:
x = the unique integer n with n  x < n+1
The ceiling function assigns to a real number x the smallest integer
that is greater than or equal to x. This value is denoted as x.
In other words:
x = the unique integer n with n1 < x  n
4
Floor and Ceiling Functions
Examples:
0.1 = 1
0.1 = 0
1.1 = 1
1.1 = 2
8/3 = 2
½+½ +½ = 0+1+½  = 2
Illustrations of floor and ceiling:
y  x 
y  x 
3
2
2
1
1
-3 -2 -1
-1
3
1
2
3
-3 -2 -1
-1
-2
-2
-3
-3
1
2
3
5
Domain and Co-domain
Definition 2:
If f is a function from A to B, we say that A is the domain of f
and B is the co-domain of f.
if f(a) = b, we say that b is the image of a and a is a preimage of b.
The range of f is the set of all images of elements of A.
Also, if f is a function from A to B, we say f maps A to B.
6
Example 2 - Function
f(x) = x2
Example 2:
Z = domain of f
Z
Znonneg
Znonneg = co-domain of f
• 4 is the image of -2
• -2 is a pre-image of 4
• 2 is also a pre-image of 4
• 3 has no pre-image
• Range(f) = {0, 1, 4, 9, 16, 25, ….}

2
1
0
1
2


•4
•3
•2
•1
•0
7
Example 3 - Functions vs. Nonfunctions
Example 3. Which of the arrow diagrams defines a function from
X = {a,b,c} to Y = {1,2,3,4} ?
f
a
b
c
g
1
2
3
4
a
b
c
h
1
2
3
4
a
b
c
1
2
3
4
8
Image of a Set
Definition 3:
Let f be a functions from A to B and SA.
The image of S is the subset of B that consists of the images of the
elements of S.
We denote the image of S by f(S): f(S) = {f(s)sS}
f:AB
s
S
A
f(s)
f(S)
B
9
Example 4 -Function
Example 4:
Define a function F:P({a,b,c})  Znonneg as follows:
for each XP({a,b,c}), F(X) = X  (number of elements in X)
P({a,b,c})

{a}
{b}
{c}
{a,b}
{a,c}
{b,c}
{a,b,c}
Let S = {,{a},{b},{a,b,c}}. What is F(S) ?
0
1
2
3
4
5

:
Znonneg
F(S)={0,1,3}
10
One-to-One Functions
Definition 4: 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 other words:
“All elements in the domain of f have different images” or
“No element in the co-domain of f has two (or more) pre-images”
Mathematical Description:
f:AB is one-to-one  x1, x2A (f(x1)=f(x2)  x1 = x2 )
or
f:AB is one-to-one   x1, x2A (x1 x2  f(x1)f(x2))
11
Example 5 - One-to-One
Example 5:
Which of the following functions is one-to-one?
A
B
a
b
c
1
2
3
4
A
B
a
b
c
1
2
3
4
12
Example 6 - One-to-One
Example 6:
Is f: R  R, f(x) = 4x1 one-to-one?
f(x)
(“Does each element in R have a different image ?”)
Yes !
To show: x1, x2  R (f(x1)=f(x2)  x1= x2)
Suppose arbitrary x1, x2  R with f(x1) = f(x2).

x1
x
x2

Then 4x11 = 4x21  4x1 = 4x2  x1=x2
13
Example 7 - One-to-One
Example 7:
Is g: R  R, g(x) = x2 one-to-one?
g(x)
(“Does each element in R have a different image ?”)
No !

 4
To show:  x1, x2  R (g(x1)=g(x2)  x1 x2)
Take x1 = 2 and x2 = 2.
2
2
x
Then g(x1) = 22 = 4 = (2)2 = g(x2) and x1 x2
14
Onto Functions
Definition 5:
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 other words:
“Each element in the co-domain of f has a pre-image”
Mathematical Description:
f:XY is onto  y x, f(x) = y
15
Example 8 - Onto
Example 8:
Which of the following functions is onto?
X
Y
a
b
c
d
1
2
3
X
Y
a
b
c
d
1
2
3
16
Example 9 - Onto
Example 9:
Is g:RR, g(x)=x2 onto ?
(“Does each element in R have a pre-image ?”)
g(x)
No !
To show: yR such that xR g(x)  y
R0
Take y = 1
x
1
Then any xR holds g(x) = x2  1 = y
But g:RR0, g(x)=x2 ,(where R0 denotes the set of nonnegative real numbers) is onto !
17
Example 10- One-to-one & Onto
Example 11:
Is f:ZnonnegZnonneg  Znonneg, f(l,m)=l + m Znonneg Znonneg
onto or one-to-one or both ?
Onto: “Does each elements in Znonneg
have a pre-image ?” Yes !
Let n Znonneg.
Then f(0,n)= 0+n = n
One-to-one: Does each element in Znonneg
have a different image ? No !
f((1,1))= 1+1 = 2 = 2+0 = f((2,0))
(0,0)
(0,1)
(1,0)
(1,1)
(2,0)
(0,2)
(2,1)
(1,2)
(3,0)
(0,3)
(4,0)
:
Znonneg
0
1
2
3
4

:
18
One-to-one Correspondence
Definition 6:
A function f is a one-to-one correspondence (or bijection),
if and only if it is both one-to-one and onto
In other words:
“No element in the co-domain of f has two (or more) pre-images”
(one-to-one) and
“Each element in the co-domain of f has a pre-image” (onto)
Each element in the co-domain of f has exactly one pre-image
19
Example 11 - One-to-one & Onto
Example 11:
Which of the following functions is a bijection?
a
b
c
1
2
3
4
a
b
c
d
1
2
3
a
b
c
d
1
2
3
4
a
b
c
d
1
2
3
4
a
b
c
1
2
3
4
20
Inverse Functions
Definition 1:
Let f:AB be a one-to-one correspondence
Then there is a function f1:BA, that is defined as follows:
f1(b) = that unique element aA such that f(a)=b.
f1 is called the inverse function of f
f
A
B
f(a)=b
b
a
f1(b)=a
In other words, if f maps a to
b, then f-1 maps b back to a
f1
21
Example 12 - Inverse
Example 12:
Find the inverse function of the following function:
A
a
b
c
d
f
A
B
1
2
3
4
a
b
c
d
f1
B
1
2
3
4
Let f:AB be a one-to-one correspondence and f1:BA its inverse.
Then it holds bB aA (f1(b)=a  f(a)=b)
22
Invertible
f
A
B
f(a)=b
b
a
f1(b)=a
f1
• A one-to-one correspondence is called invertible
• A function is not invertible if it is not a one-to-one
correspondence (since the inverse of such a function does
not exist)
23
Example 13 - Inverse
Example 13:
f(x)
What is the inverse of f:RR, f(x)=4x1?
Let yR.
Calculate x with f(x)=y: y = 4x1  (y+1)/4 = x
y
x=f-1(y)
x
Hence, f1(y) = (y+1)/4
24
One-to-one Correspondence
Theorem 1: If f:XY is a one-to-one correspondence,
then f1:YX is a one-to-one correspondence.
Proof:
(a) f1 is one-to-one:
take arbitrary y1,y2 Y such that f1(y1) =f1(y2)
to show: y1 = y2
Let x = f1(y1) = f1(y2)
Then f(x) = y1 and f(x) = y2 by definition
of inverse function
Therefore, y1 = y2
f
X
x
Y
f(y1)
f(y2)
y1
y2
f
25
One-to-one Correspondence
Theorem 1: If f:XY is a one-to-one correspondence,
then f1:YX is a one-to-one correspondence.
Proof:
(b) To show f1 is onto:
f
X
take arbitrary xX
to show: yY such that f1(y) = x
x
Y
f(x)
f(y)
y
Let y = f(x)
Then f1(y) = x
f
26
Composition of Functions
Definition 2:
Let f:AB and g:BC be functions. The composition of the
functions f and g, denoted as g ° f, is defined by: g ° f: A C, (g °
f)(a) = g(f(a)) --- it composes (creates) a new function out of f
g°f
and g!!
A
f
g
B
f(a)
C
g(f(a)) = (g°f)(a)
a
27
Example 14 - Composition
Example 14:
Let f:ZZ, f(n)=2n+3 and g:ZZ, g(n)=3n+2.
What is f ° g and g ° f?
(f ° g)(n) = f(g(n)) = f(3n + 2) = 2(3n+2) + 3 = 6n + 7
(g ° f)(n) = g(f(n)) = g(2n + 3) = 3(2n+3) + 2 = 6n + 11
Hence, f ° g  g ° f
Hence, the commutative law does not hold for the composition
of functions !
28
Example 15 - Composition
Example 15:
X
Given functions
s:XY and t:YZ.
Find t ° s.
X
a
b
c
t°s
s
a
b
c
Z
Y
Y
1
2
3
4
5
1
2
3
4
5
t
Z
m
n
p
q
m
n
p
q
29
Example 16 - Composition
Example 16:
X
Given functions
s:XY and t:YZ .
Find s ° t.
a
b
c
s°t
Y
1
2
3
4
5
t
Z
m
n
p
q
X
a
b
c
s
s
Y
Y
1
2
3
4
5
1
2
3
4
5
t
Z
m
n
p
q
Y
1
2
3
4
5
30
Exercise
f : R  R
f ( x) 
1
1  e x
e.g. Define a function
by
. Is this function
one-to-one? Is this function onto? Justify your answers.
31
Summary

Functions




One-to-One Functions (Injection)



y x, f(x) = y, each element in the co-domain has (at least) a pre-iamge
One-to-one correspondence (Bijection)


x1, x2A (f(x1)=f(x2)  x1 = x2 ), no element in the co-domain has 2 or more pre-images
Onto Functions (Surjection)


f:AB is an assignment of exactly one element of B to each element of A
Domain, co-domain
Image, pre-image
Both one-to-one and onto, each element in the co-domain has exactly one pre-image.
Let f:AB be a one-to-one correspondence
Then there is the inverse function f1:BA, that is defined as follows:
f1(b) = that unique element aA such that f(a)=b.
Let f:AB and g:BC be functions. The composition of the functions f and g,
denoted as g ° f, is defined by: g ° f: A C, (g ° f)(a) = g(f(a))
32