2.2 Relations
A relation from $A$ to $B$ is simply a subset of $A\times B$ โ the pairs that are linked. Its domain, range and codomain say where the links start and end, and there are $2^{pq}$ relations in all.
A school's records link students to the clubs they have joined. Asha is in Music and Robotics, Bilal is in Debate, and Chen has not joined any club yet. Out of all the possible (student, club) pairs โ the Cartesian product of the set of students and the set of clubs โ only some are actually linked. That chosen collection of pairs is the relation "is a member of".
Relations are everywhere: "is the mother of" in a family, "is a factor of" among numbers, "has a direct flight to" among cities, "is less than" among real numbers. In each case we start with a product $A\times B$ and select the pairs we care about. This section turns that idea into a definition, introduces the vocabulary โ domain, range, codomain โ and shows three ways to describe a relation. It also answers a counting question: how many different relations can there be between two finite sets?
Relations as Subsets of a Product
Let $A$ and $B$ be non-empty sets. A relation $R$ from $A$ to $B$ is any subset of $A\times B$: $$R\subset A\times B.$$ If $(a,b)\in R$ we say "$a$ is related to $b$", and sometimes write $a\,R\,b$; then $b$ is called an image of $a$, and $a$ a pre-image of $b$. A relation from $A$ to $A$ itself is called a relation on $A$.
The pairs of a relation are usually chosen by a rule connecting the two components โ "$b=a+1$", "$a$ divides $b$" โ but the definition does not insist on a rule: any subset of $A\times B$ counts, even $\phi$ (the empty relation, nothing linked) and the whole of $A\times B$ (the universal relation, everything linked). A relation can be described in three ways:
- roster form โ list the pairs, e.g. $R=\{(1,2),(2,3),(3,4)\}$;
- set-builder form โ give the rule, e.g. $R=\{(a,b) : a\in A,\ b\in B,\ b=a+1\}$;
- arrow diagram โ draw $A$ and $B$ as two ovals and an arrow from $a$ to $b$ for every pair $(a,b)\in R$.
Let $R$ be a relation from $A$ to $B$.
- The domain of $R$ is the set of all first components of the pairs in $R$: $\{a : (a,b)\in R \text{ for some } b\}$.
- The range of $R$ is the set of all second components: $\{b : (a,b)\in R \text{ for some } a\}$.
- The whole set $B$ is called the codomain of $R$.
Always: domain $\subset A$, and range $\subset$ codomain $=B$.
(b) $S=\{(x,x^2) : x \text{ is a prime number less than } 10\}$. Write $S$ in roster form and find its domain and range.
1. Range is not codomain. The codomain is the whole of $B$; the range is only the part of $B$ actually reached. In Example 1 the codomain contains $1$ but the range does not.
2. Domain need not be all of $A$. An element of $A$ with no arrow (like $4$ in Example 2) is simply not in the domain.
3. Direction matters. A relation from $A$ to $B$ is a subset of $A\times B$, so its pairs have the $A$-element first. $(5,2)$ cannot be in a relation from $\{1,2,3\}$ to $\{4,5,6\}$.
4. Check the sets the rule lives in. In Example 3(a), $y=5$ gives $x=0$, which is rejected because $0\notin\mathbb{N}$. Forgetting the set produces extra pairs.
How Many Relations Are There?
Choosing a relation from $A$ to $B$ means choosing a subset of $A\times B$. For each pair we make an independent yes/no decision: put it in, or leave it out.
If $A$ and $B$ are finite sets with $n(A)=p$ and $n(B)=q$, then the number of relations from $A$ to $B$ is $$2^{pq}.$$ In particular, the number of relations on a set with $n$ elements is $2^{n^2}$.
Proof. By Theorem 2.1, $A\times B$ has $pq$ pairs. A relation is fixed by deciding, for each of these $pq$ pairs, whether it is in $R$ or not: $2$ choices for the first pair, $2$ for the second, and so on, giving $2\times2\times\cdots\times2=2^{pq}$ choices (the multiplication principle you saw in Section 1.2, Example 2, and will meet properly in Chapter 6). Different choices give different subsets, so these are $2^{pq}$ different relations โ including the empty relation and the universal relation $A\times B$. $\blacksquare$
(b) There are $512$ relations from $A$ to $B$. List the possible pairs $\big(n(A),n(B)\big)$.
Exercises
- 1 $A=\{1,2,3,4,5\}$, $R=\{(a,b) : a,b\in A,\ b=a+2\}$. Write $R$ in roster form and find its domain and range.
- 2 $R=\{(x,x^3) : x\in\{-1,0,1,2\}\}$. Write $R$ in roster form; find its domain and range.
- 3 $R=\{(x,y) : x,y\in\mathbb{N},\ x+y=6\}$. Write $R$ in roster form; find its domain and range.
- 4 $A=\{2,3,5\}$, $B=\{4,6,9,10\}$, $R=\{(a,b) : a\in A,\ b\in B,\ a \text{ divides } b\}$. Write $R$, its domain and its range.
- 5 $R=\{(x,y) : x,y\in\mathbb{Z},\ y=x^2,\ -2\le x\le2\}$. Write $R$, its domain and its range.
- 6 $A=\{1,2,3,4,5\}$, $R=\{(x,y) : x,y\in A,\ y=x-1\}$. Write $R$ and find its domain and range.
- 7 Write $R=\{(1,1),(2,4),(3,9),(4,16)\}$ in set-builder form.
- 8 Write $R=\{(1,3),(2,6),(3,9),(4,12)\}$ in set-builder form.
- 9 Draw the arrow diagram of the relation in part 4. Which element of $B$ receives two arrows?
- 1 $n(A)=2$ and $n(B)=3$. How many relations are there from $A$ to $B$?
- 2 How many relations are there on the set $\{a,b\}$?
- 3 The number of relations from $A$ to $B$ is $4096$ and $n(B)=6$. Find $n(A)$.
- 4 $A=\{1,2\}$, $B=\{3,4\}$. List all relations from $A$ to $B$ with exactly three pairs.
- 5 How many relations are there from $\{1,2,3\}$ to $\{x\}$? List those whose domain is $\{1,2,3\}$.
- 6 How many relations are there on a set with $3$ elements?
- 7 $n(A)=2$, $n(B)=3$. How many relations from $A$ to $B$ have domain equal to $A$?
- 1 $R=\{(x,y) : x,y\in\mathbb{N},\ 2x+y=12\}$. Find $R$, its domain and range.
- 2 $R=\{(x,y) : x,y\in\mathbb{Z},\ x^2+y^2=25\}$. Find $n(R)$, the domain and the range.
- 3 $R=\{(x,x+5) : x\in\{0,1,2,3,4,5\}\}$. Find its domain and range.
- 4 $A=\{1,2,\dots,10\}$, $R=\{(a,b) : a,b\in A,\ b=a^2\}$. Find $R$, its domain and range.
- 5 Is $R=\{(1,2),(2,3),(3,4)\}$ a relation from $\{1,2,3\}$ to $\{2,3,4\}$? A relation on $\{1,2,3\}$? Explain.
- 6 $R=\{(x,x+1) : x\in\{1,2,3\}\}$ is regarded as a relation from $A=\{1,2,3\}$ to $B=\{1,2,3,4,5\}$. State its codomain and range, and explain why they differ.
- 1 Family. In a family, Anita is the mother of Ravi and of Meena, and Meena is the mother of Arjun. Let $F=\{\text{Anita},\text{Ravi},\text{Meena},\text{Arjun}\}$ and $R$ = "is the mother of" on $F$. Write $R$ in roster form, with its domain and range.
- 2 Clubs. Asha is in Music and Robotics, Bilal is in Debate, and Chen is in no club. Write the relation "is a member of" from the set of students to $\{\text{Music},\text{Robotics},\text{Debate}\}$, with its domain and range.
- 3 Factors. On $A=\{1,2,3,4,5,6\}$ let $R=\{(a,b) : a\ne b,\ a \text{ is a factor of } b\}$. Write $R$ in roster form; find $n(R)$, its domain and its range.
- 4 Timetable. In an exam week, Maths is on Monday, Physics and English are on Tuesday, and Chemistry is on Wednesday. Write the relation "is held on" from subjects to days. Does every subject have exactly one day? Does every day have exactly one subject?
How this is examined: Board papers give a relation by a rule and ask for its roster form, domain and range (2โ3 marks, sometimes with an arrow diagram), or ask for a range or a count of relations as a 1-mark question. JEE uses $2^{pq}$ in counting questions and relations defined by equations on $\mathbb{Z}$.
E1. Board ยท 1 mark Let $R=\{(1,2),(2,3),(1,3)\}$ be a relation on $A=\{1,2,3\}$. The range of $R$ is (A) $\{1,2\}$ (B) $\{2,3\}$ (C) $\{1,2,3\}$ (D) $\{3\}$
E2. Board ยท 2 marks Let $R=\{(x,y) : x,y\in\mathbb{N},\ x+3y=12\}$. Write $R$ in roster form and find its domain and range.
E3. Board ยท 3 marks Let $A=\{2,3,4,8,9\}$ and $R=\{(a,b) : a,b\in A,\ a\ne b,\ a \text{ divides } b\}$. (i) Write $R$ in roster form. (ii) Find its domain and range. (iii) Draw its arrow diagram.
E4. JEE Main If $n(A)=3$ and $n(B)=2$, the number of relations from $A$ to $B$ containing at least two ordered pairs is (A) $57$ (B) $58$ (C) $63$ (D) $64$
E5. JEE Main Numerical value. Let $A=\{1,2,3\}$ and $B=\{a,b\}$. Find the number of relations from $A$ to $B$ whose domain is $A$.
E6. JEE Advanced One or more options correct. Let $R=\{(x,y) : x,y\in\mathbb{Z},\ x^2+y^2=50\}$. Then (A) $R$ has exactly $12$ elements (B) the domain of $R$ has exactly $6$ elements (C) $0$ belongs to the domain of $R$ (D) the range of $R$ is different from its domain
Research question. In a small real network โ who has whose phone number saved, or who follows whom in a class group โ how "dense" is the relation, and how many links are mutual?
Why it matters. Social networks, citation databases and transport maps are stored as relations: sets of ordered pairs. Network scientists measure them by the fraction of possible pairs that are present, $n(R)/n(A\times A)$, and by how often a link $(a,b)$ comes with its reverse $(b,a)$. The same measurements are used to study the spread of rumours and of infections.
What to do.
- With permission, take $6$ to $8$ classmates as the set $A$. For each ordered pair $(a,b)$ with $a\ne b$, record whether $a$ has $b$'s number saved (or follows $b$).
- Write the relation in roster form and draw its arrow diagram (or a grid of $A\times A$ with ticks).
- Find $n(R)$, the domain and the range. Is anyone outside the domain (saves nobody) or outside the range (saved by nobody)?
- Compute the density $n(R)/\big(n(A)\,(n(A)-1)\big)$ and count the mutual pairs.
Tools: Paper grid or a spreadsheet (one row and one column per person)
Hand in: The grid, the arrow diagram, the four numbers, and a short paragraph comparing your network with a partner's.
Going further. How many different "who-saves-whom" relations are possible on your set (pairs with $a\ne b$ only)? Use the idea of Theorem 2.3: each of the $n(n-1)$ allowed pairs is in or out.
๐งช Self-check quiz
Q1. A relation from $A$ to $B$ is
Q2. The range of $R=\{(1,4),(2,5),(3,4)\}$ is
Q3. If $n(A)=n(B)=2$, the number of relations from $A$ to $B$ is
Q4. The domain of $R=\{(x,y) : x,y\in\mathbb{N},\ x+y=4\}$ is
Q5. For every relation from $A$ to $B$,