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

Slides:



Advertisements
Similar presentations
Discrete Mathematics 3. MATRICES, RELATIONS, AND FUNCTIONS Lecture 5 Dr.-Ing. Erwin Sitompul
Advertisements

Discrete Mathematics Lecture # 16 Inverse of Relations.
Functions Section 2.3 of Rosen Fall 2008
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
Functions Goals Introduce the concept of function Introduce injective, surjective, & bijective functions.
1 Section 1.8 Functions. 2 Loose Definition Mapping of each element of one set onto some element of another set –each element of 1st set must map to something,
Functions.
Discrete Structures Functions Dr. Muhammad Humayoun Assistant Professor COMSATS Institute of Computer Science, Lahore.
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
Sets Set Operations Functions. 1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products.
2.1 Sets 2.2 Set Operations 2.3 Functions ‒Functions ‒ Injections, Surjections and Bijections ‒ Inverse Functions ‒Composition 2.4 Sequences and Summations.
FUNCTION Discrete Mathematics Asst. Prof. Dr. Choopan Rattanapoka.
 Let A and B be any sets A binary relation R from A to B is a subset of AxB Given an ordered pair (x, y), x is related to y by R iff (x, y) is in R. This.
Foundations of Discrete Mathematics Chapter 3 By Dr. Dalia M. Gil, Ph.D.
February 12, 2015Applied Discrete Mathematics Week 2: Functions and Sequences 1Exercises Question 1: Given a set A = {x, y, z} and a set B = {1, 2, 3,
Functions. Copyright © Peter Cappello2 Definition Let D and C be nonempty sets. A function f from D to C, for each element d  D, assigns exactly 1 element.
Chapter 9. Chapter Summary Relations and Their Properties Representing Relations Equivalence Relations Partial Orderings.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
Chapter 9. Section 9.1 Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and.
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (2)
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
Fall 2002CMSC Discrete Structures1 … and the following mathematical appetizer is about… Functions.
10/26/20151 … and the following mathematical appetizer is about… Functions.
FUNCTIONS.
Functions Section 2.3 of Rosen Spring 2012 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions: Use Piazza.
MSU/CSE 260 Fall Functions Read Section 1.8.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
1 Discrete Structures – CNS 2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 1 The Foundations: Logic, Sets,
Functions1 Elementary Discrete Mathematics Jim Skon.
Chapter 1 SETS, FUNCTIONs, ELEMENTARY LOGIC & BOOLEAN ALGEBRAs BY: MISS FARAH ADIBAH ADNAN IMK.
1.4 Sets Definition 1. A set is a group of objects . The objects in a set are called the elements, or members, of the set. Example 2 The set of positive.
Example Prove that: “IF 3n + 2 is odd, then n is odd” Proof by Contradiction: -p = 3n + 2 is odd, q = n is odd. -Assume that ~(p  q) is true OR -(p 
Functions Reading: Chapter 6 (94 – 107) from the text book 1.
Basic Structures: Functions Muhammad Arief download dari
CSE 2353 – October 1 st 2003 Functions. For Real Numbers F: R->R –f(x) = 7x + 5 –f(x) = sin(x)
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
Chapter 5 – Relations and Functions. 5.1Cartesian Products and Relations Definition 5.1: For sets A, B  U, the Cartesian product, or cross product, of.
Agenda Week 10 Lecture coverage: –Functions –Types of Function –Composite function –Inverse of a function.
CompSci 102 Discrete Math for Computer Science January 31, 2012 Prof. Rodger Slides modified from Rosen AB a b c d x y z.
Functions. L62 Agenda Section 1.8: Functions Domain, co-domain, range Image, pre-image One-to-one, onto, bijective, inverse Functional composition and.
Discrete Mathematics Relation.
11 DISCRETE STRUCTURES DISCRETE STRUCTURES UNIT 5 SSK3003 DR. ALI MAMAT 1.
11 DISCRETE STRUCTURES DISCRETE STRUCTURES UNIT 5 SSK3003 DR. ALI MAMAT 1.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Unit II Discrete Structures Relations and Functions SE (Comp.Engg.)
CSC102 - Discrete Structures Functions
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
1 Functions CS 202 Epp section ??? Aaron Bloomfield.
FUNCTIONS COSC-1321 Discrete Structures 1. Function. Definition Let X and Y be sets. A function f from X to Y is a relation from X to Y with the property.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Discrete Mathematics Lecture # 19 Inverse of Functions.
1 Lecture 5 Functions. 2 Functions in real applications Curve of a bridge can be described by a function Converting Celsius to Fahrenheit.
Section 2.3. Section Summary  Definition of a Function. o Domain, Cdomain o Image, Preimage  One-to-one (Injection), onto (Surjection), Bijection 
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
FUNCTIONS.
Week 8 - Wednesday.  What did we talk about last time?  Relations  Properties of relations  Reflexive  Symmetric  Transitive.
Discrete Mathematics Lecture # 17 Function. Relations and Functions  A function F from a set X to a set Y is a relation from X to Y that satisfies the.
Discrete Mathematics Functions
Functions Section 2.3.
Relations, Functions, and Matrices
Cartesian product Given two sets A, B we define their Cartesian product is the set of all the pairs whose first element is in A and second in B. Note that.
Relation and function.
Chapter 3 Relation and Function Homework 4 For each of the following relations on set A = { 1,2,3,4 }, check each of them whether they are reflexive, irreflexive,
Functions Section 2.3.
Chapter 2 Sets Homework 3 Given U = { 1, 2, 3, 4, 5, 6, 7, 8, 9 } as a set universe and the sets : A = { 1, 2, 3, 4, 5 }, B = { 4, 5, 6, 7 }, C = { 5,
CS201: Data Structures and Discrete Mathematics I
Discrete Math (2) Haiming Chen Associate Professor, PhD
CS100: Discrete structures
Functions Section 2.3.
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Presentation transcript:

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

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.

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:

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:

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 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)}

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)}

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.

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

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

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

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

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

6/14 Erwin SitompulDiscrete Mathematics Composition of Relations

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

6/16 Erwin SitompulDiscrete Mathematics Example : Suppose, StudentID = { , , , , , } 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

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

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

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

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

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 Domain Co-domain Pre-image of 4 Image of 4.3 f maps A to B f(4.3)

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

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

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

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)

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)

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)

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)

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)

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

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

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

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

6/34 Erwin SitompulDiscrete Mathematics Example: Suppose that the functions are f(x) = x – 1 and g(x) = x 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) = x 2 – 2x + 2 Composition of Functions

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

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?

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

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 = 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

6/39 Erwin SitompulDiscrete Mathematics abcabc Homework abcabc abcdabcd abcdabcd 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)

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