Relations and Functions • Topic 2 of 3

Relations: Domain, Codomain and Range

A relation $R$ from set $A$ to set $B$ is any subset of $A \times B$. So a relation simply selects the ordered pairs that satisfy some rule, leaving the rest out:

$$R \subseteq A \times B; \qquad (a, b) \in R \text{ is written } a\,R\,b$$

For each relation we name three sets:

TermMeaning
Domainset of all first components in $R$ — the inputs actually used
Rangeset of all second components in $R$ — the outputs actually produced
Codomainthe whole target set $B$ — every output that could appear

The range is always a subset of the codomain ($\text{range} \subseteq B$), but they need not be equal — the codomain is the "menu", the range is "what was ordered".

Counting relations: a relation is a subset of $A \times B$, which has $n(A)\cdot n(B)$ pairs. Since a set with $k$ elements has $2^k$ subsets, the number of possible relations from $A$ to $B$ is

$$\text{number of relations} = 2^{\,n(A)\cdot n(B)}$$

Relations are often given by a rule, e.g. $R = \{(x, y) : y = x + 1,\ x \in A\}$, which you then list in roster form by testing each input.

Deeper Insight — a relation is a filter, and that is the bridge to functions: The whole content of this idea is "subset of the Cartesian product". $A \times B$ offers every possible pairing; a relation keeps only the pairings that obey a chosen condition — it is a filter on pairings. Reading the definition this way makes the domain/range distinction obvious: the domain is which inputs survived the filter, the range is which outputs they map to. It also explains the codomain, the subtlest of the three: we declare a target set $B$ in advance (the codomain) before we know which of its members will actually be hit (the range). This advance declaration is exactly what makes the next section possible — a function is nothing more than a relation with one extra rule imposed on the filter ("each input is used once, and exactly once"), so understanding a relation as a constrained subset is the conceptual key to the rest of the chapter.

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. $x=1 \Rightarrow y=4$; $x=2 \Rightarrow y=5$; $x=3 \Rightarrow y=6$.
  2. $R = \{(1,4),(2,5),(3,6)\}$.
  3. Domain $= \{1,2,3\}$; Range $= \{4,5,6\}$.

Answer: $R = \{(1,4),(2,5),(3,6)\}$; domain $\{1,2,3\}$, range $\{4,5,6\}$ (codomain is $\{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$.
  2. Number of relations $= 2^{6} = 64$.

Answer: $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. Keep only pairs where both $x$ and $2x$ lie in $A$.
  2. $x=1 \to 2$; $x=2 \to 4$; $x=3 \to 6$. For $x=4,5,6$, $2x$ exceeds $6$.

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. $R = \{(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. Every pair has its first component in $A$ and second in $B$, so $R \subseteq A \times B$ — valid.
  2. Domain $= \{1,2\}$ (first components).
  3. Range $= \{3,5\}$ (second components).

Answer: Yes, valid; domain $\{1,2\}$, range $\{3,5\}$. (Note $1$ relates to two values — fine for a relation.)

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

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

Key Points

  • A relation $R$ from $A$ to $B$ is any subset of $A \times B$.
  • Domain = first components used; range = second components produced; codomain = the whole target $B$.
  • Always $\text{range} \subseteq \text{codomain}$, but they may differ.
  • Number of relations from $A$ to $B$ is $2^{n(A)\cdot n(B)}$.
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$.