Professional Documents
Culture Documents
Exercise 7
Functions
Solution:
Discrete Mathematics 1
Exercise 7
a) is a function.
b) is not a function, since 1 can not be mapped by the given rule.
c) is not a function, because 2 can be mapped by both of the rules in different
images.
Exercise 2: Let A={1,2,3}, B={a,b,c,d}. Find one injection from A to B and one
surjection from B to A.
1
Solution: f: AB injection f :
c
a
g: BA surjection g :
3
2
a
b
2
d
c d
.
1 3
a) f: {a,b,c,d} {a,b,c} f :
a c c b
b) f: f(x)=2x+1
c) f: f(x)=2x+1
Solution:
a) f is not an injection, because c is an image of 2 elements. But it is a
surjection, because all elements of the codomain are images of some elements of
the domain.
b) Let f(x)=f(y) 2x+1=2y+1 x=y f is an injection.
There is no element of that is mapped to 2 , therefore f is not a surjection.
c) Let f(x)=f(y) 2x+1=2y+1 x=y f is an injection.
Let y , then (y-1)/2 , f((y-1)/2)=y f is a surjection.
Exercise 4: Find the properties and compositions of the given functions. Then find
the compositions properties.
a) f:
b) f:
c) f:
d) f:
f(x)=3x-1
f(x)=x2
f(x)=2x
f(x)=5x
g:
g:
g:
g: +
g(x)=[x]
g(x)=(-1)x x
g(x)=x-1
g(x)= x2
Solution:
a) Let f(x)=f(y) 3x-1=3y-1 x=y f is an injection.
Let y , then (y+1)/3 , and f((y+1)/3)=y f is a surjection.
g(1)=1=g(1.1), so it follows that g is not an injection.
Let y , then [y]=y , and g(y)=y g is a surjection.
Discrete Mathematics 1
Exercise 7
gf:
gf(x)=[3x-1]
gf(1)=[3-1]=2=[3.3-1]=g(1.1), so it follows that gf is not an injection.
Let y , then [y]=y and (y+1)/3 , so gf((y+1)/3)=[y]=y g is a surjection.
The composition f could not be defined because the codomain of g differs from
the domain of f.
b) Let f(x)=f(y) x2=y2 and because x and y are natural numbers it follows
that x=y f is an injection.
2 is not an image of any number f is not a surjection.
Let g(x)=g(y) (-1)x x =(-1)y y=a. a is either positive or negative. If it is
positive, then x and y are even numbers, so (-1)x x =x and (-1)y y=y from which it
follows that x=y.
If is negative, then x and y are odd numbers, so (-1)x x =-x and (-1)yy= -y
from which it follows that x=y. From both arguments it follows that g is an injection.
1 is not an image of any number g is not a surjection.
gf:
gf(x)= (1) x x2
2
is positive, then x2 and y2 are even numbers, i.e. x and y are even numbers, so (1) x
x2=x2 and (1) y y2=y2 from which it follows that x2=y2. Since x and y are natural
numbers, it follows that x=y.
2
If is negative, then x2 and y2 are odd numbers, so (1) x x2=-x2 and (1) y
y2=-y2 and because the numbers are natural, it follows that x=y. From both
arguments it follows that gf is an injection.
1 is not an image of any number gf is not a surjection.
2
As it was the case in ), the composition f could not be defined because the
codomain of g differs from the domain of f.
c) Let f(x)=f(y) 2x=2y x=y f is an injection.
Let y , then y/2 , and f(y/2)=y f is a surjection.
Let g(x)=g(y) x-1=y-1 x=y g is an injection.
Let y , then y+1 , and g(y+1)=y g is a surjection.
gf: gf(x)= 2x-1
Let gf(x)=gf(y) 2x-1=2y-1 x=y gf is an injection.
Let y , then (y+1)/2 , and g((y+1)/2)=y gf is a surjection.
The composition f can be defined. ( homework )
Discrete Mathematics 1
Exercise 7
1 2 3 4
f:AB f :
a b b a
1 2 3 4
h: AC h :
y z w x
If possible, find a function g: BC, such that h=gf.
Solution:
It is not possible, because if there is such g: BC, then f must be an injection (since
h is an injection), but f is not an injection.
a b c
. Find a
Exercise 6: Let A={a,b,c}, B={a,b,c,d} and f:AB is defined by f :
a d b
function g: BA, such that gf=1A.
Solution:
a b c d
. (It is possible because f is an injection).
g: BA , g :
a c c b
Discrete Mathematics 1
Exercise 7
Solution:
g: , g(x)=2(x-1). ( This is possible because f is an injection ).
1 2 3 4
.
Exercise 8: Let A={1, 2, 3, 4}, B={1, 2, 3} and g: AB is defined by g :
1 1 2 3
Find a function f: BA, such that gf=1B.
1 2 3
. ( This is possible because g is a surjection ).
Solution: f: BA , f :
1 3 4
Exercise 9: Let g: + be defined by g(x)=x2. Find a function f: + , such that
gf=1R+.
Solution:
f: + , f(x)= x . ( This is possible because g is a surjection ).
Discrete Mathematics 1
Exercise 7
Exercise 12: Give examples for a function f: XY and sets A, BX, such that f(AB)
f(A)f(B).
Solution:
1 2 3
. Then f(AB)={b}, and
Let X={1, 2, 3}, Y={a, b}, A={1, 2}, B={2, 3} f :
a b a
f(A)f(B)={a, b}{a, b}={a, b} and they are different.
Exercise 14: Prove that for each function f: XY and sets A, BX it holds that f(AB)
= f(A)f(B).
Solution:
Let y f(AB). This means that there is x AB, such that f(x)=y. Hence, there is an
element x, such that xA or xB, and f(x)=y i.e. there is xA, such that f(x)=y or
there is xB, such that f(x)=y xf(A) xf(B) x f(A)f(B).
Exercise 15: Let f: XY be a given function and AX, BY. Prove that:
) Af-1(f(A)),
b) f(f-1(B))B,
c) f(A)B iff Af-1(B).
Discrete Mathematics 1
Exercise 7
Solution:
) Let aA. It is obvious that f(a)f(A), from which it follows that f-1(f(A)), i.e.
Af-1(f(A)).
b) If yf(f-1(B)), then y=f(x), f(x)B i.e. yB. Hence f(f-1(B))B.
c) : Let Af-1(B). Then f(A)f(f-1(B)) and from f(f-1(B))B it follows that f(A)B.
: Let f(A)B. Then f-1(f(A))f-1(B) and from Af-1(f(A)) it follows that Af-1(B).
So f(A)B Af-1(B).
Exercise 16: Find the domain and codomain of the functions () = 2 , () =
( )2 , h(x) = |x| and find their properties. Find their compositions ( if possible ).
Answer:
f: + {0} , is not an injection, it is a surjection.
g: + {0} + {0} , is an injection and surjection ( so it is a bijection ).
h: + {0} is not an injection, it is a surjection.
g : + {0} g () = (()) = ( 2 ) = ( 2 )2 ,
g : + {0} g () = (()) = (||) = (|| )2 = ||
Exercise 17: Prove that: f: X Y is an injection iff for any set A and any functions g1
,g2: AX it is true that fg1=fg2 g1=g2.
Solution:
: Let f: XY be an injection and let be any set such that:
g1,g2: AX, fg1=fg2.
Let x . From fg1=fg2 it follows that fg1(x)=fg2(x) i.e. f(g1(x))=f(g2(x)) so from the
fact that f is an injection it follows that g1(x)=g2(x). Since xA is an arbitrary element,
it follows that g1=g2.
: Let it hold fg1=fg2 g1=g2, for any set A and for any functions g1 ,g2:AX
Let us assume that f is not an injection. This means that (x1,x2 X) i.e. x1 x2, but
f(x1)=f(x2)=y. Let us define =, g1: AX with g1(a)= x1, g2: AX with g2(a)= x2
then:
fg1(a)=f(g1(a))=f(x1)=f(x2)=f(g2(a))=fg2(a),
so fg1= fg2, a g1 g2, which is a contradiction.Thus, f is an injection.
Discrete Mathematics 1
Exercise 7
Exercise 18: Prove that: f: XY is a surjection iff for each set A and functions g1
,g2:YA it is true that g1f=g2f g1=g2.
Solution:
: Let f: XY be a surjection and let be a random set such that:
g1,g2: AX, g1f=g2f.
Let y Y. From the fact that f is a surjection, (xX), such that y=f(x). Then
g1(y)=g1(f(x))= g1f(x)=g2f(x)=g2(f(x))=g2(y).
From the randomness of yY follows that g1=g2.
: For a given set A and functions g1 ,g2: AX let
fg1=fg2 g1=g2.
Let us assume that f is not a surjection. It means that (y Y) such that (xX)
yf(x), i.e. (y Y) yf(X). We define =1, a2
g1: YA with g1(y)= a1 , (yY)
a1 y f ( X )
g2: YA with g 2 ( y )
a 2 y f ( X )
then:
g1f(x)=g1(f(x))=a1=g2(f(x))=g2f(x),
so g1f= g2f, a g1 g2, which is a
contradiction, from which it follows that f is a surjection.
Discrete Mathematics 1
Exercise 7
Solution:
According to the explanation in ) in the previous exercise, we conclude that f is an
injection and a surjection, which means that it is a bijection. From this conclusion it
follows that there is an inverse function f -1: NM. Let us find it:
f(1)=gf -1(g)=1
f(4)=ef -1(e)=4
f(2)=af -1(a)=2
f(5)=df -1(d)=5
f(3)=bf -1(b)=3
f(6)=cf -1(c)=6.
a b c d e g
.
So, we get the inverse function f 1 :
2 3 6 5 4 1
Discrete Mathematics 1
Exercise 7
Note: Which properties will a function have, depends not only on the function's
definition, but also on the domain and codomain. For examples, if the function
f(x)=|x| is considered as f: + , then f is an injection, but not a surjection. If it is
considered as f: + +, then f is an injection and surjection, i.e. it is a bijection.
Exercise 22: Let A={1,2,3,4,6}, B={a,b,c,d,e}, C={x,y}, and the functions f: AB, g:
1 2 3 4 5 6
a b c d e
and g :
. Find the
BC are defined by: f :
d a b a d c
x x y x y
composition gf.
Solution: Since the domain of g is equal to the codomain of f, there is a composition
gf: A C. By definition, gf(x)= g(f(x)), for every xA.
gf(1)= g(f(1))=g(d)= x;
gf(3)= g(f(3))=g(b)= x;
gf(5)= g(f(5))=g(d)= x;
gf(2)= g(f(2))=g(a)= x;
gf(4)= g(f(4))=g(1)= x;
gf(6)= g(f(6))=g(c)= y; so
1 2 3 4 5 6
gf :
x
x
x
x
x
y