# Composition of Relations

## Solved Problems

### Example 1.

The relation \(R\) on the set of real numbers \(\mathbb{R}\) is defined by \[R = \left\{ {\left( {x,y} \right) \mid y = x - 1} \right\}.\] Find the composition of relations \(R^2.\)

Solution.

By definition, the composition \(R^2\) is the relation given by the following property:

where

To determine the composed relation \(xRz,\) we solve the system of equations:

Hence, the composition \(R^2\) is given by

It is clear that the composition \(R^n\) is written in the form

### Example 2.

The relation \(S\) on the set of real numbers \(\mathbb{R}\) is defined by \[S = \left\{ {\left( {x,y} \right) \mid y = x^2 + 1} \right\}.\] Find the composition of relations \(S^2.\)

Solution.

The composition \(S^2\) is given by the property:

where

We eliminate the variable \(y\) in the second relation by substituting the expression \(y = x^2 +1\) from the first relation:

So we have:

### Example 3.

Given the set \(A = \left\{ {0,1,2} \right\}\) with the relations \(R = \left\{ {\left( {0,1} \right),\left( {0,2} \right),\left( {1,1} \right),\left( {2,0} \right)} \right\}\) and \(S = \left\{ {\left( {0,0} \right),\left( {0,2} \right),\left( {1,0} \right),\left( {1,1} \right)} \right\}.\) Find the compositions \(S \circ R\) and \(R \circ S.\)

Solution.

- Consider the composition \(S \circ R.\) Recall the the first step in this composition is \(R\) and the second is \(S.\) The first element in \(R\) is \({\left( {0,1} \right)}.\) Look for pairs starting with \(1\) in \(S:\) \({\left( {1,0} \right)}\) and \({\left( {1,1} \right)}.\) Therefore \({\left( {0,1} \right)}\) in \(R\) combined with \({\left( {1,0} \right)}\) in \(S\) gives \({\left( {0,0} \right)}.\) Similarly, \({\left( {0,1} \right)}\) in \(R\) combined with \({\left( {1,1} \right)}\) in \(S\) gives \({\left( {0,1} \right)}.\) We use the same approach to match all other elements from \(R.\) As a result, we find all pairs belonging to the composition \(S \circ R:\)
\[S \circ R = \left\{ {\left( {0,0} \right),\left( {0,1} \right),\left( {1,0} \right),\left( {1,1} \right),\left( {2,0} \right),\left( {2,2} \right)} \right\}.\]
- The composition \(R \circ S\) implies that \(S\) is performed in the first step and \(R\) is performed in the second step. Consider the first element of the relation \(S:\) \({\left( {0,0} \right)}.\) We see that it matches to the following pairs in \(R:\) \({\left( {0,1} \right)}\) and \({\left( {0,2} \right)}.\) Hence, the composition \(R \circ S\) contains the elements \({\left( {0,1} \right)}\) and \({\left( {0,2} \right)}.\) Continuing in this way, we find that
\[R \circ S = \left\{ {\left( {0,0} \right),\left( {0,1} \right),\left( {0,2} \right),\left( {1,1} \right),\left( {1,2} \right)} \right\}.\]
As it can be seen, the composition of relations is not commutative.

### Example 4.

Given the set \(A = \left\{ {a,b,c} \right\}\) with the relations \(R = \left\{ {\left( {a,a} \right),\left( {a,c} \right),\left( {b,a} \right),\left( {c,b} \right)} \right\}\) and \(S = \left\{ {\left( {a,b} \right),\left( {b,c} \right),\left( {c,c} \right)} \right\}.\) Find the composition \({S^{-1}} \circ {R^{-1}}.\)

Solution.

First we write the inverse relations \(R^{-1}\) and \(S^{-1}:\)

The first element in \(R^{-1}\) is \({\left( {a,a} \right)}.\) It has no match to the relation \(S^{-1}.\)

Take the second element in \(R^{-1}:\) \({\left( {a,b} \right)}.\) It matches to the pair \({\left( {b,a} \right)}\) in \(S^{-1},\) producing the composed pair \({\left( {a,a} \right)}\) for \(S^{-1} \circ R^{-1}.\)

Similarly, we find that \({\left( {b,c} \right)}\) in \(R^{-1}\) combined with \({\left( {c,b} \right)}\) in \(S^{-1}\) gives \({\left( {b,b} \right)}.\) The same element in \(R^{-1}\) can also be combined with \({\left( {c,c} \right)}\) in \(S^{-1},\) which gives the element \({\left( {b,c} \right)}\) for the composition \(S^{-1} \circ R^{-1}.\)

The last pair \({\left( {c,a} \right)}\) in \(R^{-1}\) has no match in \(S^{-1}.\) Thus, the composition of relations \(S^{-1} \circ R^{-1}\) contains the following elements:

### Example 5.

Consider the set \(A = \left\{ {1,2,3} \right\}\) with the relations \(R = \left\{ {\left( {1,1} \right),\left( {1,3} \right),\left( {2,1} \right),} \right.\) \(\kern-2pt\left.{\left( {2,2} \right),\left( {3,1} \right)} \right\}\) and \(S = \left\{ {\left( {1,2} \right),\left( {2,1} \right),} \right.\) \(\kern-2pt\left.{\left( {2,2} \right),\left( {3,3} \right)} \right\}.\) Calculate the composition \({R \circ S}\) in matrix form.

Solution.

The relations \(R\) and \(S\) are represented by the following matrices:

To find the composition of relations \(R \circ S,\) we multiply the matrices \(M_S\) and \(M_R:\)

We used here the Boolean algebra when making the addition and multiplication operations.

Hence, the composition of relations \(R \circ S\) is given by

### Example 6.

Consider the set \(A = \left\{ {a,b,c} \right\}\) with the relation \(R = \left\{ {\left( {a,b} \right),\left( {b,a} \right),\left( {b,c} \right),} \right.\) \(\kern-2pt\left.{\left( {c,c} \right)} \right\}.\) Calculate the combined relation \({R^2 \cap R^{-1}}\) in matrix form.

Solution.

First, we convert the relation \(R\) to matrix form:

Compute the composition of relations \(R^2\) using matrix multiplication:

The inverse (or converse) relation \(R^{-1}\) is represented by the following matrix:

Now we can find the intersection of the relations \(R^2\) and \(R^{-1}.\) Remember that when calculating the intersection of relations, we apply Hadamard matrix multiplication, which is different from the regular matrix multiplication. So, we multiply the corresponding elements of the matrices \(M_{R^2}\) and \(M_{R^{-1}}:\)

Thus, the final relation contains only one ordered pair: