Relations and Functions • Topic 2 of 3

Relations: Domain, Codomain and Range

A relation $R$ from a set $A$ to a set $B$ is simply a subset of the Cartesian product $A \times B$. In words, $R$ selects some of the possible ordered pairs and declares those elements "related". If $(a, b) \in R$ we write $a\,R\,b$ ("$a$ is related to $b$").

$$R \subseteq A \times B, \qquad R = \{(a, b) : a \in A,\ b \in B \text{ and } a,b \text{ satisfy a stated rule}\}$$

The "stated rule" is the heart of the relation — it might be "$y = x + 3$", "$a$ divides $b$", or anything that, for each pair, is unambiguously true or false. A relation from $A$ to itself (a subset of $A \times A$) is called a relation on $A$.

Roster and set-builder forms. Like any set, a relation can be written by listing its pairs (roster form), e.g. $R = \{(1,4),(2,5),(3,6)\}$, or by stating the defining property (set-builder form), e.g. $R = \{(x, y) : y = x + 3,\ x \in A\}$. Converting set-builder to roster is a standard task: run through each allowed $x$, compute the matching $y$, and keep the pair only if $y$ actually lies in $B$.

Three sets attached to every relation.

  • The domain is the set of all first components that actually occur in $R$: $\text{Dom}(R) = \{a : (a, b) \in R\}$.
  • The range is the set of all second components that actually occur: $\text{Range}(R) = \{b : (a, b) \in R\}$.
  • The codomain is the whole target set $B$, whether or not every element of $B$ is used.

The distinction between range and codomain matters: the range is always a subset of the codomain ($\text{Range}(R) \subseteq B$), but it need not equal it. The domain is likewise a subset of $A$. Think of the codomain as the set you aim at and the range as where you actually land.

Arrow diagrams. A relation is pictured by drawing $A$ and $B$ as two ovals of dots and drawing an arrow from $a$ to $b$ whenever $(a, b) \in R$. The dots in $A$ that have an arrow leaving them form the domain; the dots in $B$ that have an arrow arriving form the range; all of $B$ is the codomain. Arrow diagrams make it easy to see, at a glance, which inputs are unused and whether any input has more than one arrow.

Counting relations. Since a relation is any subset of $A \times B$, and $A \times B$ has $n(A) \cdot n(B) = mn$ ordered pairs, the number of possible relations equals the number of subsets of $A \times B$:

$$\text{If } n(A) = m \text{ and } n(B) = n, \text{ then the number of relations from } A \text{ to } B = 2^{mn}$$

This includes the empty relation (no pairs at all) and the universal relation $R = A \times B$ (every possible pair). The reasoning is exactly the power-set argument from Chapter 1: each of the $mn$ pairs is independently either in $R$ or not.

Deeper Insight — a relation is "the cells you tick" in the product grid: The single most useful mental model is to picture $A \times B$ as a rectangular grid with one cell per ordered pair. A relation is just a choice of which cells to tick — nothing more. From this one picture everything follows: the domain is the set of rows containing at least one tick, the range is the set of columns containing at least one tick, the codomain is every column whether ticked or not, and the count $2^{mn}$ is simply "each of the $mn$ cells is in or out". This grid view is also what makes the leap to functions painless: a function is the special case where every row contains exactly one tick. Master the grid and you have mastered both relations and the functions built on top of them.

Arrow diagram of a relation showing domain, range and codomain Relation R: a → b means (a, b) ∈ R A (domain set) B (codomain) 1232345 range = {2,3,4} ⊆ codomain {2,3,4,5}; element 5 is unused
1
Worked Example
Let $A = \{1,2,3\}$, $B = \{4,5,6,7\}$ and $R = \{(x,y) : y = x + 3,\ x \in A\}$. Write $R$ in roster form and state its domain and range.
Solution
  1. For each $x \in A$ compute $y = x + 3$: $x=1 \to 4$, $x=2 \to 5$, $x=3 \to 6$.
  2. Each $y$ lies in $B$, so all pairs are kept.
  3. Domain = first components, Range = second components.

Answer: $R = \{(1,4),(2,5),(3,6)\}$; domain $= \{1,2,3\}$, range $= \{4,5,6\}$ (codomain is all of $B = \{4,5,6,7\}$).

2
Worked Example
If $n(A) = 3$ and $n(B) = 2$, how many relations can be defined from $A$ to $B$?
Solution
  1. $n(A \times B) = 3 \times 2 = 6$ ordered pairs.
  2. A relation is any subset, so the count is $2^{6}$.

Answer: $2^{6} = 64$ relations.

3
Worked Example
A relation $R$ on $A = \{1,2,3,4,5,6\}$ is $R = \{(x,y) : y = 2x\}$. Write $R$ in roster form.
Solution
  1. For each $x$, $y = 2x$ must also lie in $A$.
  2. $x=1 \to 2$, $x=2 \to 4$, $x=3 \to 6$ all valid.
  3. $x=4 \to 8$, $x=5 \to 10$, $x=6 \to 12$ — these $y$ are not in $A$, so dropped.

Answer: $R = \{(1,2),(2,4),(3,6)\}$.

4
Worked Example
Write the domain and range of $R = \{(x, x^2) : x \text{ is a prime} < 10\}$.
Solution
  1. Primes below $10$: $2, 3, 5, 7$.
  2. Pairs: $(2,4),(3,9),(5,25),(7,49)$.

Answer: Domain $= \{2,3,5,7\}$; range $= \{4,9,25,49\}$.

5
Worked Example
The figure-free relation $R = \{(1,3),(1,5),(2,5)\}$ is from $A=\{1,2\}$ to $B=\{3,5\}$. Is this a valid relation? Find its domain and range.
Solution
  1. Check every pair lies in $A \times B$: all first components are in $A$, all second in $B$ — valid.
  2. Domain = first components $= \{1,2\}$.
  3. Range = second components $= \{3,5\}$.

Answer: Yes, it is a valid relation; domain $= \{1,2\}$, range $= \{3,5\}$.

6
Worked Example
Let $R = \{(a,b) : a, b \in \mathbb{N},\ a + b = 5\}$. Write $R$ and its range.
Solution
  1. Find natural-number pairs summing to $5$: $(1,4),(2,3),(3,2),(4,1)$.
  2. $(5,0)$ is excluded since $0 \notin \mathbb{N}$.

Answer: $R = \{(1,4),(2,3),(3,2),(4,1)\}$; range $= \{1,2,3,4\}$.

7
Worked Example
If $A = \{1,2\}$ and $B = \{3,4\}$, list any three different relations from $A$ to $B$, and state the total number of possible relations.
Solution
  1. $A \times B = \{(1,3),(1,4),(2,3),(2,4)\}$ has $4$ pairs.
  2. Any subset is a relation, e.g. $R_1 = \varnothing$ (empty relation), $R_2 = \{(1,3)\}$, $R_3 = A \times B$ (universal relation).
  3. Total relations $= 2^{4} = 16$.

Answer: Three examples are $\varnothing$, $\{(1,3)\}$ and $\{(1,3),(1,4),(2,3),(2,4)\}$; there are $2^{4} = 16$ relations in all.

8
Worked Example
A relation $R$ on $A = \{1,2,3,4\}$ is defined by $R = \{(x, y) : x \text{ divides } y\}$. Write $R$ in roster form and state its domain, codomain and range.
Solution
  1. Pair $x$ with every $y \in A$ that $x$ divides exactly.
  2. $x=1$: $(1,1),(1,2),(1,3),(1,4)$; $x=2$: $(2,2),(2,4)$; $x=3$: $(3,3)$; $x=4$: $(4,4)$.
  3. Domain = first components, range = second components; codomain is all of $A$.

Answer: $R = \{(1,1),(1,2),(1,3),(1,4),(2,2),(2,4),(3,3),(4,4)\}$; domain $= \{1,2,3,4\}$, range $= \{1,2,3,4\}$, codomain $= \{1,2,3,4\}$.

9
Worked Example
Distinguish range from codomain for $R = \{(1,2),(2,4)\}$ from $A = \{1,2,3\}$ to $B = \{2,4,6,8\}$.
Solution
  1. Codomain is the whole target set $B = \{2,4,6,8\}$, by definition.
  2. Range is only the second components that occur: $\{2,4\}$.
  3. Here range $\subset$ codomain, since $6$ and $8$ are never hit.

Answer: Codomain $= \{2,4,6,8\}$ but range $= \{2,4\}$; the range is a proper subset of the codomain.

10
Worked Example
Express the relation $R = \{(1,1),(2,4),(3,9),(4,16)\}$ in set-builder form and state its domain.
Solution
  1. Compare each pair: $(1,1),(2,4),(3,9),(4,16)$ — the second component is the square of the first.
  2. So $y = x^2$ with $x$ running over $1,2,3,4$.

Answer: $R = \{(x, y) : y = x^2,\ x \in \{1,2,3,4\}\}$; domain $= \{1,2,3,4\}$.

11
Worked Example
A relation $R$ from $A = \{2,3,4,5\}$ to $B = \{3,6,7,10\}$ is given by "$x$ is relatively prime to $y$" (their HCF is $1$). Write $R$ in roster form.
Solution
  1. Test each pair; keep it when $\text{HCF}(x,y) = 1$.
  2. $x=2$: coprime with $3, 7$ → $(2,3),(2,7)$. $x=3$: coprime with $7, 10$ → $(3,7),(3,10)$.
  3. $x=4$: coprime with $3, 7$ → $(4,3),(4,7)$. $x=5$: coprime with $3, 6, 7$ → $(5,3),(5,6),(5,7)$.

Answer: $R = \{(2,3),(2,7),(3,7),(3,10),(4,3),(4,7),(5,3),(5,6),(5,7)\}$.

Key Points

  • A relation $R$ from $A$ to $B$ is any subset of $A \times B$; $(a,b) \in R$ is written $a\,R\,b$.
  • Relations can be given in roster form (list the pairs) or set-builder form (state the rule).
  • Domain = set of first components that occur; range = set of second components that occur.
  • Codomain is the whole target set $B$; the range satisfies $\text{Range}(R) \subseteq B$ and need not equal it.
  • Arrow diagrams draw an arrow $a \to b$ for each $(a,b) \in R$; outgoing dots give the domain, incoming dots the range.
  • A relation on $A$ is a subset of $A \times A$.
  • Number of relations from $A$ to $B$ is $2^{mn}$ where $m = n(A)$, $n = n(B)$ — including the empty and universal relations.
Tap an option to check your answer0 / 4
Q1.A relation from $A$ to $B$ is a subset of:
Explanation: A relation is any set of ordered pairs from $A\times B$.
Q2.The domain of $R=\{(1,2),(3,4)\}$ is:
Explanation: Domain = first components.
Q3.The range of $R=\{(1,2),(3,4)\}$ is:
Explanation: Range = second components.
Q4.The number of relations from a $2$-element set to a $2$-element set is:
Explanation: $2^{n(A)\cdot n(B)}=2^{4}=16$.