A relation from A to B is nothing more than a selection of cells from the rectangular grid A \times B. The definition is that compact: pick any subset of the pairs, and that subset is a valid relation. This article gives you a live grid where you can watch relations come into existence, one pair at a time.
What the grid shows
Take A = \{1, 2, 3, 4\} on the vertical axis and B = \{p, q, r, s, t\} on the horizontal axis. The 4 \times 5 = 20 cells cover every possible ordered pair from A to B. A relation is any subset — you pick which cells are filled and which are empty.
Reading the grid
The row tells you the first coordinate (from A); the column tells you the second (from B). A filled cell at row 2, column s means the ordered pair (2, s) belongs to the relation. An empty cell means it does not.
The eight filled cells in the figure correspond to the relation
You could pick any other eight cells and get a completely different relation. The total number of possible relations from A to B equals the number of subsets of the grid: 2^{|A| \cdot |B|} = 2^{20}. The slider position gives a sense of how many pairs are involved for a given size, not which specific pairs (that is a separate choice).
Reading the row and column projections
The grid picture also lets you read off the domain and range at a glance.
- The domain of R is the set of rows that contain at least one filled cell. For the example above, every row has a dot, so the domain is all of A = \{1, 2, 3, 4\}.
- The range of R is the set of columns that contain at least one filled cell. Looking at the example, columns p, q, r, s, t all contain at least one dot, so the range is all of B.
If you shrink the relation by dragging the slider left, rows and columns start going empty — and the domain and range shrink with them. An empty row means that first-coordinate is not in the domain. An empty column means that second-coordinate is not in the range.
What the grid is not
Why: a relation is a set of pairs, not a rule. The grid enumerates every possible pair and lets you tick off which ones are in. That distinction matters — many textbooks introduce relations via a rule ("a divides b"), but the rule is just a shorthand for "these are the cells I ticked."
- The grid is not a function graph. A function is a special relation where every row has exactly one filled cell. A general relation can have zero, one, or many filled cells per row.
- The grid is not Cartesian coordinates. The axes carry the elements of A and B, which can be any objects — people, colours, words, numbers. The picture is about membership, not geometry.
- The grid does not tell you why a pair was chosen. A relation is defined by its members; any rule that produces those members is a valid description, and two different rules describing the same set of pairs describe the same relation.
Three instructive relations
The empty relation. Zero dots. Slider at 0. No element is related to anything. Domain and range are both empty.
The full product A \times B. All 20 dots. Slider at 20. Every element of A is related to every element of B. Domain = A, range = B.
The diagonal. When A = B, the dots \{(1,1), (2,2), (3,3), (4,4)\} form the identity relation — every element related to itself and nothing else. This is the smallest reflexive relation and the simplest non-empty equivalence relation.
The link to the formal definition
Every formal fact about relations is visible on the grid:
| Grid observation | Formal statement |
|---|---|
| The row for a has a dot in column b | (a, b) \in R |
| The row for a is entirely empty | a \notin \text{dom}(R) |
| The column for b is entirely empty | b \notin \text{range}(R) |
| Total number of dots | $ |
| Total number of cells | $ |
| Number of distinct dot-patterns | $2^{ |
The grid is not just a pretty picture — it is a literal drawing of the definition. A relation is a subset of cells, and the picture is the set. Train your eye to read the domain off the non-empty rows and the range off the non-empty columns, and every relation problem becomes a visual one.
Related: Relations · Set Operations · Cartesian Product Grid · Cardinality of A × B