Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Relations and Functions: Mathematics Concepts For Computing

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 41

Mathematics Concepts For Computing

AQ010-3-1-MCFC & Version 2

Relations and Functions


Topic & Structure of The Lesson

Introduction
Cartesian Product Set
Relations, Mapping & Function
Properties of Relations
Operations on Functions
Invertible Functions

AQ010-3-1-Mathematical Concepts for Computing Relation & Function Slide ‹2› of 9


Learning Outcomes

• At the end of this topic, You should be able


to
• Identify relations which are functions and determine
the domain and range of a given relation or function
and at the same time performed mapping.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function Slide ‹3› of 9


Key Terms You Must Be Able To
Use
• If you have mastered this topic, you should be able to use the following
terms correctly in your assignments and exams:
• Cartesian product
• Relation
• Reflexive
• Symmetric
• Transitive
• Function
• Inverse
• Domain
• Range
• Codomain

AQ010-3-1-Mathematical Concepts for Computing Relation & Function Slide ‹4› of 9


Applications
Explain the connection / relationship

• Between a program and a variable it uses.


• Between a computer language and a valid statement in
the language.
• Between elements of sets are represented using the
structure called a relation.
• Between people, numbers, sets, and many other entities
can be formalized in the idea of a binary relation.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Cartesian Product Set

Ordered pairs
An ordered pair consists of two elements, of which one
is designated as the first element and the other as the
second element.
 It is written as (a, b) where a is the first element and b
is the second element.
Def 1: We use the notation aRb to denote that (a,
b)R, and a is said to be related to b by R if aRb.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Cartesian Product Set

Consider two sets,


the set of all ordered pairs (a,b) where a A
and b B is called the product , or Cartesian
product of A and B.
A short designation of this product is A x B,
which is read “A crosses B”, by definition
A x B = (a,b)a  A, b  B
A x A can be represented as A 2

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Slide 7 (of 18)
Cartesian Product Set

 A binary relation between set A and B is a


subset of A × B.
 Example :
Given A={1, 2}, B={p, q}.
If R1={(1, p)},
R2={(2, k)} and R3={(1,q), (2,p)}

R1 and R3 are the relations between A and B,


but R2 is not the relation between A and B.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Example
Let A be the set {1, 2, 3, 4}. Which ordered
pairs are in the relation R = { (a, b)| a divides
b }?
Sol :

1 1
2 2

3 3

4 4

R = { (1,1), (1,2), (1,3), (1,4),


(2,2), (2,4),
(3,3),
(4,4) }
AQ010-3-1-Mathematical Concepts for Computing Relation & Function
Example . Consider the following relations on Z.
R1 = { (a, b) | a  b }
R2 = { (a, b) | a > b }
R3 = { (a, b) | a = b or a = -b } Which of these relations
contain each of the pairs
R4 = { (a, b) | a = b }
(1,1), (1,2), (2,1), (1,-1),
R5 = { (a, b) | a = b+1 }
and (2,2)?
R6 = { (a, b) | a + b  3 }
Sol : (1,1) (1,2) (2,1) (1,-1) (2,2)
R1 ● ● ●

R2 ● ●

R3 ● ● ●

● ●
R4

R5
● ● ● ●
R
AQ010-3-1-Mathematical Concepts for Computing Relation & Function
Relation
• A relation is a set of ordered pairs.
• The presence of the ordered pair (a,b) in a relation is
interpreted as indicating a relationship from a to b.
• Domain of R : Dom(R) is the set of all elements in A that
are related to some element in B.
• Range of R : Ran(R) is the set of all elements in B that
are related to some element in A.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Relation
• Example. Let A = {Alice, Bob, Claire, Dan} be a
set students,
• and B= {CS101, CS201, CS202} be a set of
courses. Then, a possible relation is:
{(Alice, CS101), (Bob, CS201), (Bob, CS202),
(Dan, CS201), (Dan, CS202)}

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Representing Relations

AQ010-3-1-Mathematical Concepts for Computing Relation & Function Slide 13 of 9


Example

Given A = {1, 2, 3, 4} and B = {x, y, z}. Let R be the


following relation from A to B:
R = {(1,y), (1,z), (3,y), (4,x), (4,z)}
(a) Find A x B.
(b) Draw the arrow diagram of R.
(c) Determine the domain and range of R.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function ‹#›


Equivalence Relation
• In mathematics, an equivalence relation is a binary
relation that is reflexive, symmetric and transitive.

Properties of a relation:
Let R be the a relation on a set A,
- R is reflexive : If (a,a)  R for every element a  A.
- R is symmetric : If (b,a)  R whenever (a,b)  R, for
some a,b  A.
- R is transitive: If (a,b)  R and (b,c)  R, then (a,c)  R ,
for a, b, c  A.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function Slide 15 of 9


Equivalence Relation

• The relations “has the same hair color as” or “is the
same age as” in the set of people are equivalence
relations.
• The equivalence classes under the relation “has the
same hair color as” are the set of blond people, the set
of red-haired people, etc.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function Slide 16 of 9


Reflexivity
Example.
= is reflexive, since a = a
≤ is reflexive, since a ≤ a
< is not reflexive is a < a is false.

Symmetric

AQ010-3-1-Mathematical Concepts for Computing Relation & Function Slide 17 of 9


Examples on Transitivity

AQ010-3-1-Mathematical Concepts for Computing Relation & Function Slide 18 of 9


Example 1
Consider the relation R on a set {1,2,3,4,5}.
R = {(1,1), (1,3), (1,5), (2,2), (2,4), (3,1), (3,3), (3,5), (4,2),
(4,4), (5,1), (5,3), (5,5)} is an equivalence relation?

Answer:
• R is reflexive because (1,1), (2,2), (3,3), (4,4), (5,5) are
in R.
• R is symmetric because whenever (x,y) is in R, (y,x) is in
R as well.
• R is transitive because whenever (x,y) and (y,z) are in R,
(x,z) is in R as well.
• So, R is an equivalence realtion.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function Slide 19 of 9


Example 2

Consider the relation R on a set {1,2,3,4}.


R = {(1,1), (1,2), (1,3), (1,4), (2,2), (2,3), (2,4), (3,3), (3,4),
(4,4)}

Answer:
R is NOT an equivalence relation because R is not
symmetric.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function Slide 20 of 9


Properties of Relations
Are the following relations on {1, 2, 3, 4} reflexive?

R1 = {(1, 1), (1, 2), (2, 3), (3, 3), (4, 4)}
R2 = {(1, 1), (2, 2), (2, 3), (3, 3), (4, 4)}
R3 = {(1, 3), (3, 2), (2, 1)}
Sol: R2

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Properties of Relations

Are the following relations on {1, 2, 3, 4} symmetric?

R1 = {(1, 1), (1, 2), (2, 1), (3, 3), (4, 4)}
R2 = {(1, 1)}
R3 = {(1, 3), (3, 2), (2, 1)}
R4 = {(4, 4), (3, 3), (1, 4)}

Sol: R1, R2

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Properties of Relations

Are the following relations on {1, 2, 3, 4} transitive?

R1 = {(1, 1), (1, 2), (2, 2), (2, 1), (3, 3)}

R2 = {(1, 3), (3, 2), (2, 1)}

R3 = {(2, 4), (4, 3), (2, 3), (4, 1)}

Sol: R1

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Example
Let R be the relation on a set A = {1, 2, 3, 4}.
Determine the following given relations for reflexive,
symmetric and transitive.

R1 ={(1,1), (1,2), (2,1), (2,2), (3,4), (4,1), (4,4)}


R2 ={(1,1), (1,2), (2,1)}
R3 ={(1,1), (1,2), (1,4), (2,1), (2,2), (3,3), (4,1), (4,4)}
R4 ={(2,1), (3,1), (3,2), (4,1), (4,2), (4,3)}
R5 ={(1,1), (1,2), (1,3), (1,4), (2,2), (2,3), (2,4), (3,3),
(3,4), (4,4)}

AQ010-3-1-Mathematical Concepts for Computing Relation & Function ‹#›


Functions
A function f from a nonempty set A to a nonempty set B
is an assignment of exactly one element of B to each
element of A.

We write the function as f : A  B.


Functions are also called mappings or transformations.

- b = f(a) is called the image of a under f, and


f a is called the object of b.
• •
a b= (a) - A is the domain of f and B is the co-domain
- f(A) = { f(a) | a  A} is called the range of f
A B

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


From Relation to Function
A relation f from A to B is a function if:
• Every element of A is related to some element of B
• An element of A cannot be related to more than one
element of B.

A B A B

1 a 1 a
2 b 2 b
3 c 3 c
4 4

A function (many-to-one) Not a function (one-to-many)

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Relation Vs Function
A function yields a single result for any element in its domain.
Example: age (of a person), square (of an integer) etc.

A relation allows multiple mappings between the domain and


the co-domain.
Example: students enrolled in multiple courses.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Example
Determine whether the following relation is a
function.
A B A B

α 1 α 1
β 2 β

γ 2
γ 3

A Not a function B A B
Not a function

α 1 α 1
2
β 2 β
3
γ γ
4
a function a function

AQ010-3-1-Mathematical Concepts for Computing Relation & Function ‹#›


Example
Let f be the function defined by the rule f(x)= X2
f

0 0
1
1 2
3
2 4

Set X Set Y

X2 = Y is a function from X to Y.
Domain is {0, 1, 2} and Codomain is {0, 1, 2, 3, 4}.

f(a)=b, so f(0)=0, f(1)=1 and f(2)=4


Range is {0,1,4}
AQ010-3-1-Mathematical Concepts for Computing Relation & Function
Operations on Functions
Sum of functions
(f +g)(x) = f(x) + g(x)

Difference of functions
(f – g)(x) = f(x) – g(x)

Product of functions
(fg)(x) = f(x) . g(x)

Quotient of functions
(f/g)(x) = f(x)
g(x)
AQ010-3-1-Mathematical Concepts for Computing Relation & Function
Example 1

2
Given f (x) =x - 4, g(x) =x + 2
Find:
1) (f + g)(x)
2) (f - g)(x)
3) (fg)(x)
4) (f/g)(x)

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Composite Functions

 Let g be a function from the set A to the set B


and let f be a function from set B the set C.
 Find the image of a under f and then find the
image of f(a) under g.
 The composition functions f and g, is defined by
(g o f)(a) = g(f(a))

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Composition Functions- Example

You use composite functions whenever you buy a sale


(discounted) item. When you are standing in the store
trying to decide if you can afford the item, the first thing you
calculate is the discount.
• For example, I want to buy this 20 dollar shirt, and it is
on sale at 15% off. This means that the shirt is really 17
dollars.
• Now, you must calculate what the shirt will cost after
sales tax (let's say it is 8%).
• Your total cost for the shirt after the discount and sales
tax will be $18.36. This process of computation can be
expressed as a composite function.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Example (Contd)

• If f(x) = The price of the shirt after the discount and g(x)
= The price after sales tax then,
• The function for the final cost of the shirt = g(f(x)).

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Example

Given f (x) =3x - 1, g(x) =4x +3


Find:
1) (f o g)(x)
2) (g o f)(x)

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Inverse Functions
Def: Let f be a one-to-one function from the set A to
the set B. The inverse function of f is the function
that assigns to an element b belonging to B the
unique element a in A such that f(a) = b. The
inverse function of f is denoted as f -1.
Hence, f -1(b) = a when f(a) = b.

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Example

Given that f ( x )  2 
Find ,
( x 1) 3

1
(i) f ( x)
(ii) f 1 (16)

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Quick Review Question

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Slide 38 (of 18)
Summary of Main Teaching Points

• Cartesian product set


• Relations, Mapping & Function
• Properties of Relations
• Operations on Functions
• Invertible Functions

AQ010-3-1-Mathematical Concepts for Computing Relation & Function


Slide 39 (of 18)
Question and Answer Session

Q&A

AQ010-3-1-Mathematical Concepts for Computing Relation & Function Slide ‹40› of 9


What we will cover next

Discrete Probability

AQ010-3-1-Mathematical Concepts for Computing Relation & Function Slide ‹41› of 9

You might also like