Title: Discrete Structures Chapter 5
1Discrete StructuresChapter 5 Relations and
Functions
Nurul Amelina Nasharuddin Multimedia Department
2Objectives
- On completion of this chapter, student should be
able to - Define a relation and function
- Determine the type of function (one-to-one, onto,
one-to-one correspondence) - Find a composite function
- Find an inverse function
3Outline
- Cartesian products and relations
- Functions Plain, one-to-one, onto
- Function composition and inverse functions
- Functions for computer science
- Properties of relations
- Computer recognition Zero-one matrices and
directed graphs - Use in database example
4Identity Function (pg 394)
- The function 1A A ? A, defined by 1A (a) a for
all a ? A, is called the identity function for A - It is a function that always returns the same
value that was used as its argument. In terms of
equations, the function is given by f(x) x - 1X(x) x for all x in X
5Function Equality
- When are f and g equal?
- If f, g A ? B, we say that f and g are equal and
write f g, if f (a) g (a) for all a ? A - Eg Define f R ? R and g R ? R by the
following formulas - f(x) x for all x ? R
- g(x) vx2 for all x ? R
- Does f g? Yes, x vx2 for all x ? R
6Composite Function
- Function composition is an operation for
combining two functions - If f A ? B and g B ? C, we define the composite
function, which is denoted g o f A ? C, - by (g o f )(a) g (f(a)), for each a ? A
7Example (1)
Let A 1, 2, 3, 4, B a, b, c, and C w,
x, y, z with f A ? B and g B ? C given by f
(1, a), (2, a), (3, b), (4, c) and g (a, x),
(b, y), (c, z). For each element of A we
find (g o f) (1) g (f (1)) g (a) x (g o f)
(2) g (f (2)) g (a) x (g o f) (3) g (f
(3)) g (b) y (g o f) (4) g (f (4)) g (c)
z So g o f (1, x), (2, x), (3, y), (4, z)
8Example (2)
- Are f o g and g o f equal?
- Let f R ? R, g R ? R be defined by f (x) x2,
- g(x) x 5. Then
- (g o f)(x) g (f(x)) g(x2) x2 5, whereas
- (f o g)(x) f (g(x)) f(x 5) (x 5)2 x2
10x 25 - Here g o f R ? R and f o g R ? R, but
- (g o f)(1) 6 ? 36 (f o g)(1), so even though
both composites f o g and g o f can be formed, we
do not have f o g g o f
9Example (3)
- Let f, g, h R ? R, where f(x) x2, g(x) x 5
and h(x) - Then, ((h o g) o f)(x) (h o g)(f(x)) (h o
g)(x2) - h(g(x2)) h(x2 5)
-
-
10Example (4)
- Let f, g, h R ? R, where f(x) x2, g(x) x 5
and h(x) - Find (h o (g o f))(x).
- Is (h o (g o f)) ((h o g) o f)?
- Yes. Using the definition of the composite
function, we find that - ((h o g) o f) (x) (h o g) (f (x)) h ( g
(f (x))), whereas - (h o (g o f )) (x) h ((g o f ) (x)) h (g
(f (x))).
11Associative Property
Since ((h o g) o f)(x) h (g(f(x))) (h o (g o
f))(x), for each x in A, it now follows that (h o
g) o f h o (g o f)
12Composition with an Identity Function
- If f is a function from a set A to a set B, and
1A is the identity function on A and 1B is the
identity function on B, then - f o 1A f 1B o f
13Example (1)
- Let X a,b,c,d and Y u,v,w and f (a,
u), (b, v), (c, v), (d, u). Find f o 1X and 1Y o
f - (f o 1x)(a) f(1x(a)) f(a) u
- (f o 1x)(b) f(1x(b)) f(b) v
- (f o 1x)(c) f(1x(c)) f(c) v
- (f o 1x)(d) f(1x(d)) f(d) u
- So, (f o 1x)(x) f(x)
- Find (1Y o f ) and show that for (1Y o f)(x)
f(x)
14Properties of Composite Function
Let f A ? B and g B ? C a) If f and g are
one-to-one, then g o f is one-to-one b) If f and
g are onto, then g o f is onto
15Converse of a Function
- Since a function is also a relation, first let us
see the converse of a relation - For sets A, B, if R is a relation from A to B,
then the converse of R, denoted Rc, is the
relation from B to A defined by R (b, a)(a,
b) ? R - Eg A 1, 2, 3, 4, B w, x, y, and R (1,
w), (2, w), (3, x) then Rc (w, 1), (w, 2),
(x, 3), a relation from B to A
16Example (1)
- For A 1, 2, 3 and B w, x, y, let f A ? B
be given by f (1, w), (2, x), (3, y) - Then f c (w, 1), (x, 2), (y, 3) is a
function from B to A, and we observe that - f c o f 1A and f o f c 1B
- f c o f(1) f c(w) 1
- f c o f(2) f c(x) 2
- f c o f(3) f c(y) 3
- f c o f (1,1), (2,2), (3,3) 1A
17Invertibility of a Function
- If f A ? B, then f is said to be invertible if
there is a function g B ? A such that - g o f 1A and f o g 1B
- A function f A ? B is invertible iff it is
one-to-one and onto
18Example (1)
- Let f, g R ? R be defined by
- f(x) 2x 5,
- g(x) (1/2)(x 5). Then
- (g o f)(x) g(f(x)) g(2x 5)
- (1/2)(2x 5) 5 x, and
- (f o g )(x) f(g (x)) f((1/2)(x 5))
- 2(1/2)(x 5) 5 x
- So f o g 1R and g o f 1R. Consequently, f and
g are both invertible functions
19Inverse Functions
Suppose f X ? Y is a one-to-one correspondence.
Then inverse function, f-1 Y ? X that is defined
as follows Given any element in Y, f-1(y) that
unique element x in X such that f(x) equals y In
other words, f-1(y) x ? y f(x)
20Finding an Inverse Function
- Find the inverse function for f(x) 4x 1for
all real numbers x - By definition of f-1(y) that unique real number
x such that f(x) y - f(x) y
- 4x - 1 y
- x (y 1)/4
- f -1(y) x, hence f -1(y) (y 1)/4
- Rename y by x, f -1(x) (x 1)/4
21(No Transcript)
22Quiz 4A
- Let f Z?Z be the successor function and let g
Z?Z be the squaring function. Then f(n) n 1
for all n ? Z and g(n) n2 for all n ? Z. (a)
Find the compositions g o f and f o g. (b) Is g o
f f o g? Explain. - Let X a,b,c,d and Y u,v,w, and suppose f
X ? Y is given by (a, u), (b, v), (c, v), (d,
u). Find f o 1X and 1Y o f. - f R ? R is defined by f(x) 3x 5. Find its
inverse function.
Send your answers in the next class!