A function is always a relation but relation is not always a function
<u>Solution:</u>
Given that, we have to explain Is a relation always a function and is a function always a relation
Note that both functions and relations are defined as sets of lists.
In fact, every function is a relation. However, not every relation is a function. A relation from a set X to a set Y is called a function if each element of X is related to exactly one element in Y.
That is, given an element x in X, there is only one element in Y that x is related to.
For example, consider the following sets X and Y. Let me give you a relation between them that is not a function;
X = { 1, 2, 3 }
Y = { a , b , c, d }
Relation from X to Y : { (1,a) , (2, b) , (2, c) , (3, d) }
This relation is not a function from X to Y because the element 2 in X is related to two different elements, b and c
Relation from X to Y that is a function: { (1,d) , (2,d) , (3, a) }
This is a function since each element from X is related to only one element in Y. Note that it is okay for two different elements in X to be related to the same element in Y. It's still a function, it's just not a one-to-one function.
So, we can say that function is a type of relation.
Which means whatever a function occurs, it will be a relation from one set to other.
But when a relation occurs it may be a function but need not be always a function.
Hence, a function is always a relation but relation is not always a function.