Download presentation
Presentation is loading. Please wait.
Published byVincent Wade Modified over 9 years ago
1
HALVERSON – MIDWESTERN STATE UNIVERSITY CMPS 2433 Chapter 2 – Part 2 Functions & Relations
2
2.2 Relations A RELATION from set A to set B is any subset of the Cartesian Product A X B If R is a relation from A to B & (a, b) is an element of R, a is related to b by R Example A = {students enrolled at MSU in fall 2014} B = {courses offered at MSU in fall 2014} R = {(a,b)| student a is enrolled in course b} R = {(Smith,Math1233), (Jones, CMPS1044), etc.}
3
Relations (cont’d) A relation is ANY subset, so no repeated pairs but can have repeated elements in the pairs. R = {(Smith,Math1233), (Jones, Cmps1044), (Smith, Engl1013), (Jones, Math1233), (Hunt, Math1233), (Williams, Cmps1044), etc.} What is the Universal Set for R? Define a different Relation from A to B.
4
Relations (cont’d) Example: R is a relation on A A = {students enrolled at MSU in fall 2014} R = {(a, b)| a & b are in a course together} R = {(Smith, Jones), (Jones, Hunt), (Hunt, Wills), (Wills, Johnson), etc.} What about (Jones, Smith)? Relation from a set S to itself is call a Relation on S
5
Reflexive Property of Relations A Relation R on a set S is said to be Reflexive if for each x S, x R x is true if for each x S, (x, x) is in R that is, every element is related to itself Is our previous example R a Reflexive Relation?
6
Reflexive Property of Relations - Examples A = {students enrolled at MSU in fall 2014} Which of the following are Reflexive? R = {(a,b): a & b are siblings} R = {(a,b): a & b are not in a course together} R = {(a,b): a & b are same classification} R = {(a,b): a & b are married} R = {(a,b): a & b are the same age} R = {(a,b): a has a higher GPA than b}
7
Symmetric Property of Relations A Relation R on a set S is said to be Symmetric If x R y is true, then y R x is true If (x, y) R, then (y, x) is true That is, the elements of the relation R can be reversed Is R Symmetric? R = {(a, b)| a & b are in a course together}
8
Symmetric Property of Relations - Examples A = {students enrolled at MSU in fall 2014} Which of the following are Symmetric? R = {(a,b): a & b are siblings} R = {(a,b): a & b are not in a course together} R = {(a,b): a & b are same classification} R = {(a,b): a & b are married} R = {(a,b): a & b are the same age} R = {(a,b): a has a higher GPA than b}
9
Transitive Property of Relations A Relation R on a set S is said to be Transitive If x R y and y R z are true, then x R z is true If (x, y) R & (y, z) R, then (x, z) R Is R Transitive? R = {(a, b)| a & b are in a course together}
10
Transitive Property of Relations - Examples A = {students enrolled at MSU in fall 2014} Which of the following are Transitive? R = {(a,b): a & b are siblings} R = {(a,b): a & b are not in a course together} R = {(a,b): a & b are same classification} R = {(a,b): a & b are married} R = {(a,b): a & b are the same age} R = {(a,b): a has a higher GPA than b}
11
Equivalence Relation Any Relation that is Reflexive, Symmetric & Transitive is an Equivalence Relation If R is an Equivalence Relation on S & x S, the set of all elements related to x is called an Equivalence Class Denoted [x] Any 2 Equivalence Classes of a Relation are either Equal or Disjoint The Equivalence Classes of R Partition S
12
Equivalence Relations - Examples A = {students enrolled at MSU in fall 2014} Which are Equivalence Relations? If so, what are the partitions? R = {(a,b): a & b are siblings} R = {(a,b): a & b are not in a course together} R = {(a,b): a & b are same classification} R = {(a,b): a & b are married} R = {(a,b): a & b are the same age} R = {(a,b): a has a higher GPA than b}
13
Homework on Relations - Section 2.2 Page 52 – 54 Problems 1 – 14, 19-20, 25
14
Section 2.4 - Functions A Function f from set X to set Y is a relation from X to Y in which for each element x in X there is exactly one element y in Y for which x f y Among the ordered pairs (x, y) in f, x appears only ONCE Example: is F a function? F = {(2,3), (3,2), (4,2)} F = {(2,3), (3,2), (2,4), (4,6)}
15
Mathematical Functions Consider mathematical FUNCTIONS Assume S = {0, 1, 2, 3, 4, 5,…} f(x) = x 2 = {(0,0), (1,1),(2,4),(3,9),(4,16),…} f(x) = x+2 = {(0,2),(1,3),(2,4),(3,5),…} For every x, there is only ONE value to which it is related, thus these are Functions!
16
Equivalence Relations - Examples A = {students enrolled at MSU in fall 2014} Which are Functions? R = {(a,b): a & b are siblings} R = {(a,b): a & b are not in a course together} R = {(a,b): a & b are same classification} R = {(a,b): a & b are married} R = {(a,b): a & b are the same age} R = {(a,b): a has a higher GPA than b}
17
Function Domain If f is a function from X to Y, denote f: X Y Set X is called the domain of the function Set Y is called co-domain Subset of Y actually paired with elements of X under f is called the range For f(x) = y, y is the image of x under f
18
Domain, Co-domain, Range Examples S = {…, -3,-2,-1,0, 1, 2, 3, 4, 5,…} Define f as a function on S F(x) = x 2 Domain = S Co-domain = S Range = ???
19
Functions – additional terms One-to-One function For every x, there is a unique y & For every y, there is a unique x {(x, y)| no repeats of x or y} S = {…, -3,-2,-1,0, 1, 2, 3, 4, 5,…} f(x) = x 2 Is f one-to-one?
20
Exponential & Logarithmic Functions Logarithmic functions IMPT in Computing Generally, base 2 NOTE: 2 n is exponential function, base 2 2 0 = 1 and 2 -n = 1/2 n See page 73 for graph – Figure 2.18 Logarithmic Function base 2 is inverse of Exponential Function
21
Logarithmic Function - Base 2 Notation: log 2 x Read “log base 2 of x” Defn: y = log 2 x if and only if x = 2 y Examples: log 2 8 = 3 because 2 3 = 8 log 2 1024 = 10 because 2 10 = 1024 log 2 256 = 8 because 2 8 = 256 log 2 100 ~~ 6.65 because 2 6.65 ~~ 100
22
More on Logarithmic Function - Base 2 Growth rate is small, less than linear See graph page 74 – Figure 2.19 Calculator Note: Most calculators with LOG button is base 10 log 2 x = LOG x / LOG 2 Algorithms with O(log 2 n) complexity??
23
Homework – Section 2.4 Note – we omitted section on Composite & Inverse Functions Page 74-75 Problems 1 - 36
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.