Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Mathematics 3. MATRICES, RELATIONS, AND FUNCTIONS Lecture 6 Dr.-Ing. Erwin Sitompul

Similar presentations


Presentation on theme: "Discrete Mathematics 3. MATRICES, RELATIONS, AND FUNCTIONS Lecture 6 Dr.-Ing. Erwin Sitompul"— Presentation transcript:

1 Discrete Mathematics 3. MATRICES, RELATIONS, AND FUNCTIONS Lecture 6 Dr.-Ing. Erwin Sitompul http://zitompul.wordpress.com

2 6/2 Erwin SitompulDiscrete Mathematics Homework 5 For each of the following relations on set A = {1,2,3,4}, check each of them whether they are reflexive, transitive, symmetric, and/or anti-symmetric: (a)R = {(2,2),(2,3),(2,4),(3,2),(3,3),(3,4)} (b) S = {(1,1),(1,2),(2,1),(2,2),(3,3),(4,4)} (c) T = {(1,2),(2,3),(3,4)} No.1: No.2: Represent the relation R, S, and T using matrices and digraphs.

3 6/3 Erwin SitompulDiscrete Mathematics Solution of Homework 5 Given: A = {1,2,3,4}, then (a)R = {(2,2),(2,3),(2,4),(3,2),(3,3),(3,4)} is not reflexive, because (1,1) and (4,4) are not members of R transitive, proven by(2,2)(2,3)(2,3) (2,2)(2,4)(2,4) (2,3)(3,2)(2,2) (2,3)(3,3)(2,3) (2,3)(3,4)(2,4) (3,2)(2,2)(3,2) a.s.o. not symmetric, because {(4,2),(4,3)}  R not anti symmetric, because there exists (2,3) and (3,2) as members of R while 2  3 No.1:

4 6/4 Erwin SitompulDiscrete Mathematics Solution of Homework 5 Given: A = {1,2,3,4}, then (b)S = {(1,1),(1,2),(2,1),(2,2),(3,3),(4,4)} is reflexive, because (a,a) is a member of R for each a  A transitive, proven by(1,1)(1,2)(1,2) (1,2)(2,2)(1,2) symmetric, because if (a,b)  S then (b,a)  S, too not anti symmetric, because there exists (1,2) and (2,1) as members of R while 1  2 No.1:

5 6/5 Erwin SitompulDiscrete Mathematics Solution of Homework 5 Given: A = {1,2,3,4}, then (c)T = {(1,2),(2,3),(3,4)} is not reflexive, because {(1,1),(2,2),(3,3),(4,4)}  R not transitive, because (1,3) and (2,4) are not members of R not symmetric, because (2,1), (3,2), and (4,3)  R anti symmetric, because the definition of the property is not violated No.1:

6 6/6 Erwin SitompulDiscrete Mathematics Solution of Homework 5 No.2: Represent the relation R, S, and T using matrices and digraphs. (a)R= {(2,2),(2,3),(2,4),(3,2),(3,3),(3,4)} (b) S= {(1,1),(1,2),(2,1),(2,2),(3,3),(4,4)} (c) T= {(1,2),(2,3),(3,4)}

7 6/7 Erwin SitompulDiscrete Mathematics Solution of Homework 5 RTS No.2: Represent the relation R, S, and T using matrices and digraphs. (a)R= {(2,2),(2,3),(2,4),(3,2),(3,3),(3,4)} (b) S= {(1,1),(1,2),(2,1),(2,2),(3,3),(4,4)} (c) T= {(1,2),(2,3),(3,4)}

8 6/8 Erwin SitompulDiscrete Mathematics Combining Relations  A binary relation is composed of a set of relation pairs.  Thus, set operations such as intersection, union, difference, and symmetric difference between two relations or more are also applicable on binary relations.  If both R 1 and R 2 are relations from set A to set B, then R 1  R 2, R 1  R 2, R 1 – R 2, and R 1  R 2 are also relations from set A to set B.

9 6/9 Erwin SitompulDiscrete Mathematics Example: Suppose A = {a,b,c} and B = {a,b,c,d}, Relation R 1 = {(a,a),(b,b),(c,c)}, Relation R 2 = {(a,a),(a,b),(a,c),(a,d)}, then R 1  R 2 = {(a,a)} R 1  R 2 = {(a,a),(b,b),(c,c),(a,b),(a,c),(a,d)} R 1  R 2 = {(b,b),(c,c)} R 2  R 1 = {(a,b),(a,c),(a,d)} R 1  R 2 = {(b,b),(c,c),(a,b),(a,c),(a,d)}. Combining Relations

10 6/10 Erwin SitompulDiscrete Mathematics Suppose R is a relation from set A to set B, and S is a relation from set B to set C. then composition of relations R and S, denoted with S○R, is a relation from set A to set C that is defined by: S○R = {(a,c)  a  A, c  C, and for some b  B, (a, b)  R and (b, c)  S} Example : Suppose R = {(1,2),(1,6),(2,4),(3,4),(3,6),(3,8)} is a relation from set {1,2,3} to set {2,4,6,8}; and S = {(2,u),(4,s),(4,t),(6,t),(8,u)} is a relation from set {2,4,6,8} to set {s,t,u}. Then the composition of relations R and S is S○R = {(1,u),(1,t),(2,s),(2,t),(3,s),(3,t),(3,u)}. Composition of Relations

11 6/11 Erwin SitompulDiscrete Mathematics Composition of relations R and S can also be represented by using an arrow diagram: R = {(1,2),(1,6),(2,4),(3,4),(3,6),(3,8)} S = {(2,u),(4,s),(4,t),(6,t),(8,u)} S○R = {(1,u),(1,t),(2,s),(2,t),(3,s),(3,t),(3,u)} Composition of Relations

12 6/12 Erwin SitompulDiscrete Mathematics If relations R 1 and R 2 are each represented by matrix M R1 and matrix M R2, then the matrix that represents the composition of both relations is: M R2○R1 = M R1  M R2 In other words, composition matrix of two relations can be obtained from the multiplication between the corresponding relation matrices, with the rule:  Value 1 is considered as True (T), 0 as False (F)  Operation of multiplication is replaced by logical operation “and” (  )  Operation of summation is replaced by logical operation “or” (  ) Composition of Relations

13 6/13 Erwin SitompulDiscrete Mathematics Example : As previously given, R = {(1,2),(1,6),(2,4),(3,4),(3,6),(3,8)} S = {(2,u),(4,s),(4,t),(6,t),(8,u)} S○R = {(1,u),(1,t),(2,s),(2,t),(3,s),(3,t),(3,u)} Composition of Relations

14 6/14 Erwin SitompulDiscrete Mathematics 011 1 1 0 111 Composition of Relations

15 6/15 Erwin SitompulDiscrete Mathematics  A binary relation only connects two sets.  The general form of relation can connect more than two sets. This relation is called n-ary relation.  If n = 2, then the relation is again called binary relation (bi=2).  n-ary relation find an important application in data base.  Suppose A 1, A 2, …, A n are sets. Then the n-ary relation R on the sets is subset of A 1  A 2  …  A n, or R  A 1  A 2  …  A n.  Set A 1, A 2, …, A n is called domain of relation and n is called degree. n-ary Relation

16 6/16 Erwin SitompulDiscrete Mathematics Example : Suppose, StudentID = {001200900023,001200900091,001200900007, 001200900038, 001200900069, 001200900070} Name= {Amir, Budi, Cora, Dudi, Encep, Florina} Subject = {Discrete Mathematics (DM), Data Structure and Algorithm (DSA), State Philosophy (SP), English III (E3)} Grade = {A, B, C, D, E} The 4-tuple relation LIST is defined as (StudentID, Name, Subject, Grade), where LIST  StudentID  Name  Subject  Grade. n-ary Relation

17 6/17 Erwin SitompulDiscrete Mathematics Then, one possible example of relation LIST is LIST= {(001200900023, Amir, DM, B), (001200900023, Amir, E3, A), (001200900007, Budi, DSA, A), (001200900070, Cora, DSA, B), (001200900070, Cora, SP, A), (001200900070, Cora, E3, A), (001200900069, Dudi, DM, D), (001200900069, Dudi, SP, C), (001200900038, Encep, DM, E), (001200900038, Encep, DSA, E), (001200900038, Encep, SP, E), (001200900038, Encep, E3, E)} n-ary Relation

18 6/18 Erwin SitompulDiscrete Mathematics Relation LIST can also be represented by using a table. n-ary Relation

19 6/19 Erwin SitompulDiscrete Mathematics  A data base is a collection of tables.  One model of data base is relational database, which is based on relation n-ary relation.  In a relational database, one table represents one relation. Data Base attribute record field

20 6/20 Erwin SitompulDiscrete Mathematics  Suppose A and B are sets, then a binary relation f from A to B is called a function if every member in A is related with exactly one member in B.  The notation of a function is written as f : A  B.  Pronounced: “f maps or associates A to B.”  A is called domain of f and B is called co-domain of f.  Other terms for “function” are mapping and transformation.  We write f(a) = b if the function maps or associates a  A with b  B. Functions

21 6/21 Erwin SitompulDiscrete Mathematics  If f(a) = b, then b is called the image of a and a is called the pre-image of b.  A set that contains all mapping values of f is called the range of f.  Note that the range of f is an improper subset of the co- domain B. Functions A B f 4.3 4 Domain Co-domain Pre-image of 4 Image of 4.3 f maps A to B f(4.3)

22 6/22 Erwin SitompulDiscrete Mathematics  A function is a relation with special properties:  Every member of set A must be utilized/employed by the procedure or rule that defines the function.  The sentence “every member in A is related with exactly one member in B” has the meaning that if (a,b)  f and (a,c)  f, then b = c.  Or in other words, if b = f(a) and c = f(a), then b = c. Functions

23 6/23 Erwin SitompulDiscrete Mathematics Example: Suppose A = {1,2,3} and B = {u,v,w}, then the following relations: (a)f = {(1,u),(2,v),(3,w)} is a function from A to B. Here, f(1) = u, f(2) = v, and f(3) = w. The domain of f is A and the co-domain of f is B. The range of f are {u,v,w}, which in this case is equivalent to set B. (b)f = {(1,u),(2,u),(3,v)} is a function from A to B, although u becomes the image of two members of A. The domain of f is A and the co-domain of f is B. But, the range of f is {u,v} only, a subset of B. Functions

24 6/24 Erwin SitompulDiscrete Mathematics Example: Suppose A = {1,2,3} and B = {u,v,w}, then the following relations : (c)f = {(1,u),(2,v)} is not a function from A to B, because not all members of A is associated to any members of B. (d)f = {(1,u),(1,v),(2,v),(3,w)} is not a function from A to B, because 1 is mapped to two members of B, which are u and v. Functions

25 6/25 Erwin SitompulDiscrete Mathematics  The function f that maps elements of A to elements of B is called a one-to-one function or injective function if all members of A have distinct image in B. One-to-one Function (Injective Function)

26 6/26 Erwin SitompulDiscrete Mathematics Example: Suppose A = {1,2,3} and B = {u,v,w,x}, then the following relations: (a)f = {(1,w),(2,u),(3,v)} is a one-to-one function, because all members of A have distinct image on B. (b)f = {(1,u),(2,u),(3,v)} is not a one-to-one function, because f(1) = f(2) = u. One-to-one Function (Injective Function)

27 6/27 Erwin SitompulDiscrete Mathematics  The function f that maps elements of A to elements of B is called an onto function or surjective function if every member B is the image of one or more members of A.  In other words, all members of B become the range of f.  The function f is called “the function on B.” Onto Function (Surjective Function)

28 6/28 Erwin SitompulDiscrete Mathematics Example: Suppose A = {1,2,3} and B = {u,v,w}, then the following relations: (a)f = {(1,u),(2,u),(3,v)} is not an onto function, because w is not included in the range of f. (b)f = {(1,w),(2,u),(3,v)} is an onto function, because all members of B are included in the range of f. Onto Functions (Surjective Function)

29 6/29 Erwin SitompulDiscrete Mathematics  The function f that maps elements of A to elements of B is called a one-to-one correspondence or bijection if f is a one-to-one function and an onto function, simultaneously. Example: Suppose A = {1,2,3} and B = {u,v,w}, then the relation f = {(1,w),(2,u),(3,v)} is a one-to-one correspondence, because f is a one-to-one function and also an onto function. One-to-one Correspondence (Bijections)

30 6/30 Erwin SitompulDiscrete Mathematics one-to-one, not onto not one-to-one, not onto not one-to-one, onto not a function Exercise

31 6/31 Erwin SitompulDiscrete Mathematics  Inverse of a function f that maps elements of A to elements of B can be obtained if and only if f is a one-to-one correspondence from A to B.  Inverse of function f is denoted by f –1, which is a one-to-one correspondence from B to A.  Suppose a  A and b  B, if f(a) = b then f –1 (b) = a.  A one-to-one correspondence is also called an invertible function, because its inverse can be defined.  A function is said to be not invertible if it is not a one-to-one correspondence. In this case, the inverse does not exist. Inverse of Functions

32 6/32 Erwin SitompulDiscrete Mathematics Example: Suppose A = {1,2,3} and B = {u,v,w}, then the following relations: (a)f = {(1,u),(2,u),(3,v)} is not a one-to-one correspondence. f –1 = {(u,1),(u,2),(v,3)} is not a function at all  the inverse cannot be defined. (b)f = {(1,w),(2,u),(3,v)} is a one-to-one correspondence. f –1 = {(w,1),(u,2),(v,3)} is a function  the inverse can be defined  f is an invertible function Inverse of Functions

33 6/33 Erwin SitompulDiscrete Mathematics Suppose f is a function that builds a map from set A to set B, and likewise g from set B to set C. The composition of f and g, denoted as g○f, is function from A to C that is defined by: (g○f)(a) = g(f(a)) Example: Given function f = {(1,u),(2,u),(3,v)} that builds a map from A = {1,2,3} to B = {u,v,w}, and function g = {(u,y),(v,x),(w,z)} that builds a map from B = {u,v,w} to C = {x,y,z}. Then the composition of A to C is: g○f = {(1, y), (2, y), (3, x)} Composition of Functions

34 6/34 Erwin SitompulDiscrete Mathematics Example: Suppose that the functions are f(x) = x – 1 and g(x) = x 2 + 1. Determine f○g and g○f. Solution: (a)(f○g)(x) = f(g(x)) = f(x 2 + 1) = (x 2 + 1) – 1 = x 2 (b) (g○f)(x) = g(f(x)) = g(x – 1) = (x –1) 2 + 1 = x 2 – 2x + 2 Composition of Functions

35 6/35 Erwin SitompulDiscrete Mathematics 1. Floor Function and Ceiling Function Suppose x is a real number, whose value is between two integers. floor of x, denoted as  x , yields the greatest integer which is less than or equal to x. ceiling of x, denoted as  x , yields the smallest integer which is greater than or equal to x. Several Special Functions

36 6/36 Erwin SitompulDiscrete Mathematics Example: Some examples for the values of floor function and ceiling function:  3.5  = 3  3.5  = 4  0.45  = 0  0.45  = 1  4.8  = 4  4.8  = 5  – 0.5  = – 1  – 0.5  = 0  –3.75  = – 4  –3.75  = – 3 Several Special Functions How to make a round function, such that round(4.2) = 4, round(7.52) = 8?

37 6/37 Erwin SitompulDiscrete Mathematics 2. Modulo Function Suppose a is an arbitrary integer and m is an arbitrary positive integer, then a mod m yields the remaining of the division if a is divided by m a mod m = rsuch that a = mq + r, where q is an arbitrary integer and 0  r < m The value of r can also be found using the formula of: r = a – mqwhere q =  a/m  Several Special Functions

38 6/38 Erwin SitompulDiscrete Mathematics Example: Some examples of the value of module function: 25 mod 7 = 4,  25/7  = 3 and 25 – 7  3 = 4 15 mod 4 = 3,  15/4  = 3 and 15 – 4  3 = 3 3612 mod 45 = 12,  3612/45  = 80 and 3612 – 45  80 = 12 0 mod 5 = 0,  0/5  = 0 and 0 – 5  0 = 0 –25 mod 7 = 3,  –25/7  = –4 and –25 – 7  (–4) = 3 Several Special Functions

39 6/39 Erwin SitompulDiscrete Mathematics 12341234 abcabc Homework 6 12341234 abcabc 123123 abcdabcd 12341234 abcdabcd 12341234 abcdabcd No.1: Determine whether the following relations are one-to-one, onto, one-to-one correspondence, or neither. New (a)(b)(c) (d) (e)

40 6/40 Erwin SitompulDiscrete Mathematics Homework 6 No.2: Let f:R  R and g:R  R be defined by f(x) = 2x + 1 and g(x) = x 2 – 2. Find the formula for the composition functions: (a) f○f○g (b)g○g○f New


Download ppt "Discrete Mathematics 3. MATRICES, RELATIONS, AND FUNCTIONS Lecture 6 Dr.-Ing. Erwin Sitompul"

Similar presentations


Ads by Google