Relations

"Is a parent of." "Is greater than." "Maps to." Every one of these everyday links between two collections of things has a precise mathematical shape: a relation is nothing but a chosen set of ordered pairs, one entry taken from each collection. Before you can define a function — a rule assigning exactly one output to each input — you need the more general language of relations, and that language starts with the ordered pair and the Cartesian product. This article builds that language from scratch: what an ordered pair is and when two of them are equal, how the Cartesian product A×BA \times B collects every possible pairing of two sets, how a relation is simply a subset of that product, and how domain, co-domain, and range describe which pairs actually occur. Two worked examples, one in roster form and one from a rule, fix the ideas.

The core insight

A relation from set AA to set BB is any subset of the Cartesian product A×BA \times B, so it is completely described by which ordered pairs (a,b)(a,b) it contains.

The core idea

Ordered pairs. An ordered pair (a,b)(a,b) has a fixed first component aa and second component bb, and the order is part of its identity: two ordered pairs are equal exactly when both components match.

(a,b)=(c,d)  ⟺  a=c and b=d(a,b) = (c,d) \iff a = c \text{ and } b = d

where: a,ca, c are the first components and b,db, d are the second components. In particular (a,b)≠(b,a)(a,b) \neq (b,a) unless a=ba = b — this is what separates an ordered pair from a two-element set, where {a,b}={b,a}\{a,b\} = \{b,a\} always.

Cartesian product. For sets AA and BB, the Cartesian product collects every possible ordered pairing of an element of AA with an element of BB:

A×B={(a,b):a∈A, b∈B}A \times B = \{(a,b) : a \in A,\ b \in B\}

where: aa ranges over all of AA and bb ranges over all of BB, independently, so every combination appears exactly once. When AA and BB are finite, the size of the product follows a simple counting rule, n(A×B)=n(A)⋅n(B)n(A \times B) = n(A) \cdot n(B), proved below. The same idea extends to three sets: A×B×CA \times B \times C is the set of ordered triples (a,b,c)(a,b,c), and R×R×R=R3\mathbb{R} \times \mathbb{R} \times \mathbb{R} = \mathbb{R}^3 is the set of all ordered triples of real numbers — the coordinate space used for points in three dimensions.

Relations. A relation RR from AA to BB is simply a subset of the Cartesian product:

R⊆A×BR \subseteq A \times B

where: every element of RR is itself an ordered pair (a,b)(a,b) with a∈Aa \in A, b∈Bb \in B. If (a,b)∈R(a,b) \in R, we say "aa is related to bb" and write a R ba\,R\,b. A relation can be presented in roster form (a list of pairs), by a set-builder rule (a condition the pairs must satisfy), as an arrow diagram between two sets, or as a graph of points in the plane — all four are the same underlying set of pairs, just displayed differently. Three sets travel with every relation:

  • The domain is the set of first components that actually occur in RR — the inputs that are used.
  • The co-domain is the set BB itself, fixed in advance when RR is defined, whether or not every element of BB is used.
  • The range is the set of second components that actually occur in RR — always a subset of the co-domain, but not necessarily all of it.
Figure
An arrow diagram from set A to set B showing three arrows landing on two of three elements of B, illustrating that the domain and range are the parts actually used while the co-domain is the whole target set
Domain, co-domain, and range of a relation R A (domain side) B (co-domain) 1 2 3 2 4 6 domain = 1, 2, 3 · range = 2, 4 (used) · co-domain = 2, 4, 6 (whole target set, 6 unused)
Derivation AThe counting rule for a Cartesian product

The goal here is to show why n(A×B)=n(A)⋅n(B)n(A \times B) = n(A) \cdot n(B) always holds for finite sets, not just to state it, so that the rule can be trusted for any pair of finite sets rather than memorised as a formula that happens to work in small examples.

Step 1. Fix the first component. Suppose n(A)=mn(A) = m and n(B)=kn(B) = k. Pick any single element a∈Aa \in A. Pairing this one fixed aa with each element of BB in turn produces exactly kk distinct ordered pairs — one pair (a,b)(a,b) for every b∈Bb \in B, and no two of these kk pairs can coincide because their second components differ.

Step 2. Repeat for every choice of first element. There are mm possible choices of aa (all of AA), and Step 1 shows each choice contributes its own block of exactly kk pairs. These blocks never overlap: a pair from the block built on a1a_1 and a pair from the block built on a2≠a1a_2 \neq a_1 differ in their first component, so they cannot be the same pair.

Step 3. Add the blocks. The full set A×BA \times B is the union of these mm non-overlapping blocks, each of size kk, so

n(A×B)=k+k+⋯+k⏟m times=m⋅k=n(A)⋅n(B)n(A \times B) = \underbrace{k + k + \cdots + k}_{m \text{ times}} = m \cdot k = n(A) \cdot n(B)

Step 4. Sanity-check on a small case. With A={1,2,3}A = \{1,2,3\} (m=3m=3) and B={2,4}B=\{2,4\} (k=2k=2), the rule predicts n(A×B)=3×2=6n(A \times B) = 3 \times 2 = 6, matching the 6 pairs listed by direct enumeration in the worked example below.

Worked example

Problem. A={1,2,3}A = \{1, 2, 3\}, B={2,4}B = \{2, 4\}. Find A×BA \times B and n(A×B)n(A \times B), then let R={(a,b)∈A×B:a<b}R = \{(a,b) \in A \times B : a < b\} and find RR, its domain, co-domain, and range.

Step 1. List every ordered pair with first entry from AA and second entry from BB:

A×B={(1,2),(1,4),(2,2),(2,4),(3,2),(3,4)}A \times B = \{(1,2),(1,4),(2,2),(2,4),(3,2),(3,4)\}

By the counting rule, n(A×B)=n(A)⋅n(B)=3×2=6n(A \times B) = n(A) \cdot n(B) = 3 \times 2 = 6, which matches the 6 pairs listed.

Step 2. Test each pair of A×BA \times B against the condition a<ba < b: (1,2)(1,2) satisfies it since 1<21<2; (1,4)(1,4) satisfies it since 1<41<4; (2,2)(2,2) fails since 2≮22 \not< 2; (2,4)(2,4) satisfies it since 2<42<4; (3,2)(3,2) fails since 3≮23 \not< 2; (3,4)(3,4) satisfies it since 3<43<4.

Step 3. Collect the pairs that pass:

R={(1,2),(1,4),(2,4),(3,4)}R = \{(1,2),(1,4),(2,4),(3,4)\}

Step 4. Read off domain, co-domain, and range. The domain is the set of distinct first entries in RR: {1,2,3}\{1,2,3\}. The co-domain is the target set BB itself: {2,4}\{2,4\}. The range is the set of distinct second entries in RR: {2,4}\{2,4\}. Here the range happens to equal the co-domain, though that is not required in general.

Competitive stretch

A second relation on R\mathbb{R} is defined by R′={(x,y):y=x2, x∈{−2,−1,0,1,2}}R' = \{(x,y) : y = x^2,\ x \in \{-2,-1,0,1,2\}\}. Evaluating y=x2y = x^2 at each given xx gives x=−2⇒y=4x=-2 \Rightarrow y=4, x=−1⇒y=1x=-1 \Rightarrow y=1, x=0⇒y=0x=0 \Rightarrow y=0, x=1⇒y=1x=1 \Rightarrow y=1, x=2⇒y=4x=2 \Rightarrow y=4, so R′={(−2,4),(−1,1),(0,0),(1,1),(2,4)}R' = \{(-2,4),(-1,1),(0,0),(1,1),(2,4)\}. The domain is {−2,−1,0,1,2}\{-2,-1,0,1,2\}, but the range collapses repeated values into {0,1,4}\{0,1,4\} — even though 44 and 11 each arise from two different xx-values, each appears only once in the range because the range is a set.

Common traps

  • Confusing an ordered pair with a two-element set: (a,b)≠{a,b}(a,b) \neq \{a,b\}, since order matters for pairs — (1,2)≠(2,1)(1,2)\neq(2,1) — but not for sets, since {1,2}={2,1}\{1,2\}=\{2,1\}.
  • Listing repeated values in the range: the range is a set, so a second component that occurs twice, as in the competitive stretch above, is written once, not twice.
  • Assuming range equals co-domain automatically: the co-domain is chosen in advance as the whole target set BB, while the range depends only on which pairs actually belong to RR; range is always a subset of co-domain but need not be all of it.
  • Miscounting n(A×B)n(A \times B) by adding instead of multiplying: the counting rule is n(A)⋅n(B)n(A) \cdot n(B), never n(A)+n(B)n(A) + n(B).

Ask the tutor: Want to practise turning a word description straight into a relation and pinning down its domain and range?

Why does order matter in an ordered pair but not in a set?

An ordered pair is built to record which element came from which set — the first slot is reserved for the element of AA, the second for the element of BB, so swapping them changes the meaning entirely, like swapping latitude and longitude. A set has no slots at all, just membership, so {a,b}\{a,b\} and {b,a}\{b,a\} describe the exact same collection. Keeping this distinction straight is exactly why (a,b)≠{a,b}(a,b) \neq \{a,b\} in general.

Is every relation also a function?

No. A relation is any subset of A×BA \times B at all — it can leave some elements of AA unused, and it can pair one element of AA with several different elements of BB. A function is a much more restrictive relation: every element of the domain set must appear as a first component exactly once, giving one and only one output. So every function is a relation, but most relations are not functions — the formal test for this comes later in the "Functions" sub-topic.

How is the co-domain different from the range if they can look the same in examples?

The co-domain is a choice you make when defining the relation — you fix a target set BB before deciding which pairs go into RR. The range is a consequence — it is whatever second components happen to show up once RR is actually written down. They can coincide, as in the first worked example, purely by chance of which pairs satisfied the condition; nothing forces them to. Always check the range by listing the pairs, never by assuming it matches the stated co-domain.

Before this

Where this leads