I've been looking at the following example exercise:
Consider the relation
$R = \{(0,2), (0,3), (1,0), (1,3), (2,0), (2,3)\}$
On the set
$A = \{0, 1, 2, 3, 4\}$
Determine $R^2$
and the textbook says the answer is
$R^2 = \{(0,0), (0,3), (1,2), (1,3), (2,2), (2,3)\}$
however, my problem is that I don't understand how $R$ was derived in the first place, and subsequently I don't understand how this leads to the answer for $R^2$.
Could somebody explain to me how the relation $R$ is generated? Once this is clear I should be able to work from there.
The relation $R \subseteq A \times A$ is defined in the exercise, it is not "derived".
What is derived is the relation \begin{align} R^2 = R \circ R = \{(x,y) \in A \times A \mid \exists z \in A \text{ such that } x \, R \, z \text{ and } z \, R \, y \}. \end{align}
You can easily check that $R^2 = \{(0,0),(0,3),(1,2),(1,3),(2,2),(2,3)\}$. For instance, $0 \, R^2 \, 0$ because $0 \,R\, 2$ and $2 \,R\, 0$. On the contrary, $1 \not R^2 1$ because there is no $a \in A$ such that $1 \,R\, a$ and $a \,R\, 1$.