Sets, Relations and Functions
The grammar of all higher mathematics — collections, the links between them, and the machines that turn one into another
- Why a set — a well-defined collection of distinct objects — is the single idea every later topic is written in.
- How to name, classify and combine sets, and prove statements with Venn diagrams and De Morgan's laws.
- Counting overlapping groups with the inclusion–exclusion principle.
- How a relation links two sets, and what makes one an equivalence relation that slices a set into classes.
- What a function really is, how to find its \(\text{domain}\) and \(\text{range}\), and how to tell one-one from onto from bijective.
- The standard library of functions, plus composition, inverses, and even / odd / periodic behaviour.
The Language of Sets
If physics begins with measurement, mathematics begins with the set. Numbers, points, lines, matrices, functions, even probabilities — every object you will ever meet in this book is, underneath, a set or a collection built from sets. Learn this language well and the rest of mathematics reads like sentences instead of riddles.
The idea is due to Georg Cantor in the 1870s. A set is simply a well-defined collection of distinct objects. The objects are its elements (or members). Two words carry all the weight:
For any object, you can decide without argument whether it belongs. "All prime numbers below 20" is a set; "all large numbers" is not — there is no sharp test for membership.
An element is either in or out — it is never counted twice. So \(\{1,2,2,3\}\) is just the set \(\{1,2,3\}\).
Order does not matter inside a set: \(\{a,b,c\}=\{c,a,b\}\). (Order will matter later, for ordered pairs.)
We write membership with the symbol \(\in\) ("belongs to") and its negation \(\notin\). Sets are named with capital letters, elements with small letters:
Describing a Set
There are two standard ways to pin down exactly which elements a set contains.
List every element between braces, separated by commas: \(A=\{2,3,5,7\}\). For an unmistakable pattern you may use dots: the natural numbers are \(\mathbb{N}=\{1,2,3,\dots\}\).
State the rule for membership: \(A=\{x : x \text{ is prime and } x<10\}\). Read the bar "|" or colon ":" as "such that." This is the form competitive exams love.
Types of Sets
| Name | Meaning | Example |
|---|---|---|
| Empty / null set | Contains no element; written \(\varnothing\) or \(\{\,\}\) | \(\{x:x^2=-1,\,x\in\mathbb{R}\}\) |
| Singleton | Exactly one element | \(\{0\}\) |
| Finite set | A countable, ending list of elements | \(\{a,e,i,o,u\}\) |
| Infinite set | Elements never run out | \(\mathbb{Z},\ \mathbb{R}\) |
| Equal sets | Exactly the same elements: \(A=B\) | \(\{1,2\}=\{2,1\}\) |
| Equivalent sets | Same number of elements (same cardinality) | \(\{a,b\}\sim\{9,10\}\) |
The number of elements in a finite set \(A\) is its cardinal number, written \(n(A)\) or \(|A|\). Note carefully: equal sets are always equivalent, but equivalent sets need not be equal.
There is only one empty set. And mind the difference: \(\varnothing\) contains nothing, but \(\{\varnothing\}\) is a singleton — a box containing one (empty) box. So \(n(\varnothing)=0\) while \(n(\{\varnothing\})=1\).
Subsets, Power Sets & Intervals
If every element of \(A\) is also in \(B\), we call \(A\) a subset of \(B\) and write \(A\subseteq B\). If in addition \(B\) has something \(A\) lacks, \(A\) is a proper subset, \(A\subset B\). Two facts hold for every set:
Collect all the subsets of \(A\) into one set and you get the power set \(P(A)\). If \(n(A)=n\), then:
Of these, \(2^{n}-1\) are proper subsets, and \(2^{n}-2\) are non-empty proper subsets. Why \(2^n\)? Each element independently chooses "in or out" — two choices, \(n\) times.
In any given discussion, all sets are subsets of one big universal set \(U\). For real analysis, the most useful subsets of \(\mathbb{R}\) are intervals — continuous stretches of the number line. A filled dot (closed, \([\,]\)) includes the endpoint; a hollow dot (open, \((\,)\)) excludes it.
| Notation | Set-builder | Endpoints |
|---|---|---|
| \([a,b]\) | \(\{x:a\le x\le b\}\) | both included |
| \((a,b)\) | \(\{x:a< x< b\}\) | both excluded |
| \([a,b)\) | \(\{x:a\le x< b\}\) | left only |
| \((a,b]\) | \(\{x:a< x\le b\}\) | right only |
| \((a,\infty)\) | \(\{x:x> a\}\) | \(\infty\) never closed |
Set Operations & Venn Diagrams
A Venn diagram draws the universal set as a rectangle and each set as a region inside it. Shading the answer turns an abstract set identity into a picture you can simply read off.
| Operation | Symbol | Set-builder definition |
|---|---|---|
| Union | \(A\cup B\) | \(\{x: x\in A \text{ or } x\in B\}\) |
| Intersection | \(A\cap B\) | \(\{x: x\in A \text{ and } x\in B\}\) |
| Difference | \(A-B\) | \(\{x: x\in A \text{ and } x\notin B\}\) |
| Complement | \(A'\) or \(A^{c}\) | \(\{x\in U: x\notin A\}=U-A\) |
| Symmetric difference | \(A\,\triangle\,B\) | \((A-B)\cup(B-A)\) |
The Algebra of Sets
Set operations obey laws that mirror ordinary algebra — with one famous twist. Memorise these; many JEE shortcuts are just one identity applied cleverly.
| Law | Statement |
|---|---|
| Commutative | \(A\cup B=B\cup A,\quad A\cap B=B\cap A\) |
| Associative | \((A\cup B)\cup C=A\cup(B\cup C)\) |
| Distributive | \(A\cap(B\cup C)=(A\cap B)\cup(A\cap C)\) |
| Identity | \(A\cup\varnothing=A,\quad A\cap U=A\) |
| Idempotent | \(A\cup A=A,\quad A\cap A=A\) |
| Complement | \(A\cup A'=U,\quad A\cap A'=\varnothing,\quad (A')'=A\) |
The complement of a union is the intersection of complements, and vice-versa. In words: "not (A or B)" is "not A and not B." These are the most-used identities in the whole chapter.
Counting: The Inclusion–Exclusion Principle
How many people read at least one of two newspapers? You cannot just add — you would count the overlap twice. So you add, then subtract the double-counted middle. That single idea, scaled up, is the inclusion–exclusion principle.
Problems often ask for those in exactly one region. Sketch the three-circle Venn, place the centre value first, work outward, and label all seven regions. Then read off whatever the question wants — "exactly two," "none," "at least one."
Cartesian Products & Relations
Inside a set, order is irrelevant. But to describe pairings — a point \((x,y)\), a fixture between two teams — we need order to matter. An ordered pair \((a,b)\) has a first and a second slot:
The Cartesian product \(A\times B\) is the set of all ordered pairs with first entry from \(A\) and second from \(B\):
A relation \(R\) from \(A\) to \(B\) is nothing more than a subset of \(A\times B\) — a chosen collection of the pairs that "belong together." If \((a,b)\in R\) we write \(a\,R\,b\).
- The domain is the set of all first entries that actually appear.
- The range is the set of all second entries that actually appear.
- The codomain is the whole "target" set \(B\) (the range may be smaller).
Because \(A\times B\) has \(mp\) pairs, and a relation is any subset of them — and a set of \(mp\) elements has \(2^{mp}\) subsets.
Types of Relations on a Set
When a relation runs from a set \(A\) to itself, three properties decide its character. Test each one with the question in the right-hand column.
| Property | Condition for all \(a,b,c\in A\) | Ask yourself |
|---|---|---|
| Reflexive | \(a\,R\,a\) | Is every element related to itself? |
| Symmetric | \(a\,R\,b \Rightarrow b\,R\,a\) | Does the link work both ways? |
| Transitive | \(a\,R\,b,\ b\,R\,c \Rightarrow a\,R\,c\) | Does it chain through? |
Such a relation carves \(A\) into non-overlapping equivalence classes — a partition. "Has the same remainder mod 5," "is parallel to," and "is congruent to" are all equivalence relations.
Functions: The Big Idea
A function is a special relation — a reliable machine. Feed it an input and it returns exactly one output, every time, with no input left unprocessed. Formally, a function \(f:A\to B\) assigns to each \(a\in A\) one and only one \(b=f(a)\in B\).
Two rules separate a function from a mere relation: (1) every element of the domain must be used, and (2) none may map to two different outputs. The arrow diagrams make the distinction vivid:
For a graph in the \(xy\)-plane: if any vertical line meets the curve more than once, it is not a function — that \(x\) would have two outputs. A circle fails; a parabola \(y=x^2\) passes.
Classifying Functions
Two independent questions classify every function \(f:A\to B\). Do different inputs always give different outputs? (one-one). Does every target value get hit? (onto).
| Type | Plain English | Test |
|---|---|---|
| One-one (injective) | No two inputs share an output | \(f(x_1)=f(x_2)\Rightarrow x_1=x_2\) |
| Many-one | Some output is shared | fails the above |
| Onto (surjective) | Range = codomain | every \(b\in B\) has a pre-image |
| Bijective | One-one and onto together | perfectly invertible |
Of these, the number that are one-one (needs \(m\le n\)) is \({}^{n}P_{m}=\dfrac{n!}{(n-m)!}\). When \(m=n\), one-one, onto and bijective all coincide, and there are exactly \(n!\) of them. Use the horizontal line test on a graph to spot one-one functions.
The Standard Function Library
A handful of real functions appear again and again. Knowing each one's domain and range by heart is half the battle in calculus.
| Function | Rule | Domain | Range |
|---|---|---|---|
| Identity | \(f(x)=x\) | \(\mathbb{R}\) | \(\mathbb{R}\) |
| Constant | \(f(x)=c\) | \(\mathbb{R}\) | \(\{c\}\) |
| Modulus | \(f(x)=|x|\) | \(\mathbb{R}\) | \([0,\infty)\) |
| Signum | \(\operatorname{sgn}(x)=\tfrac{x}{|x|},\,x\neq0\) | \(\mathbb{R}\) | \(\{-1,0,1\}\) |
| Greatest integer | \(f(x)=\lfloor x\rfloor\) | \(\mathbb{R}\) | \(\mathbb{Z}\) |
| Fractional part | \(\{x\}=x-\lfloor x\rfloor\) | \(\mathbb{R}\) | \([0,1)\) |
| Exponential | \(f(x)=a^{x},\,a>0,a\neq1\) | \(\mathbb{R}\) | \((0,\infty)\) |
| Logarithm | \(f(x)=\log_a x\) | \((0,\infty)\) | \(\mathbb{R}\) |
The greatest-integer (floor) function rounds down, toward \(-\infty\). So \(\lfloor 2.3\rfloor=2\) but \(\lfloor -2.3\rfloor=-3\), not \(-2\). This single sign trip-up wrecks more exam answers than almost anything else in the chapter.
Algebra, Composition & Inverse
Where two functions share a domain, you can add, subtract, multiply and divide them point-by-point: \((f+g)(x)=f(x)+g(x)\), and so on — with \((f/g)(x)\) defined only where \(g(x)\neq0\).
More powerful is composition: feed the output of one machine straight into the next. \((g\circ f)(x)=g\big(f(x)\big)\) — apply \(f\) first, then \(g\).
A function can be "undone" only if it loses no information — that is, only if it is a bijection. Its undoing is the inverse \(f^{-1}\):
Useful identities: \((f^{-1})^{-1}=f\) and \((g\circ f)^{-1}=f^{-1}\circ g^{-1}\) (socks-and-shoes: undo in reverse order). Graphically, \(y=f^{-1}(x)\) is the mirror image of \(y=f(x)\) across the line \(y=x\).
Even, Odd & Periodic Functions
Symmetry gives a function a personality you can exploit in integration, graphing and series.
\(f(-x)=f(x)\). The graph is mirror-symmetric about the \(y\)-axis. Examples: \(x^2,\ \cos x,\ |x|\).
\(f(-x)=-f(x)\). The graph has half-turn symmetry about the origin. Examples: \(x^3,\ \sin x,\ \tan x\).
\(f(x+T)=f(x)\) for some smallest \(T>0\), the fundamental period. \(\sin x\) has period \(2\pi\), \(\{x\}\) has period \(1\).
Putting It to Work
Problem. Among 100 students, 40 study Mathematics, 35 Physics and 30 Chemistry; 15 take Maths and Physics, 10 Maths and Chemistry, 12 Physics and Chemistry, and 5 take all three. How many study (a) at least one subject, (b) none, (c) exactly one?
Solution. Apply the three-set formula for "at least one":
(b) None: \(100-73=27\). (c) For exactly one, subtract the shared regions. Exactly-one totals \((40+35+30)-2(15+10+12)+3(5)=105-74+15=46\) students.
Problem. On \(\mathbb{Z}\) define \(a\,R\,b \iff (a-b)\text{ is divisible by }5\). Show \(R\) is an equivalence relation and describe its classes.
Solution.
- Reflexive: \(a-a=0=5\cdot0\), divisible by 5. ✓
- Symmetric: if \(a-b=5k\) then \(b-a=5(-k)\). ✓
- Transitive: if \(a-b=5k\) and \(b-c=5m\), then \(a-c=5(k+m)\). ✓
So \(R\) is an equivalence relation. It partitions \(\mathbb{Z}\) into five classes by remainder: \([0],[1],[2],[3],[4]\) — the residue classes modulo 5.
Problem. Find the domain and range of \(f(x)=\sqrt{9-x^{2}}\).
Solution. The square root needs a non-negative inside, so \(9-x^{2}\ge0 \Rightarrow x^{2}\le9 \Rightarrow -3\le x\le3\). Hence the domain is \([-3,3]\). As \(x\) sweeps this interval, \(9-x^2\) runs from 0 (at the ends) up to 9 (at \(x=0\)), so \(f\) runs from 0 to 3. The range is \([0,3]\).
Problem. Let \(f:\mathbb{R}\to\mathbb{R}\), \(f(x)=2x+3\) and \(g(x)=x^{2}\). Find \((f\circ g)(x)\) and \((g\circ f)(x)\), show \(f\) is bijective, and find \(f^{-1}\).
Solution. \((f\circ g)(x)=f(x^2)=2x^2+3\), while \((g\circ f)(x)=(2x+3)^2\) — clearly different, confirming non-commutativity. For \(f\): it is one-one (slope \(2\neq0\)) and onto \(\mathbb{R}\), so bijective. Solve \(y=2x+3\) for \(x\):
Problem. Classify \(f(x)=x^{3}-x\) and decompose \(g(x)=x^2+2x\) into even and odd parts.
Solution. \(f(-x)=(-x)^3-(-x)=-x^3+x=-f(x)\), so \(f\) is odd. For \(g\), the even part is \(\tfrac12[g(x)+g(-x)]=x^2\) and the odd part is \(\tfrac12[g(x)-g(-x)]=2x\) — exactly the two terms, as expected.
Chapter Summary
A well-defined collection of distinct, unordered objects. Describe by roster or set-builder; classify as empty, finite, infinite, equal or equivalent.
\(2^n\) subsets; power set \(P(A)\). Combine sets with \(\cup,\cap,-,'\) and read identities off Venn diagrams.
De Morgan's laws and distribution; \(n(A\cup B)=n(A)+n(B)-n(A\cap B)\) with the three-set extension.
A subset of \(A\times B\); \(2^{mp}\) in all. Reflexive + symmetric + transitive = equivalence, which partitions the set.
Each input one output. Classify as one-one / onto / bijective; \(n^m\) functions in total; know each standard function's domain and range.
\((g\circ f)(x)=g(f(x))\), associative but not commutative. Invertible \(\iff\) bijective; even/odd/periodic capture symmetry.
Problems
Work these with set-builder notation, Venn diagrams and careful domain checks. Difficulty rises down the list.
- Write \(A=\{x\in\mathbb{Z}: x^2<20\}\) in roster form, and write \(\{2,4,6,8,10\}\) in set-builder form.
- List every subset of \(\{a,b,c\}\). How many subsets does a 6-element set have, and how many of those are non-empty proper subsets?
- Given \(U=\{1,\dots,10\}\), \(A=\{1,2,3,4,5\}\), \(B=\{4,5,6,7\}\), find \(A\cup B,\ A\cap B,\ A-B,\ A'\), and verify De Morgan's law \((A\cup B)'=A'\cap B'\).
- In a town, 65% read newspaper X, 40% read Y, and 25% read both. What percentage read at least one? What percentage read neither?
- If \(n(A)=3\) and \(n(B)=2\), find \(n(A\times B)\) and the number of relations from \(A\) to \(B\).
- On the set \(\{1,2,3\}\), decide whether \(R=\{(1,1),(2,2),(3,3),(1,2),(2,1)\}\) is reflexive, symmetric and/or transitive.
- Show that "is parallel to" on the set of lines in a plane is an equivalence relation, and describe an equivalence class.
- Use the vertical line test to decide which of \(x^2+y^2=4\) and \(y=x^2+1\) defines \(y\) as a function of \(x\).
- Find the domain of \(f(x)=\dfrac{1}{\sqrt{x-2}}+\sqrt{5-x}\).
- Find the range of \(f(x)=\dfrac{x^2}{1+x^2}\).
- For \(f(x)=3x-2\) and \(g(x)=x^2+1\), compute \((g\circ f)(x)\) and \(f^{-1}(x)\).
- Determine whether \(f(x)=\dfrac{e^x-e^{-x}}{e^x+e^{-x}}\) is even, odd, or neither, and state its range.