Unit 3 Functions
Unit 3 Functions
1
Definition of a function
• Let A and B be non-empty 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 provided that 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
Pictorial representation of a function f
from A to B
f
b f (a)
a
A B
f
3
A function from {1, 2, 3} to {a, b, c}
1 a
2 b
3 c
4
A function from {0, 2, 3} to {a, b}
0 a
2 b
5
A function from {1, 2} to {1, 2, 3}
1 1
2 2
6
Not a function from {a, b} to {0, 1}
a 0
b 1
7
Not a function from {a, b} to {0, 1}
a 0
b 1
8
Not a function from {a, b} to {0}
a 0
b 1
9
Some terminology
• Let f : A B. We say that A is the domain of f.
The set B is called the codomain of f. If f (a) b,
we say that b is the image of a. We also say
that a is a pre-image of b.
• Functions are also called mappings or
transformations. If f is a function from A to
B, we also say that f maps A to B.
10
Functions in calculus
• In calculus, a function is defined by a formula and
the domain and codomain are usually not
specified. Unless otherwise stated, the domain is
understood to be the set of all real numbers for
which the formula makes sense. The codomain is
understood to be the set of all real numbers.
• For example, the domain of the function f defined
by f ( x) x is understood to be the set of all real
2
11
The Range of a function
• Let f : A B. The range of f is the set of all
images of elements of A. In symbols, the
range of f is the set {b B : b f (a) for some a A}.
This is written in brief as { f (a) : a A}.
12
Bit strings
• A bit string is a string consisting of bits
(zeros and/or ones). The empty string contains
no bits. Two bit strings are equal provided that
they have the same bits in the same order. The
length of a bit string is the number of bits in it.
• For example, 10, 00 and 01 are different bit
strings of length 2 while 101 is a bit string of
length 3.
13
An example
• Let A be the set of all bit strings of length 2 or
more. Let B be the set of all bit strings.
Let f : A B be defined by
f (a) bit string formed by taking the last two bits of a
(for every a A)
The Range of f is {00, 01, 10, 11}.
14
One to one functions
• Let f : A B. We say that f is one to one or
injective provided that
a1 A a2 A ( f (a1 ) f (a2 ) a1 a2 )
Equivalently,
a1 A a2 A (a1 a2 f (a1 ) f (a2 ))
15
Examples
• Let Z be the set of all integers. Let f : Z Z be
defined by f ( x) x 2 x Z . Is f one to one?
Solution: f is not one to one since
f (1) f (1) but 1 1.
16
• Let Z be the set of all integers and let 𝑍 + be the set of
all positive integers. Let
𝑓: 𝑍 + → 𝑍 be defined by 𝑓 𝑥 = 𝑥 2 ∀𝑥 ∈ 𝑍 + .
Is f one to one?
Solution: For all 𝑥 ∈ 𝑍 + and 𝑦 ∈ 𝑍 + ,
f ( x) f ( y )
x2 y2
( x y )( x y ) 0
x y 0 (since x and y are positive)
x y
Hence, f is one to one.
17
Onto functions
• Let f : A B. We say that f is onto or
surjective provided that b B a A ( f (a) b).
18
Examples
• Let Z be the set of all integers. Define
f : Z Z by f ( x) x 2 x Z . Is f onto?
Solution: f is not onto since there is no integer
x with f ( x) x 2 1.
19
• Let Z be the set of all integers. Let
f : Z Z Z be defined by f ((m, n)) m n
(m, n) Z Z .
Is f one to one and is is it onto?
Solution : f is not one to one since
f ((0,1)) f ((1,0)) but (0,1) (1,0).
f is onto since given any b Z ,
f ((0, b)) b.
20
Bijective functions
• A function is said to be bijective provided that
it is one to one and onto. A function which is
bijective is also called a one to one
correspondence or bijection.
21
Inverse functions
Let f : A B be bijective. We define
the inverse of f , denoted by f 1 as follows :
f 1 : B A is defined as follows :
Given any b B, there is a unique a A with f (a) b.
We define f 1 (b) a.
22
Pictorial representation of the inverse
of a bijective function f from A to B
f 1
f
a f 1 (b) b f (a)
A B
23
An example
Let A be the set of all non - negative real numbers.
We define f : A A by f ( x) x 2 x A.
Does f 1 exist? If yes, find it.
Solution (in brief) : It is easily checked that f is bijective
and f 1 ( y ) y y A.
24
Composition of functions
Let g : A B and f : B C.
We define f g : A C by
( f g )(a) f ( g (a)) a A.
25
Pictorial representation of
composition of functions
A B C
g f
f ( g (a))
a g (a)
f g
26
Floor and ceiling functions
For any real number x, we define
floor of x x greatest integer x ,
ceiling of x x smallest integer x.
For example, 4.1 4, 5 5, 6.2 7,
4.1 5, 5 5, 6.2 6.
27