A point on a graph, a seat marked "row, column" in a cinema hall: in both, the order of the two entries matters, and (2,5) is not the same as (5,2). Pairs like these build the Cartesian product of two sets, and a relation turns out to be nothing more than a collection of such pairs. We will define ordered pairs and Cartesian products, count them, and then describe relations in roster form, set-builder form and arrow diagrams, along with their domain, codomain and range. All of this is the groundwork for functions in the next lesson.
Two ordered pairs are equal only when they match entry by entry: (a,b)=(c,d) exactly when a=c and b=d. So (x−2,y+3)=(4,−1) gives x=6 and y=−4.
The Cartesian product collects every possible pair: A×B={(a,b):a∈A,b∈B}. For A={1,2} and B={x,y,z}:
A×B={(1,x),(1,y),(1,z),(2,x),(2,y),(2,z)}
Every element of the first set pairs with every element of the second, so n(A×B)=n(A)⋅n(B). Watch the order, though: A×B=B×A unless A=B (or one of them is empty). You have been using a Cartesian product for years without the name: R×R is the coordinate plane, and R×R×R is space.
The six ordered pairs of A x B drawn as a grid
Example 1.A={1,2}: A×A×A has 8 triples, (1,1,1),(1,1,2),…,(2,2,2).
Example 2. If A×B={(p,1),(p,2),(q,1),(q,2)} then A={p,q}, B={1,2}.
Example 3.A×(B∩C)=(A×B)∩(A×C): with A={1}, B={2,3}, C={3,4}, both sides are {(1,3)}.
Out of all the possible pairs, a rule usually picks out only some. That selection is a relation: a relation from A to B is any subset R of A×B. We write (a,b)∈R or aRb, and call b the image of a.
Domain: the set of first elements of pairs in R.
Codomain: the whole of B.
Range: the set of second elements actually used, which is a subset of the codomain.
Example 4. Take A={1,2,3,4,5,6} and the relation R={(a,b):b=a+2} on A. Then R={(1,3),(2,4),(3,5),(4,6)}, with domain {1,2,3,4}, range {3,4,5,6} and codomain A. Notice that the two largest elements have no image, since adding two takes them outside the set.
An arrow diagram shows a relation at a glance: draw A and B as ovals and join each a to its images.
Arrow diagram of the relation b = a + 2 in Example 4
Counting relations. The same in-or-out argument you used for subsets works here. A×B has n(A)n(B) pairs, and each one is either in the relation or out, so there are 2n(A)n(B) relations from A to B. With n(A)=2 and n(B)=3, that is already 26=64.