5 Funtions
5 Funtions
Definition of a Function.
Domain, Codomain
Image, Preimage
Injection, Surjection, Bijection
Inverse Function
Function Composition
Graphing Functions
Floor, Ceiling, Factorial
Partial Functions
Functions
Definition: Let A and B be nonempty sets. A function f
from A to B, denoted f: A → B is an assignment of each
element of A to exactly one element of B. We write
f(a) = b if b is the unique element of B assigned by the
function f to the element a of A. Students Grades
A
Functions are sometimes Ankit
B
called mappings or
Rahul
C
transformations.
Sounak D
F
Shrinika
Functions
A function f: A → B can also be defined as a subset of
A×B (a relation). This subset is restricted to be a
relation where no two elements of the relation have
the same first element.
and
Functions
Given a function f: A → B:
We say f maps A to B or
f is a mapping from A to B.
A is called the domain of f.
B is called the codomain of f.
If f(a) = b,
then b is called the image of a under f.
a is called the preimage of b.
The range of f is the set of all images of points in A under f. We
denote it by f(A).
Two functions are equal when they have the same domain, the
same codomain and map elements of their common domain to
the same elements in their common codomain.
Representing Functions
Functions may be specified in different ways:
A formula.
f(x) = x + 1
A computer program.
A C-language program that when given an integer n, produces
the nth Fibonacci Number.
Questions on Functions
f(a) = ? z A B
a
The image of d is ? z x
b
The domain of f is ? A y
c
The codomain of f is ? B
d z
The preimage of y is ? b
f(A) = ? {y,z}
The preimage(s) of z is (are) ? {a,c,d}
Questions on Functions
Example 1: Let 𝑓: ℤ → ℤ and 𝑓 𝑥 = 𝑥 2 . What is the
domain, codomain and range of 𝑓?
f {c,d} is ? {z} d z
Injections
Definition: A function f is said to be one-to-one, or
injective, if and only if f(a) = f(b) implies that a = b for
all a and b in the domain of f. A function is said to be
an injection if it is one-to-one.
A B
a x
v
b
y
c
z
d
w
Showing that f is one-to-one or not
Example 1: Let 𝑓: ℝ → ℝ and 𝑓 𝑥 = 𝑥 + 1. Is f an
one-to-one function?
A B
a x
b
y
c
z
d
Showing that f is onto or not
Example 1: Let f be the function from {a,b,c,d} to {1,2,3}
defined by f(a) = 3, f(b) = 2, f(c) = 1, and f(d) = 3. Is f an
onto function?
Solution: Yes, f is onto since all three elements of the
codomain are images of elements in the domain.
A B
a x
b
y
c
z
d
w
Examples of Different Types of Correspondences
b b
W W
c c
d X X
d
Y Y
Questions
Example 1: Let f be the function from {a,b,c} to {1,2,3}
such that f(a) = 2, f(b) = 3, and f(c) = 1. Is f invertible
and if so what is its inverse?
𝑓 2 = 𝑓 −2 = 4, but 2 ≠ −2.
and
Composition Questions
Example 2: Let g be the function from the set {a,b,c} to itself
such that g(a) = b, g(b) = c, and g(c) = a. Let f be the function
from the set {a,b,c} to the set {1,2,3} such that f(a) = 3, f(b) = 2,
and f(c) = 1.
What is the composition of f and g, and what is the composition
of g and f.
Solution: The composition f∘g is defined by
f∘g (a)= f(g(a)) = f(b) = 2.
f∘g (b)= f(g(b)) = f(c) = 1.
f∘g (c)= f(g(c)) = f(a) = 3.
Note that g∘f is not defined, because the range of f is not a subset of
the domain of g.
Composition Questions
Example 3: Let f and g be functions from the set of
integers to the set of integers defined by f(x) = 2x + 3
and g(x) = 3x + 2.
What is the composition of f and g, and also the
composition of g and f ?
Solution:
f∘g (x)= f(g(x)) = f(3x + 2) = 2(3x + 2) + 3 = 6x + 7
g∘f (x)= g(f(x)) = g(2x + 3) = 3(2x + 3) + 2 = 6x + 11
Graphs of Functions
Let f be a function from the set A to the set B. The
graph of the function f is the set of ordered pairs
{(a,b) | a ∈A and f(a) = b}.
Example:
Floor and Ceiling Functions
Case 2: ε≥½
2x = 2n + 2ε = (2n + 1) +(2ε − 1) and ⌊2x⌋ =2n + 1,
since 0 ≤ 2 ε - 1< 1.
⌊x + 1/2⌋ = ⌊ n + (1/2 + ε)⌋ = ⌊ n + 1 + (ε – 1/2)⌋ = n + 1 since
0 ≤ ε – 1/2< 1.
Hence, ⌊2x⌋ = 2n + 1 and ⌊x⌋ + ⌊x + 1/2⌋ = n + (n + 1) = 2n + 1.
Factorial Function
Definition: f: N → Z+ , denoted by f(n) = n! is the
product of the first n positive integers when n is a
nonnegative integer.
f(n) = 1 ∙ 2 ∙∙∙ (n – 1) ∙ n, f(0) = 0! = 1
Examples:
f(1) = 1! = 1
f(2) = 2! = 1 ∙ 2 = 2
f(6) = 6! = 1 ∙ 2 ∙ 3∙ 4∙ 5 ∙ 6 = 720
f(20) = 2,432,902,008,176,640,000.
Partial Functions
Definition: A partial function f from a set A to a set B is an
assignment to each element a in a subset of A, called the
domain of definition of f, of a unique element b in B.
The sets A and B are called the domain and codomain of f,
respectively.
We say that f is undefined for elements in A that are not in
the domain of definition of f.
When the domain of definition of f equals A, we say that f is a
total function.
Examples:
1. Let a = 1 and r = −1. Then:
3. Let a = 1 and d = 2:
Strings
Definition: A string is a finite sequence of characters
from a finite set (an alphabet).
Answer:
f 2 = f 1 + f 0 = 1 + 0 = 1,
f 3 = f 2 + f 1 = 1 + 1 = 2,
f 4 = f 3 + f 2 = 2 + 1 = 3,
f 5 = f 4 + f 3 = 3 + 2 = 5,
f 6 = f 5 + f 4 = 5 + 3 = 8.
Solving Recurrence Relations
Finding a formula for the nth term of the sequence
generated by a recurrence relation is called solving the
recurrence relation.
a2 = 2 + 3
a3 = (2 + 3) + 3 = 2 + 3 × 2
a4 = (2 + 3 × 2) + 3 = 2 + 3 × 3
.
.
.
an = an-1 + 3 = (2 + 3 × (n – 2)) + 3 = 2 + 3(n – 1)
Iterative Solution Example
Method 2: Working downward, backward substitution
Let {an} be a sequence that satisfies the recurrence relation
an = an-1 + 3 for n = 2,3,4,… and suppose that a1 = 2.
an = an-1 + 3
= (an-2 + 3) + 3 = an-2 + 3 × 2
= (an-3 + 3 )+ 3 × 2 = an-3 + 3 × 3
.
.
.