Every introductory chapter on relations sneaks in a counting question: "how many relations can you form on a set with n elements?" The answer — 2^{n^2} — is one of those numbers that feels too big to be right. For n = 5, it is 2^{25} = 33{,}554{,}432 relations. For n = 10, it is 2^{100}, which is more than the number of atoms in a human body. The count is correct, and the why is a clean two-step argument that also locks in the formula for general relations from A to B.
The two-step count
Here is the argument in its simplest form.
The $2^{n^2}$ count
Let A be a set with n elements. The number of relations on A is
because (a) a relation on A is a subset of A \times A, (b) A \times A has n \cdot n = n^2 ordered pairs, and (c) a set with k elements has 2^k subsets.
Steps (a), (b), (c) are each standard results. The trick is seeing how they compose.
Step 1: a relation is a subset
The definition says a relation on A is any subset of A \times A. That is not a property of a relation — it is literally what a relation is. So counting relations means counting subsets of A \times A. You do not need to worry about properties like reflexivity or symmetry at this stage; every subset, however weird, is a valid relation.
Step 2: the Cartesian product has n^2 elements
For every ordered pair (a, b) \in A \times A, the first coordinate a can be any of the n elements of A and the second coordinate b can independently be any of the n elements. So the number of ordered pairs is
This is just the "row times column" count of a square grid. Laying A along both axes gives an n \times n grid with n^2 cells — one cell per ordered pair.
Step 3: each cell is an independent in/out choice
For every cell in the grid, you have a binary choice: include this pair in your relation, or do not.
- Cell (1, 1): in or out? 2 choices.
- Cell (1, 2): in or out? 2 choices.
- ... and so on for all n^2 cells.
- Cell (n, n): in or out? 2 choices.
Each choice is independent of the others — there is no constraint forcing one pair in or out based on the others (you are counting all relations, not just equivalence relations or functions). So by the multiplication principle:
distinct ways to pick your subset. This matches the general fact that a set with k elements has 2^k subsets — here k = n^2.
Interactive: watch the count explode
The general formula for relations from A to B
The same argument gives the count for relations between two (possibly different) sets.
If |A| = m and |B| = n, then A \times B has mn ordered pairs, and the number of subsets is 2^{mn}.
So a relation from A to B — with |A| = m and |B| = n — is one of 2^{mn} possibilities. When A = B and m = n, this collapses to 2^{n \cdot n} = 2^{n^2}.
Summary table:
| Setup | Number of relations |
|---|---|
| From A (size m) to B (size n) | 2^{mn} |
| On A (size n) | 2^{n^2} |
| On A (size n), reflexive | 2^{n^2 - n} |
| On A (size n), symmetric | 2^{n(n+1)/2} |
The last two are what you would count after imposing a property — interesting, but not the base count 2^{n^2} that the chapter asks for first.
The common error: 2^n instead of 2^{n^2}
Students sometimes write 2^n for the number of relations on a set of n elements. The mistake is forgetting step 2 — confusing the number of elements in A (which is n) with the number of pairs in A \times A (which is n^2).
A set of subsets of A has 2^n members. A set of subsets of A \times A has 2^{n^2} members. The distinction shows up whenever the ambient set is itself a Cartesian product.
Why the right size is n^2: each ordered pair has two independent slots, each with n choices. It is like counting the cars on a chessboard — there are 8 \times 8 = 64 squares, not 8. A relation picks squares, not rows.
Sanity check: n = 1 and n = 2
Always try tiny cases to trust a formula.
n = 1: A = \{a\}. Then A \times A = \{(a, a)\}, a one-element set. Its subsets are \varnothing and \{(a, a)\} — exactly 2. Formula: 2^{1^2} = 2^1 = 2. Match.
n = 2: A = \{a, b\}. Then A \times A has 4 pairs: (a,a), (a,b), (b,a), (b,b). Subsets count: 2^4 = 16. Formula: 2^{2^2} = 2^4 = 16. Match.
The formula survives small cases, which is strong evidence it is correct for all n.
The one-line derivation
A relation on A is a subset of A \times A; A \times A has n^2 pairs; a set with n^2 elements has 2^{n^2} subsets. Therefore the number of relations on A is 2^{n^2}.
Related: Relations · How Many Subsets? 2ⁿ · Cartesian Product Grid · Sets — Introduction