You are on page 1of 12

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 element and the other as the
second element.
u The ordered pairs (1,2) and (2,1) are different
Peter Lo
u The set {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 Product 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 Integer
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 Cartesian Product 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 Relation between sets A and B is a n The Domain of a relation R is the set of all first
subset of A × B. In other word, a binary relation 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),

complement 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 Directed Graph is a way of picturing a relation when it is
form a finite set to itself is to write down the elements of
where R = {(1, a), (1, b), (3, a)}. The represented 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
uB = {b1, b2, … , bm }
n Matrix M is called the Logical Matrix for R if n Irreflexive
 True ∀ (ai , b j ) ∈ R  n Antisymmetric
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 point 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,
u Then R is not a transitive relation because
because it does not contain any of the ordered
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 integers, 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
the relation between A and C.
reverses of the roles of A and B to obtain a
n The composite relation of S and R is denoted as S o R,
relation between B and A.
given by S o R = {(x, z) | x∈A, z∈C, ∃y∈B, xRy ∩ ySz}
n The inverse Relation of R is denoted as R-1 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 Function
n A Function is an association of exactly one object n Functions are often referred to as Mappings or
Transformations.
from one set (the range) with each object from
n The unique element y = f (x) of B assigned to x∈A by f is
another set (the domain). called the Image 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 Codomain 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 The set of all ordered pairs of the function f
gmean(x,y) = √ (xy)
u What is the domain of gmean? plotted in a Cartesian coordinate system is called
u Explain why the range of gmean is different from the codmain the Graph of f.
u Is gmean 1 one-to-one function? Why?

n Answer n The graph of a function 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 of gmean 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 Injective Function, or an Injection if ∀x, y∈A,
n Bijections f (x) = f (y) ⇒ x = y.
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 Bijection
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 Surjective Function, 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
u f(x) is not 1 to 1 function since (-1, 2) and (1,2) ∈ f(x).
u f(x) = 4x2 – 1 is not a 1-to-1 function since (-1,
u f(x) is not onto function since –5 in domain B but no x
3) and (1,3) exist
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 Binary Operation 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
n Difference of Functions in the domain, f (x) = g(x).
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 if and only if 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

You might also like