Functions
Ms. Rachana Pathak
(
[email protected])
Assistant Professor, Dept of Computer Science and Engineering
Walchand Institue of Technology, Solapur
(www.witsolapurcorg)
Learning Outcome
Ci
At the end of this session,
Students will be able to explain Functions in Discrete Mathematical
Structures.
Definition of a function 7
+ A function takes an element from a set and maps it to a
UNIQUE element in another set
Domain & Pompe Re z Co-domain
ge
Image of 4.3
ai PreSeage of 4 / ,Definition Ci
+ Given any sets A, B, a function / from (or “mapping”") A to B
(fA-B) is an assignment of exactly one element f(yeB
to each element xeA.
&
wed mnie Teccigs Sow
Graphical Representation Ci&
Terminologies Ci
If AB, and fla)=b (where acA & beB), then:
+ Ais the domain of f.
* Bis the codomain off.
+ bis the image of a under /.
* ais a pre-image of b under f-
* In general, b may have more than one pre-image.
* The range RCB of fis {b | da flaj=b }.Think & Write Ci
Suppose that: “fis a function mapping students in this class to
the set of grades {A,B,C,D,E}.”
At this point, you know fs codomain is: and its
range is ‘
Suppose the grades turn out all As and Bs.
Then the range of f is but its codomain is
Answer Ci
Suppose that: “fis a function mapping students in this class to
the set of grades {A,B,C,D,E}.”
At this point, you know fs codomain is: _!4:8.C0-6) and its
range is_unknown ,
Suppose the grades turn out all As and Bs.
Then the range of fis _A.B but its codomain is
{AB.C.D.E}Injections
Definition: a function f is said to be one-to-one if and only if
for all a and b in the domain, f(a) = f(b) implies that a = b.
A function is said to be an injection if it is one-to-one.
Xx Bg x xy X ¥
\f \_f \ f
|| |
[| ae
YES! YES! NO!Surjections
Definition: a function f from A to B is called onto, if and only if
for every element b _ Y, there isan element a || X with f(a) = b.
© A function fis called a surjection if it is onto.
X ¥ Xx x Xx x
\ f \ \_f
| | |
[ | ae
NO! YES! YES!Bijections
Definition: a function fis a bijection (one-to-one correspondence),
if it is both one-to-one and onto, i.e., both surjective and injective.
A B
x x & (x) Xx ¥
7 ® . \/
| Q -
[\ a
©)
YES! me NO!
surjection but not injectionShowing that f is one-to-one or onto
Example 1: let f be a 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 fan onto
function?
Solution: Yes, f is onto since all three elements of the codomain
are images of elements in the domain. If the codomain were
changed to { 1, 2, 3, 4}, f would not be onto.
Example 2: is the following function f(x): Z > Z, where Z is the
set of integers and f(x) = x* onto?
Solution: No, f is not onto because, e.g., —1 in the codomain
does not have a preimage in the domian.P a=
Inverse Functions
Definition: let f be a bijection from A to B. Then the inverse
of f, denoted by f~', is the function from B to A defined as
f"(y) = vif f(x) = y
© No inverse exists unless f is a bijection.
fyP a=
Inverse Functions
Definition: let f be a bijection from A to B. Then the inverse
of f, denoted by f~', is the function from B to A defined as
f"(y) = vif f(x) = y
© No inverse exists unless f is a bijection.
fyO@ ©
A
@)
(b)
©)
@)
O©@ © @xa
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?
Solution: the function f is invertible because it is a one-to-one
correspondence (bijection).
The inverse function f~! reverses the correspondence given by
function f, therefore, f-1(1) =c, f-1(2)=a, and f-! (3) =b.Questions
Example 2: let f: Z > Z be such that f(x) =x + 1. Is f invertible,
and if so, what is its inverse?
Solution: the function f is invertible because it is a one-to-one
correspondence (bijection). The inverse function f~! reverses
the correspondence so f~! (y) =y- 1.
Z
@)
C4)
ii
ilComposition
Definition: let f: B = C,g:A > B. The composition of
function f with function g, denoted by fog, isa function
from A to C defined by
fog(z) = f(g(x))
{f 2 aie)P SSComposition
Example 1:if f(x) =a? and g(«) = 2a +1, then
f(g(x)) = (2a + 1)?
and
g(f(a)) = 2a? +1
Since f(g (x) ) =f( 2x+1) = (2x41)?
and g (f(x) ) =9 (x?) =2 (x2) +1 =2x241Composition Questions
Bemis 2: let g be the function from the set { a, b, c } to itself
such t
from the set {a, b, c } tothe set
at g (a) =b,g (b) =c, eal (c) =a. Let f be the function
al
and f(c) =1.
2,3)}s.t. om 3,f (6) = 2,
What are the compositions of fo g and g of ?
Solution: The composition f° g is defined by
fog (a)=f(g(a)) =f(b) = 2.
fog (b)=f(g(b)) =f(c) = 1.
fog (c) =flglc)) =f (a) = 3.
Note that g o f is not defined, because the codomain of f is not a
subset of the domain of g.Composition Questions
Example 2: let fand 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 fand g, and also the composition
of g and f?
Solution:
feg CO=f (¢@)) =f (8x + 2) = 2(3x + 2) +3 =6x+7
gof (x)= 9 (F(X) = 9 (2x + 3) = 3(2x4+ 3) +2 =6x411P Ss
Graphs of Functions
© Let f bea function from the set A to the set B. The graph
of the function fis the set of ordered pairs
{(a, b) |a € Aand f (a) = b}.
fo
eens aoe
6 . °
Pea) ae
che en
Graph of f (n) = 2n + 1 Graph of f (x) = x*
from Z to Z from Z to Za
Some Important Functions
© The floor function, denoted
f(z) = [2]
is the largest integer less than or equal to x.
© The ceiling function, denoted
F(x) = [2]
is the smallest integer greater than or equal to x
Example: [3.5] =4 [3.5] =3
[-1.5]=-1 |[-1.5} =-2= oo
bye bt
Graph of (a) Floor and (b) Ceiling Functionsa
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)=1x«2™..«(n-1) xn, f(@) =o0!=1
Examples:
f@e=u =1
f@Q=2l=1*2=2
f(6@)=6!= 1x2x3«x4x5x6=720
f (20) = 2,432,902,008,176,640,000.
Why f:N—> Z*? — since {0, 1, 2, 3, ...} > { 1, 2,3, ...}