Quick viewing(Text Mode)

Relations and Functions Order Pair Cartesian Product Notation For

Relations and Functions Order Pair Cartesian Product Notation For

Order Pair

n An Ordered Pair consists of two elements, say a and b, in which one of them, saying a is Relations and Functions designated as the first and the other as the second element. Peter Lo u The ordered pairs (1,2) and (2,1) are different u The {1, 2} is not an ordered pair

u Ordered pair can have same elements (1,1)

CS218 © Peter Lo 2004 1 CS218 © Peter Lo 2004 2

Cartesian Notation for Number System n If X and Y are sets, we let X ´ Y denote the set of n Æ denotes Null Set all order pairs (x, y) where x Î X and y Î Y. n Z denotes the set of n We call X ´ Y the Cartesian Productof X and Y. n Q denotes the set of Rational Numbers n If |X| = m, |Y| = n, then |X ´ Y| = mn n Qc denotes the set of Irrational Numbers n If A = {1, 2, 3} and B = {a, b}. n N denotes the set of Natural Numbers The A ´ B n R denotes the set of Real Numbers = {(1, a), (1, b), (2, a), (2, b), (3, a), (3,b) }

CS218 © Peter Lo 2004 3 CS218 © Peter Lo 2004 4

1 Introduction to Relations Domain and Range n A Binary between sets A and B is a n The Domain of a relation R is the set of all first of A ´ B. In other word, a is elements of the ordered pair which belong to R, a collection of ordered pairs from A ´ B. and the Range of R is the set of second elements. n If A and B are equal, this relation is called n A relation is also written as aRb. Relation on the Set A. n Example: n Since relation R is a subset of A ´ B, any relation R has a complementary relation R, which is the u If A = {1, 2, 3}, B = {a, b, c}, and R = {(1, b), of the set R relative A ´ B. (1, c), (3, b)}. For this relation 1Rb, 1Rc, 3Rb, n (Do Ex. 1 & 2) domain = {1, 3}, range = {b, c}.

CS218 © Peter Lo 2004 5 CS218 © Peter Lo 2004 6

Pictorial Representation of Graphical Representation of Relations Relations n Let R be a relation from A = {1, 2, 3} to B = {a, b} n is a way of picturing a relation when it is where R = {(1, a), (1, b), (3, a)}. The represented form a to itself is to write down the elements of the set and then draw an arrow from an elements x to an as follows: element y whenever x is related to y.

n (Do Ex. 3)

n (Do Ex. 4 – 7)

CS218 © Peter Lo 2004 7 CS218 © Peter Lo 2004 8

2 Matrix Representation of a Properties of Relations Relation n Let A be a set with n elements, and let B be a set with m n Reflexive elements and R be a relation between A and B. n Symmetric u A = {a1, a2, … , an} n Transitive u B = {b1, b2, … , bm} n Matrix M is called the Logical Matrix for R if n Irreflexive n Antisymmetric ì True "(ai ,b j ) Î R ü M (i, j) = í ý îFalse "(ai ,b j ) Ï Rþ n (Do Ex. 8)

CS218 © Peter Lo 2004 9 CS218 © Peter Lo 2004 10

Reflexive Symmetric n Let R be a subset of A ´ A. Then R is called a n Let R be a subset of A ´ A. Then R is called a Reflexive Relation if "xÎA, (a, a)ÎR. Symmetric Relation if (a, b)ÎR Þ (b, a)ÎR. n The direct graph of every reflexive relation n The matrix representation for the symmetric includes an arrow from every to the point relations are symmetric with respect to the main itself. diagonal.

CS218 © Peter Lo 2004 11 CS218 © Peter Lo 2004 12

3 Transitive Irreflexive n A relation R in a set A is called a Transitive n A Relation R on a set S is Irreflexive Relation if Relation if ((a, b)ÎR Ç (b, c)ÎR) Þ (a, c)ÎR. x R x, "xÎR. n Example: n Example:

u Let W = {a, b, c}, and let u The relation on the set {a, b, c} given by the set R = {(a, b), (c, b), (b, a), (a, c)}. of order pairs {(a, b), (b, c), (c, a)} is irreflexive, because it does not contain any of the ordered u Then R is not a because pairs (a, a), (b, b) and (c, c). (c, b) ÎR and (b, a) ÎR but (c, a) Ï R.

CS218 © Peter Lo 2004 13 CS218 © Peter Lo 2004 14

Antisymmetric Types of Relations n A Relation R on a set S is Antisymmetric if n Equivalence of Relations "x, yÎS, (xRy Ç yRx) Þ (x = y). n Partially Ordered Relations n Example: n Universal Relations

u The relation “Greater than or equal to” on the n Empty Relations set of integer is antisymmetric because if x, y n Inverse Relations ÎZ, then (x ³ y and y £ x) Þ (x = y). n Composite Relations

CS218 © Peter Lo 2004 15 CS218 © Peter Lo 2004 16

4 Equivalence Relations Example n A relation is an Equivalence Relation if it is n Provide that the relation = of equality on any set S reflexive, symmetric and transitive and is denoted is an equivalence relation.

as ~. u (1) a = a for every a in S; (Reflexive property)

u (2) if a = b, then b = a; (Symmetric property)

u (3) if a = b and b = c, then a = c. (Transitive property)

u Therefore, S is an equivalent relation.

CS218 © Peter Lo 2004 17 CS218 © Peter Lo 2004 18

Partially Ordered Relations Example n A Relation on a set is reflexive, antisymmetric and n If a and b are positive , a|b means that a is transitive is called Partially Ordered Relation on a divisor of b, i.e. b = ac for some integer c. Show the set. that “|” is a partial ordering of the set of positive integers.

CS218 © Peter Lo 2004 19 CS218 © Peter Lo 2004 20

5 Answer Universal and Empty Relations n By definition, the a|b means that the number b/a is an integer. n Universal Relation We need to verify reflexivity, antisymmetry, and transitivity. u Let A be any set, then A ´ A is known as the + u Reflexivity: "nÎZ , n|n as n/n is 1 Universal Relation. u Antisymmetry: If n|m and m|n, then m/n and n/m are both integers. Since n/m = (m/n)-1, the integer n/m has n Empty Relation the property that its reciprocal is also an integer. The u Let A be any set, then Æ is called the Empty only such positive integer is 1, and so n/m = 1, i.e. n = m. Relation. u Transitivity: If n|m and m|p, then p/n = (n/m) x (m/n) is an integer, since it is the product of two other integers. n It follows that “|” is a partial ordering.

CS218 © Peter Lo 2004 21 CS218 © Peter Lo 2004 22

Inverse Relations Composite Relations

n For every relation R between sets A and B is a n Let R be a relation between sets A and B, and let S be a subset of A ´ B, the Inverse Relation of R is the relation between B and C. The composition of R and S is reverses of the roles of A and B to obtain a the relation between A and C. relation between B and A. n The composite relation of S and R is denoted as S o R, given by S o R = {(x, z) | xÎA, zÎC, $yÎB, xRy Ç ySz} -1 n The inverse Relation of R is denoted as R and the n (Do Ex. 11) relation between B and A given by R-1 = {(y, x) | (x, y) ÎR} n (Do Ex. 9 – 10)

CS218 © Peter Lo 2004 23 CS218 © Peter Lo 2004 24

6 Introduction to Functions Elements of a n A Function is an association of exactly one object n Functions are often referred to as Mappings or from one set (the range) with each object from Transformations. n The unique element y = f (x) of B assigned to xÎA by f is another set (the domain). called the of x under f. n This means that there must be at least one arrow n f: A®B indicate f is a function from A to B. The set A is leaving each point in the domain, and further that called the Domain of f, and set B is called of f. there can be no more than one arrow leaving each n The range of f denoted by f [A], is the set of all images: point in the domain. f [A] = {f(x) | x ÎA} n The Pre -image or Inverse Image of a set B contained in n (Do Ex. 12) the range of f is denoted by f -1(B) and is the subset of the domain whose members have images in b.

CS218 © Peter Lo 2004 25 CS218 © Peter Lo 2004 26

Example Graphing Functions

+ n The geometric mean function gmean: N x N à R is defined by n gmean(x,y) = Ö(xy) The set of all ordered pairs of the function f u What is the domain ofgmean? plotted in a Cartesian coordinate system is called u Explain why the range ofgmean is different from the codmain the Graph of f. u Is gmean 1 one-to-one function? Why? n n Answer The f is equivalent to the graph u The domain ofgmean (N,N) of the equation y = f (x) as described in algebra. u The range ofgmean is different from the codmain: n (Do Ex. 13 – 14) t gmean(x,y) – domain t Ö(xy) – codmain u gmean is not a one-to-one function since gmean(1,4) and gmean(2,2) = 2

CS218 © Peter Lo 2004 27 CS218 © Peter Lo 2004 28

7 Types of Functions Injection n Injections n Let f: A®B be a function. The function f is called n Surjections an , or an Injection if "x, yÎA, f (x) = f (y) Þ x = y. n n An injective function is also called a One-to-one or 1-1 Function.

CS218 © Peter Lo 2004 29 CS218 © Peter Lo 2004 30

Surjection n Let f: A®B be a function. The function f is called n If a function is both 1-1 and Onto, it is called a a , or a Surjection if $ xÎA, Bijective Function, or a Bijection. "yÎB, f (x) = y. n A bijection from a set A to itself is called a n A surjective function is also called an Onto Permutation of the set A. Function.

CS218 © Peter Lo 2004 31 CS218 © Peter Lo 2004 32

8 Example Example n Use counter example, show the function f: Zà Z n Give f: Z à Z, Show f(x) = (x 2 +1)/2 whether it is or not is defined by the rule f(x) = 4x2 – 1 for xÎZ is not u 1 to 1 Function bijective function for x is any integers. u Onto Function n Answer n Answer 2 u f(x) is not 1 to 1 function since (-1, 2) and (1,2) Î f(x). u f(x) = 4x – 1 is not a 1-to-1 function since (-1, 3) and (1,3) exist u f(x) is not onto function since –5 in domain B but no x in domain B.

t -5 = (x 2 +1)/2 => -11 = x 2 => impossible.

CS218 © Peter Lo 2004 33 CS218 © Peter Lo 2004 34

Limits Binary Operations n The function f (x) approaches the limit L as n A on a set A is a function approaches +¥ if the values of f (x) get arbitrarily op: A ´ A ® A. Thus, a binary operation takes close to L as x gets arbitrarily large, written as two elements of A and maps them to a third Lim element of A. f (x) = L x ® +¥ n The Binary Operation is denoted as op(a, b) or a op b, a, bÎA. n (Do Ex. 15 – 16) n op(a, b) is called Prefix Notation. n a op b is called Infix Notation.

CS218 © Peter Lo 2004 35 CS218 © Peter Lo 2004 36

9 Operations of Functions Equal Functions n Equal Functions n Two functions f and g are said to be equal if they n Sum of Functions have the same domain and codomain, and for all x in the domain, f (x) = g(x). n Difference of Functions n Example n Product of Functions u Let f (x) = (6x – 4) /2 and g(x) = 3x – 2. n Quotient of Functions u Then f = g, since they both have the same n Composite Functions domain and codomain, and for all x in the n Invertible Functions domain f(x) = g(x).

CS218 © Peter Lo 2004 37 CS218 © Peter Lo 2004 38

Sum and Difference of Functions Product and Quotient of Functions n Sum of Functions n Product of Functions

u The Sum of f and g, f + g is defined by u The Product of f and g, f g is defined by (f + g)(x) = f (x) + g(x) (f g)(x) = f (x) · g(x) n Difference of Functions n Quotient of Functions

u The Difference of f and g, f – g is defined by u The Sum of f and g, f / g is defined by (f – g)(x) = f (x) – g(x) (f / g)(x) = f (x) / g(x)

CS218 © Peter Lo 2004 39 CS218 © Peter Lo 2004 40

10 Composite Functions Example n Since functions are subset of relation, we can form n Let f (x) = 3x + 5 and g(x) = 4x – 3, find (f o g)(x) the composition of two function into a Composite n (f o g)(x) Function. n = f (g(x)) n The composition of two functions f and g relates an element a to an element c if there is some n = f (4x-3) element b such that b = f(a) and c = g(b). n = 3(4x – 3) + 5 n Given two functions f and g, the composite n =12x –9 +5 function, denoted by f o g is defined by n = 12x – 4 (f o g)(x) = f (g(x))

CS218 © Peter Lo 2004 41 CS218 © Peter Lo 2004 42

Invertible Functions Example n If the inverse relation of a function is a function, n Find the inverse of f (x) = 4x – 1 then the function is Invertible. n Let f: A ® B be a function. The function f is invertible f is a bijection.

CS218 © Peter Lo 2004 43 CS218 © Peter Lo 2004 44

11 Difference between Function and Relation n In a function, no two distinct ordered pairs have the same first element.

CS218 © Peter Lo 2004 45

12