Chapter 1 · Sets, Relations and Functions

1.2 Functions

A function is a relation that gives every element of its domain exactly one image. We find domains and ranges, sort functions into one-one or many-one and onto or into, count them on finite sets — $n^m$ functions, $3^m-3\cdot2^m+3$ onto ones — and combine them by composition, $(g\circ f)(x)=g(f(x))$.

A railway reservation system takes the list of passengers on a train and gives each one a seat. Each passenger must get exactly one seat — no passenger without a seat, none with two. That rule is what makes the allocation a function from passengers to seats. Two further questions decide whether the booking is sound and whether the train is full. Does any seat go to two passengers? (If not, the allocation is one-one.) Is every seat taken? (If so, it is onto.) A booking that is both pairs passengers and seats perfectly.

Functions also chain together. An oil slick spreads so that its radius after $t$ minutes is $r=3t$ metres; its area is $A=\pi r^2$. Feeding the first rule into the second gives the area directly as a function of time, $A=\pi(3t)^2=9\pi t^2$ — a composite function. In this section we define functions as special relations (Section 1.1), learn to find their domains and ranges, classify them as one-one or many-one and onto or into, count them on finite sets, and study composition. Every later unit of JEE Main — limits, derivatives, integrals, inverse trigonometric functions, probability distributions — is written in this language, and the paper regularly asks directly for the number of one-one or onto functions, the domain or range of a formula, or a property of a composite.

Functions, Domain, Codomain and Range

📘 Definition 1.10 — Function

A relation $f$ from a non-empty set $A$ to a set $B$ is a function (or map) if every element of $A$ is related to exactly one element of $B$. We write $f:A\to B$ and $f(a)=b$ when $(a,b)\in f$; $b$ is the image of $a$, and $a$ is a pre-image of $b$.

$A$ is the domain of $f$, $B$ is its codomain, and the set of all images, $f(A)=\{f(a): a\in A\}\subseteq B$, is its range.

In an arrow diagram, a relation from $A$ to $B$ is a function when exactly one arrow leaves every element of $A$. Nothing is demanded of $B$: an element of $B$ may receive many arrows or none. On a graph in the plane, a curve is the graph of a function of $x$ exactly when every vertical line meets it at most once (the vertical line test) — the circle $x^2+y^2=1$ fails it, the parabola $y=x^2$ passes.

A real function has its domain and codomain inside $\mathbb{R}$. When only a formula is given, the domain is understood to be the largest set of real $x$ for which the formula gives a real number: avoid division by zero and even roots of negative numbers. (Logarithms, with their condition "argument $\gt0$", and the trigonometric functions join the list in Chapters 7 and 14.)

📘 Definition 1.11 — Equal functions

Functions $f$ and $g$ are equal if they have the same domain, the same codomain, and $f(x)=g(x)$ for every $x$ in the domain. For example $f(x)=\dfrac{x^2-1}{x-1}$ and $g(x)=x+1$ are not equal: $f$ is not defined at $x=1$.

📐 Theorem 1.7 — Counting functions

If $n(A)=m$ and $n(B)=n$ (both finite, $m\ge1$), the number of functions from $A$ to $B$ is $n^m$.

Proof. A function is fixed by choosing an image for each of the $m$ elements of $A$, and each choice can be any of the $n$ elements of $B$, independently of the others: $n\times n\times\dots\times n=n^m$. $\blacksquare$ Compare with the $2^{mn}$ relations of Theorem 1.4: functions are a small part of all relations. For $m=n=3$ there are $27$ functions among $512$ relations — about $5\%$.

✏️ Example 1 — Which relations are functions?
Let $A=\{1,2,3,4\}$ and $B=\{a,b,c\}$. (a) Which of these are functions from $A$ to $B$? $\ f_1=\{(1,a),(2,b),(3,a),(4,c)\}$, $\ f_2=\{(1,a),(2,b),(3,c)\}$, $\ f_3=\{(1,a),(1,b),(2,c),(3,a),(4,b)\}$. Give the range of each function. (b) On $\mathbb{R}$, is $\{(x,y): y^2=x\}$ a function of $x$? Is $\{(x,y): y=x^2\}$? (c) How many functions are there from $A$ to $B$, and how many of them send $1$ to $a$?
(a) $f_1$ is a function: each of $1,2,3,4$ has exactly one image; its range is $\{a,b,c\}$ (it does not matter that $a$ is used twice). $f_2$ is not: $4$ has no image. $f_3$ is not: $1$ has two images.
(b) $y^2=x$ is not a function of $x$: $x=4$ gives $y=2$ and $y=-2$ (and $x\lt0$ gives no $y$ at all). $y=x^2$ is a function from $\mathbb{R}$ to $\mathbb{R}$ with range $[0,\infty)$.
(c) Theorem 1.7: $3^4=81$ functions. With $f(1)=a$ fixed, the other three elements are free: $3^3=27$.
Check $27$ is one third of $81$, as it should be: $f(1)$ is equally likely to be $a$, $b$ or $c$.
✏️ Example 2 — Domains and ranges of real functions
Find the domain and range of (a) $f(x)=\sqrt{(x-1)(5-x)}$, (b) $g(x)=\dfrac{1}{x^2-4}$, (c) $h(x)=\dfrac{x}{1+x^2}$.
What is the largest value of $h(x)=\dfrac{x}{1+x^2}$?
(a) domain Need $(x-1)(5-x)\ge0$, i.e. $1\le x\le5$: domain $[1,5]$.
(a) range Complete the square: $(x-1)(5-x)=-x^2+6x-5=4-(x-3)^2$, which runs over $[0,4]$ as $x$ runs over $[1,5]$ (largest at $x=3$, zero at the ends). So $f$ takes every value in $[0,2]$: range $[0,2]$.
(b) Domain $\mathbb{R}-\{-2,2\}$. Put $t=x^2-4$; then $t$ takes every value in $[-4,\infty)$ except $0$. For $-4\le t\lt0$, $\tfrac1t\le-\tfrac14$; for $t\gt0$, $\tfrac1t\gt0$. Range: $\left(-\infty,-\tfrac14\right]\cup(0,\infty)$. (The value $-\tfrac14$ is reached at $x=0$; no value in $\left(-\tfrac14,0\right]$ is reached.)
(c) Domain $\mathbb{R}$. A number $y$ is in the range when $y=\dfrac{x}{1+x^2}$ has a real solution $x$, i.e. $yx^2-x+y=0$. For $y=0$, $x=0$ works. For $y\ne0$ this quadratic has a real root iff its discriminant $1-4y^2\ge0$, i.e. $-\tfrac12\le y\le\tfrac12$. Range: $\left[-\tfrac12,\tfrac12\right]$, with $h(1)=\tfrac12$ and $h(-1)=-\tfrac12$.
⏱ Shortcut The "discriminant method" in (c) works for any $y=\dfrac{\text{quadratic}}{\text{quadratic}}$ defined on all of $\mathbb{R}$: it turns a range question into an inequality in $y$. Always check the special value that makes the $x^2$ coefficient zero separately.

Which of the following defines a function from $\mathbb{R}$ to $\mathbb{R}$?

One-one, Many-one, Onto and Into Functions

The definition of a function makes a demand on the domain only. The two classifications below look at the codomain: does any element of $B$ receive two arrows, and does any receive none?

📘 Definition 1.12 — One-one and many-one functions

$f:A\to B$ is one-one (injective) if different elements have different images:

$$f(x_1)=f(x_2)\ \Rightarrow\ x_1=x_2\qquad\text{for all } x_1,x_2\in A.$$

Otherwise — if some two different elements share an image — $f$ is many-one.

📘 Definition 1.13 — Onto, into and bijective functions

$f:A\to B$ is onto (surjective) if its range is the whole codomain: for every $b\in B$ there is some $a\in A$ with $f(a)=b$. Otherwise — if the range is a proper subset of $B$ — $f$ is into. A function that is both one-one and onto is a bijection (one-one correspondence).

Figure 1.1 — The four combinations. A shared image (red) makes a function many-one; an element of $B$ with no arrow (dashed) makes it into.

Whether a function is onto depends on the codomain we name, not just on the formula: $x\mapsto x^2$ is not onto as a map $\mathbb{R}\to\mathbb{R}$ (no $x$ has $x^2=-1$) but is onto as a map $\mathbb{R}\to[0,\infty)$. Likewise whether it is one-one depends on the domain: $x\mapsto x^2$ is many-one on $\mathbb{R}$ but one-one on $[0,\infty)$.

🧭 Problem-solving strategy — testing one-one and onto
  1. One-one, algebraically: assume $f(x_1)=f(x_2)$ and deduce $x_1=x_2$. Many-one: one pair $x_1\ne x_2$ with $f(x_1)=f(x_2)$ is enough (even functions on a symmetric domain are many-one: $f(-1)=f(1)$).
  2. One-one, by graph: every horizontal line meets the graph at most once (the horizontal line test). A function that is strictly increasing or strictly decreasing on its domain is one-one.
  3. Onto: take a general $y$ in the codomain, solve $f(x)=y$ for $x$, and check that a solution exists and lies in the domain for every such $y$. Equivalently, find the range and compare it with the codomain.
📐 Theorem 1.8 — Functions between finite sets

Let $A$ and $B$ be finite and $f:A\to B$.

  1. If $f$ is one-one, then $n(A)\le n(B)$. If $f$ is onto, then $n(A)\ge n(B)$.
  2. If $n(A)=n(B)$, then $f$ is one-one if and only if $f$ is onto.

Proof. (1) If $f$ is one-one, the $n(A)$ images are all different, so the range has exactly $n(A)$ elements; it sits inside $B$, so $n(A)\le n(B)$. If $f$ is onto, every element of $B$ has at least one pre-image, and different elements of $B$ have different pre-images, so $A$ has at least $n(B)$ elements. (2) If $f$ is one-one, its range is a subset of $B$ with $n(A)=n(B)$ elements, so it is all of $B$. If $f$ is onto but not one-one, two elements share an image and the range has at most $n(A)-1\lt n(B)$ elements — a contradiction. $\blacksquare$ Part (1) is the pigeonhole principle: put $5$ letters in $4$ pigeonholes and some pigeonhole gets two. Part (2) is false for infinite sets: $f:\mathbb{N}\to\mathbb{N}$, $f(n)=2n$ is one-one but not onto (no odd number is an image).

✏️ Example 3 — Classifying real functions
Classify each function as one-one or many-one and as onto or into. (a) $f:\mathbb{R}\to\mathbb{R}$, $f(x)=3x-5$. (b) $f:\mathbb{R}\to\mathbb{R}$, $f(x)=x^2$, and the same rule as a map $[0,\infty)\to[0,\infty)$. (c) $f:\mathbb{R}\to\mathbb{R}$, $f(x)=x^3+x$. (d) $h:\mathbb{R}\to\mathbb{R}$, $h(x)=\dfrac{x}{1+x^2}$ (Example 2).
(a) $3x_1-5=3x_2-5\Rightarrow x_1=x_2$: one-one. For any real $y$, $x=\dfrac{y+5}{3}$ is real and $f(x)=y$: onto. A bijection.
(b) On $\mathbb{R}$: $f(-2)=f(2)=4$, many-one; $-1$ has no pre-image, into. On $[0,\infty)\to[0,\infty)$: $x_1^2=x_2^2$ with $x_1,x_2\ge0$ forces $x_1=x_2$, and each $y\ge0$ has the pre-image $\sqrt y$ — a bijection. Same rule, different sets, different answers.
(c) If $x_1\lt x_2$ then $x_1^3\lt x_2^3$, so $x_1^3+x_1\lt x_2^3+x_2$: $f$ is strictly increasing, hence one-one. It is onto: $f(x)$ becomes arbitrarily large and arbitrarily negative and its graph has no breaks, so it passes every height $y$ (Chapter 7 makes "no breaks" precise — continuity). A bijection.
(d) $h(2)=\tfrac25=h\!\left(\tfrac12\right)$: many-one. Range $\left[-\tfrac12,\tfrac12\right]\ne\mathbb{R}$: into.
Check In (d), $h(x)=h\!\left(\tfrac1x\right)$ for every $x\ne0$: the pairs $x$, $\tfrac1x$ always share an image, which is why a horizontal line at height $0.4$ meets the graph twice.

For finite sets we can count each kind of function. The count of onto functions uses inclusion–exclusion from Section 1.1.

📐 Theorem 1.9 — Counting one-one and onto functions

Let $n(A)=m$ and $n(B)=n$.

  1. The number of one-one functions $A\to B$ is $n(n-1)(n-2)\cdots(n-m+1)$ ($m$ factors) if $m\le n$, and $0$ if $m\gt n$.
  2. If $m=n$, the number of bijections is $n!=n(n-1)\cdots2\cdot1$.
  3. The number of onto functions $A\to B$ is $2^m-2$ when $n=2$, and $3^m-3\cdot2^m+3$ when $n=3$.

Proof. (1) Choose images for the elements of $A$ one at a time: the first in $n$ ways, the second must differ from it ($n-1$ ways), the third from both ($n-2$ ways), and so on. (2) is (1) with $m=n$. (3) Let $B=\{p,q,r\}$ and let $M_p$ be the set of functions $A\to B$ whose range misses $p$ — functions into $\{q,r\}$, so $n(M_p)=2^m$; similarly for $M_q$, $M_r$. A function in $M_p\cap M_q$ sends everything to $r$: $n(M_p\cap M_q)=1$; and $M_p\cap M_q\cap M_r=\phi$. The functions that are not onto form $M_p\cup M_q\cup M_r$, which by Theorem 1.3 has $3\cdot2^m-3\cdot1+0$ elements. Subtract from all $3^m$ functions. The case $n=2$ is the same argument with $2^m-1-1$. $\blacksquare$ (In general the number of onto functions is $\sum_{k=0}^{n}(-1)^k\binom nk(n-k)^m$, with the binomial coefficients of Chapter 4.)

✏️ Example 4 — Counting functions between small sets
Let $A=\{1,2,3,4\}$ and $B=\{x,y,z\}$. Find the number of (a) functions $A\to B$; (b) one-one functions $A\to B$; (c) onto functions $A\to B$; (d) one-one functions $B\to A$; (e) bijections $f:A\to A$ with $f(1)\ne1$.
Find (c), the number of onto functions from $A$ to $B$:
(a), (b) $3^4=81$ functions. One-one: $0$ — four elements cannot have four different images in a three-element set (pigeonhole).
(c) $3^4-3\cdot2^4+3=81-48+3=36$.
(d) $x$, $y$, $z$ choose distinct images in turn: $4\cdot3\cdot2=24$.
(e) All bijections: $4!=24$. Those with $f(1)=1$ are bijections of $\{2,3,4\}$: $3!=6$. Answer $24-6=18$.
Check (c) directly: an onto map from $4$ elements to $3$ uses one image twice. Choose which image is doubled ($3$ ways) and which two elements share it ($6$ ways), then match the other two elements with the other two images ($2$ ways): $3\cdot6\cdot2=36$ ✓.

Set $n(A)=3$ and $n(B)=4$. Which kind of function will the lab never be able to show you, however long it runs?

Set $n(A)=3$, $n(B)=4$. The counts read $64$ functions in all, $24$ one-one and $0$ onto (choose "onto only" and the lab says that none exist). Three arrows can reach at most three of the four elements of $B$, so some element of $B$ is always left without an arrow — every function here is into (Theorem 1.8(1)). One-one functions exist ($4\cdot3\cdot2=24$), and so do many-one ones ($64-24=40$).
Interactive 1 — Arrow-Diagram Lab: One-one, Onto, and How Many

Each element of $A$ sends exactly one arrow into $B$. Arrows that land on a shared image are red (many-one); elements of $B$ that receive no arrow are dashed (into). Choose the sizes of $A$ and $B$ and a kind of function; Play draws a fresh random function of that kind every two seconds, and the readouts count all such functions (Theorems 1.7 and 1.9). Click an element of $A$ to move its arrow yourself.

43
range—
this function is—
functions $A\to B$: $n^m$—
one-one · onto · bijective—

A function $f:\{1,2,3,4,5\}\to\{1,2,3,4,5\}$ is known to be one-one. Then $f$

Composition of Functions

📘 Definition 1.14 — Composite function

Let $f:A\to B$ and $g:B\to C$. The composite $g\circ f:A\to C$ is defined by

$$(g\circ f)(x)=g\big(f(x)\big)\qquad(x\in A).$$

Read it from the right: first apply $f$, then apply $g$. For real functions given by formulas, $g\circ f$ is defined at $x$ exactly when $x$ is in the domain of $f$ and $f(x)$ is in the domain of $g$:

$$\operatorname{dom}(g\circ f)=\{x\in\operatorname{dom}f:\ f(x)\in\operatorname{dom}g\}.$$

With $f(x)=2x-1$ and $g(x)=x^2$: $(g\circ f)(x)=(2x-1)^2$, but $(f\circ g)(x)=2x^2-1$. At $x=2$ these are $9$ and $7$. So, unlike multiplication of numbers, composition is not commutative: the order of the machines matters. It does, however, have the other good properties of a product.

📐 Theorem 1.10 — Properties of composition

Let $f:A\to B$, $g:B\to C$ and $h:C\to D$, and let $I_A(x)=x$ be the identity function on $A$.

  1. Associative: $h\circ(g\circ f)=(h\circ g)\circ f$.
  2. Identity: $f\circ I_A=f$ and $I_B\circ f=f$.
  3. If $f$ and $g$ are one-one, so is $g\circ f$. If $f$ and $g$ are onto, so is $g\circ f$. Hence a composite of bijections is a bijection.
  4. If $g\circ f$ is one-one, then $f$ is one-one. If $g\circ f$ is onto, then $g$ is onto.

Proof. (1) Both sides send $x$ to $h(g(f(x)))$. (2) $f(I_A(x))=f(x)$ and $I_B(f(x))=f(x)$. (3) If $g(f(x_1))=g(f(x_2))$ then $f(x_1)=f(x_2)$ because $g$ is one-one, and then $x_1=x_2$ because $f$ is one-one. For onto: given $c\in C$, pick $b$ with $g(b)=c$ ($g$ onto), then $a$ with $f(a)=b$ ($f$ onto); then $(g\circ f)(a)=c$. (4) If $f(x_1)=f(x_2)$ then certainly $g(f(x_1))=g(f(x_2))$, so $x_1=x_2$. And every $c\in C$ equals $g(f(a))$ for some $a$, so $c$ is the image under $g$ of $f(a)\in B$. $\blacksquare$

Part (4) is a JEE favourite because its converse is false: $g\circ f$ can be one-one while $g$ is not. Take $f:[0,\infty)\to\mathbb{R}$, $f(x)=\sqrt x$ and $g:\mathbb{R}\to\mathbb{R}$, $g(x)=x^2$; then $(g\circ f)(x)=x$ is one-one on $[0,\infty)$, but $g$ is many-one. A bijection $f:A\to B$ has an inverse $f^{-1}:B\to A$ with $f^{-1}\circ f=I_A$ and $f\circ f^{-1}=I_B$; inverse functions are developed in Section 7.1.

✏️ Example 5 — Composites and their domains
Let $f(x)=x^2+1$ and $g(x)=\sqrt{x-2}$, each with its largest real domain. Find $g\circ f$ and $f\circ g$ with their domains, and $f\circ f$. Is $f\circ g$ the same function as $x\mapsto x-1$?
$g\circ f$ $(g\circ f)(x)=\sqrt{(x^2+1)-2}=\sqrt{x^2-1}$. Domain: $x\in\mathbb{R}$ with $f(x)=x^2+1\ge2$, i.e. $|x|\ge1$: $(-\infty,-1]\cup[1,\infty)$.
$f\circ g$ $(f\circ g)(x)=\left(\sqrt{x-2}\right)^2+1=x-1$, but only for $x$ in the domain of $g$: $x\ge2$. Its range is $[1,\infty)$.
$f\circ f$ $(f\circ f)(x)=(x^2+1)^2+1=x^4+2x^2+2$, domain $\mathbb{R}$.
Answer No: $f\circ g$ agrees with $x-1$ only on $[2,\infty)$. Simplifying the formula does not enlarge the domain — $(f\circ g)(0)$ is undefined, although $0-1=-1$.

Take $f(x)=2x-1$ and $g(x)=x^2$, and put $x_0=2$. Predict the two composite values.

Choose $f=2x-1$, $g=x^2$, the order $g\circ f$, and set $x_0=2$. The machine shows $2\to f\to3\to g\to9$, so $(g\circ f)(2)=9$, and the readout gives $(f\circ g)(2)=f(4)=7$. Switching the order to $f\circ g$ redraws the machine as $2\to g\to4\to f\to7$ and changes the graph from the parabola $(2x-1)^2$ (vertex at $x=\tfrac12$) to $2x^2-1$. The first machine applied is the one written on the right.
Interactive 2 — Composition Machine and the Horizontal Line Test

Choose two functions and an order. The strip at the top feeds $x_0$ through the two machines; the graph shows the composite $h$ on $-4\le x\le4$. The blue horizontal line $y=c$ is the horizontal line test: the readout counts how many $x$ solve $h(x)=c$. Two or more solutions mean $h$ is many-one; none means $c$ is not a value of $h$ on this window. Play sweeps $x_0$ and $c$; dragging a slider stops the sweep.

24
$f(x_0)$, $g(x_0)$—
$(g\circ f)(x_0)$—
$(f\circ g)(x_0)$—
solutions of $h(x)=c$—
✏️ Example 6 — Hard example: a function that repeats after four steps
Let $f(x)=\dfrac{x-1}{x+1}$. Write $f^{(n)}$ for $f\circ f\circ\dots\circ f$ ($n$ times). Find $f^{(2)}$, $f^{(3)}$ and $f^{(4)}$, and hence $f^{(2027)}(3)$. For which $x$ are these formulas valid?
Find $f^{(2027)}(3)$ before you open the solution:
$f^{(2)}$ $f\big(f(x)\big)=\dfrac{\frac{x-1}{x+1}-1}{\frac{x-1}{x+1}+1}=\dfrac{(x-1)-(x+1)}{(x-1)+(x+1)}=\dfrac{-2}{2x}=-\dfrac1x$.
$f^{(3)}$, $f^{(4)}$ $f^{(3)}(x)=f\!\left(-\dfrac1x\right)=\dfrac{-\frac1x-1}{-\frac1x+1}=\dfrac{-1-x}{-1+x}=\dfrac{1+x}{1-x}$, and $f^{(4)}=f^{(2)}\circ f^{(2)}$: $x\mapsto-\dfrac{1}{-1/x}=x$. So $f^{(4)}$ is the identity (Theorem 1.10(1) lets us group the four $f$'s in pairs).
Reduce $2027=4\times506+3$, so $f^{(2027)}=\big(f^{(4)}\big)^{506}\circ f^{(3)}=f^{(3)}$, and $f^{(2027)}(3)=\dfrac{1+3}{1-3}=-2$.
Domain $f$ needs $x\ne-1$; $f^{(2)}$ also needs $f(x)\ne-1$, i.e. $x\ne0$; $f^{(3)}$ also needs $x\ne1$. So the cycle works for $x\notin\{-1,0,1\}$. ($x=3$ is fine: $3\to\tfrac12\to-\tfrac13\to-2\to3$.)
⏱ Shortcut Compute the orbit of the given number instead of the formulas: $3\to\tfrac12\to-\tfrac13\to-2\to3$ repeats every $4$ steps, and the $3$rd entry is $-2$.
⚠️ JEE Main traps

1. Onto depends on the codomain. "Is $f(x)=x^2$ onto?" has no answer until the codomain is named: onto $[0,\infty)$, into $\mathbb{R}$. Read the arrow $f:A\to B$ in the question carefully.

2. The order of composition. $(g\circ f)(x)=g(f(x))$: $f$ acts first. Most wrong options in composition MCQs are the other order.

3. Simplified formulas hide domains. $\left(\sqrt{x-2}\right)^2+1=x-1$ only for $x\ge2$; $\dfrac{x^2-1}{x-1}=x+1$ only for $x\ne1$. Find the domain before simplifying.

4. Counting slips. Functions from an $m$-set to an $n$-set: $n^m$ (images to the power of elements), not $m^n$. One-one needs $m\le n$; onto needs $m\ge n$. For onto maps to a $3$-set the "$+3$" in $3^m-3\cdot2^m+3$ is often forgotten.

5. One example proves "many-one", never "one-one". $f(1)\ne f(2)$ shows nothing about one-one; you must argue for all pairs (or use monotonicity). But a single pair $x_1\ne x_2$ with $f(x_1)=f(x_2)$ settles "many-one".

Let $f:A\to B$ and $g:B\to C$ be functions such that $g\circ f$ is onto. Which statement must be true?

Exercises

Real functions have their largest real domain unless a domain is stated. Justify "one-one" and "onto" by an argument for all elements; disprove them with one example.

I
Functions, domains and ranges.
  • 1 Which of these relations from $\{1,2,3\}$ to $\{4,5,6\}$ are functions? $R_1=\{(1,4),(2,5),(3,4)\}$, $R_2=\{(1,4),(2,6)\}$, $R_3=\{(1,5),(2,5),(3,5)\}$, $R_4=\{(1,4),(1,6),(2,5),(3,6)\}$.
  • 2 Find the range of each function in part 1.
  • 3 How many functions are there from $\{a,b,c,d,e\}$ to $\{0,1\}$?
  • 4 Find the domain and range of $f(x)=\sqrt{9-x^2}$.
  • 5 Find the domain of $f(x)=\dfrac{1}{\sqrt{x^2-5x+6}}$.
  • 6 Find the domain of $f(x)=\sqrt{x-1}+\sqrt{4-x}$ and its greatest value.
  • 7 Find the range of $f(x)=\dfrac{x^2+2}{x^2+1}$.
  • 8 Find the range of $f(x)=\dfrac{x-1}{x^2+3}$.
  • 9 Are $f(x)=x$ and $g(x)=\sqrt{x^2}$ equal functions on $\mathbb{R}$? Are $f(x)=\dfrac{x^2-1}{x-1}$ and $g(x)=x+1$ equal?
1 $R_1$ and $R_3$ are functions. $R_2$ gives $3$ no image; $R_4$ gives $1$ two images.
2 Range of $R_1$: $\{4,5\}$; range of $R_3$: $\{5\}$ (a constant function).
3 $2^5=32$.
4 $9-x^2\ge0$: domain $[-3,3]$; $9-x^2$ runs over $[0,9]$, so the range is $[0,3]$.
5 Need $x^2-5x+6=(x-2)(x-3)\gt0$ (strictly, as it is under a root in a denominator): $x\lt2$ or $x\gt3$, i.e. $(-\infty,2)\cup(3,\infty)$.
6 Domain $[1,4]$. $f^2=3+2\sqrt{(x-1)(4-x)}$ and $(x-1)(4-x)=\tfrac94-\left(x-\tfrac52\right)^2\in\left[0,\tfrac94\right]$, so $f^2\in[3,6]$: greatest value $\sqrt6\approx2.449$ at $x=\tfrac52$ (least $\sqrt3$ at the ends).
7 $f(x)=1+\dfrac{1}{x^2+1}$, and $\dfrac1{x^2+1}\in(0,1]$: range $(1,2]$.
8 $y(x^2+3)=x-1\iff yx^2-x+(3y+1)=0$. For $y\ne0$, real $x$ needs $1-4y(3y+1)\ge0$, i.e. $12y^2+4y-1\le0$, $(6y-1)(2y+1)\le0$: $-\tfrac12\le y\le\tfrac16$ ($y=0$ at $x=1$ is inside). Range $\left[-\tfrac12,\tfrac16\right]$, reached at $x=-1$ and $x=3$.
9 No: $\sqrt{x^2}=|x|$, which differs from $x$ for $x\lt0$. No: $\dfrac{x^2-1}{x-1}$ is undefined at $x=1$, so the domains differ.
II
One-one and onto. Classify each function, with reasons, and answer the numerical question.
  • 1 $f:\mathbb{R}\to\mathbb{R}$, $f(x)=5-2x$.
  • 2 $f:\mathbb{R}\to\mathbb{R}$, $f(x)=x^2+2x$. What is the least value of $f$?
  • 3 $f:\mathbb{R}\to\mathbb{R}$, $f(x)=x|x|$.
  • 4 $f:[0,\infty)\to\mathbb{R}$, $f(x)=\sqrt x$.
  • 5 $f:\mathbb{R}-\{2\}\to\mathbb{R}-\{1\}$, $f(x)=\dfrac{x-1}{x-2}$. Find the $x$ with $f(x)=3$.
  • 6 $f:\mathbb{N}\to\mathbb{N}$, $f(n)=n+1$ if $n$ is odd and $f(n)=n-1$ if $n$ is even.
  • 7 $f:\mathbb{Z}\to\mathbb{Z}$, $f(n)=3n+1$. Find the pre-image of $100$. Does $101$ have one?
  • 8 $f:\mathbb{R}\to\mathbb{R}$, $f(x)=x^3-3x$. How many real $x$ satisfy $f(x)=0$?
  • 9 Give an example of a function $\mathbb{N}\to\mathbb{N}$ that is onto but not one-one.
1 Bijection: $5-2x_1=5-2x_2\Rightarrow x_1=x_2$, and $x=\dfrac{5-y}{2}$ is a pre-image of any $y$.
2 $f(x)=(x+1)^2-1$: least value $-1$ (at $x=-1$), so values below $-1$ are missed — into; $f(0)=f(-2)=0$ — many-one.
3 $f(x)=x^2$ for $x\ge0$ and $-x^2$ for $x\lt0$: strictly increasing, so one-one; every $y\ge0$ is $f(\sqrt y)$ and every $y\lt0$ is $f(-\sqrt{-y})$, so onto. Bijection.
4 One-one ($\sqrt{x_1}=\sqrt{x_2}\Rightarrow x_1=x_2$); into (no negative values).
5 $f(x)=1+\dfrac{1}{x-2}$. One-one: $\dfrac1{x_1-2}=\dfrac1{x_2-2}\Rightarrow x_1=x_2$. Onto $\mathbb{R}-\{1\}$: for $y\ne1$, $x=2+\dfrac{1}{y-1}\ne2$ works. Bijection; $f(x)=3$ at $x=2+\tfrac12=2.5$.
6 $f$ swaps $1\leftrightarrow2$, $3\leftrightarrow4$, …, so $f(f(n))=n$ for all $n$. Then $f$ is one-one ($f(n_1)=f(n_2)\Rightarrow n_1=n_2$ on applying $f$) and onto ($m=f(f(m))$). Bijection.
7 One-one (linear); into: $3n+1=100$ gives $n=33$, but $3n+1=101$ gives $n=\tfrac{100}{3}\notin\mathbb{Z}$.
8 $x(x^2-3)=0$: $x=0,\pm\sqrt3$ — $3$ solutions, so $f$ is many-one. It is onto (an odd-degree polynomial takes all real values, as in Example 3(c)).
9 $f(1)=1$ and $f(n)=n-1$ for $n\ge2$: every $m$ equals $f(m+1)$ (onto), but $f(1)=f(2)=1$ (many-one).
III
Counting functions.
  • 1 $A=\{1,2,3\}$, $B=\{a,b,c,d\}$: how many functions $A\to B$?
  • 2 How many one-one functions $A\to B$ (sets of part 1)?
  • 3 How many onto functions $B\to A$?
  • 4 How many onto functions are there from $\{1,2,3,4,5\}$ to $\{p,q\}$?
  • 5 How many bijections of $\{1,2,3,4,5\}$ onto itself are there, and how many of them satisfy $f(1)=1$?
  • 6 How many functions $f:\{1,2,3,4\}\to\{1,2,3,4\}$ satisfy $f(1)=f(2)$?
  • 7 How many onto functions are there from a $5$-element set to a $3$-element set?
  • 8 How many many-one functions are there from $\{1,2,3\}$ to itself?
1 $4^3=64$.
2 $4\cdot3\cdot2=24$.
3 From a $4$-set onto a $3$-set: $3^4-3\cdot2^4+3=36$.
4 $2^5-2=30$ (all functions except the two constant ones).
5 $5!=120$; with $f(1)=1$, the rest is a bijection of a $4$-set: $4!=24$.
6 Choose the common value of $f(1)=f(2)$ ($4$ ways), then $f(3)$ and $f(4)$ ($4$ ways each): $4^3=64$.
7 $3^5-3\cdot2^5+3=243-96+3=150$.
8 All $3^3=27$ minus the one-one ones $3!=6$: $21$.
IV
Composition.
  • 1 $f(x)=2x+3$, $g(x)=x^2$. Find $(g\circ f)(x)$ and $(f\circ g)(x)$, and the value of $(g\circ f)(1)$.
  • 2 $f(x)=3x-1$. Find $(f\circ f)(x)$ and $(f\circ f\circ f)(1)$.
  • 3 $f(x)=\dfrac{1}{1-x}$ ($x\ne0,1$). Show that $(f\circ f)(x)=\dfrac{x-1}{x}$ and $(f\circ f\circ f)(x)=x$. Find $f(f(f(7)))$.
  • 4 $f(x)=\sqrt x$, $g(x)=x^2-4$. Find the domains of $f\circ g$ and $g\circ f$.
  • 5 $f(x)=x+1$ for $x\le1$ and $f(x)=2x$ for $x\gt1$; $g(x)=x^2$. Find $(f\circ g)(-2)$ and $(g\circ f)(-2)$.
  • 6 $f(x)=ax+b$ with $a\gt0$ satisfies $f(f(x))=4x+9$ for all $x$. Find $a+b$.
  • 7 Prove that if $g\circ f$ is one-one then $f$ is one-one, and give an example in which $g\circ f$ is one-one but $g$ is not.
  • 8 (Modelling) An oil slick is circular with radius $r=f(t)=3t$ metres after $t$ minutes, and the area of a circle of radius $r$ is $g(r)=\pi r^2$. Express the area as a composite function of $t$ and find it at $t=4$ minutes (in $\text{m}^2$, to one decimal place).
1 $(g\circ f)(x)=(2x+3)^2$, $(f\circ g)(x)=2x^2+3$; $(g\circ f)(1)=25$ (while $(f\circ g)(1)=5$).
2 $(f\circ f)(x)=3(3x-1)-1=9x-4$; $f(1)=2$, $f(2)=5$, $f(5)=14$.
3 $f(f(x))=\dfrac{1}{1-\frac1{1-x}}=\dfrac{1-x}{-x}=\dfrac{x-1}{x}$; $f\!\left(\dfrac{x-1}{x}\right)=\dfrac{1}{1-\frac{x-1}{x}}=\dfrac{x}{1}=x$. So $f(f(f(7)))=7$.
4 $f\circ g=\sqrt{x^2-4}$ needs $x^2\ge4$: $(-\infty,-2]\cup[2,\infty)$. $g\circ f=(\sqrt x)^2-4=x-4$ needs $x\ge0$: $[0,\infty)$.
5 $g(-2)=4\gt1$, so $(f\circ g)(-2)=f(4)=8$; $f(-2)=-1$, so $(g\circ f)(-2)=1$.
6 $f(f(x))=a(ax+b)+b=a^2x+(a+1)b$. So $a^2=4$, $a=2$ (as $a\gt0$), and $3b=9$, $b=3$: $a+b=5$.
7 If $f(x_1)=f(x_2)$ then $g(f(x_1))=g(f(x_2))$, so $x_1=x_2$ as $g\circ f$ is one-one. Example: $f:[0,\infty)\to\mathbb{R}$, $f(x)=\sqrt x$, $g(x)=x^2$ on $\mathbb{R}$: $g\circ f$ is the identity on $[0,\infty)$, but $g(-1)=g(1)$.
8 $A(t)=(g\circ f)(t)=\pi(3t)^2=9\pi t^2$; $A(4)=144\pi\approx452.4\ \text{m}^2$.
🎯 Exam corner JEE Main · MCQJEE Main · Numerical

E1. JEE Main · MCQ Which of the following functions $f:\mathbb{R}\to\mathbb{R}$ is one-one but not onto? (A) $f(x)=x^3-x$ (B) $f(x)=2x+|x|$ (C) $f(x)=x^2+1$ (D) $f(x)=\dfrac{x}{1+|x|}$

(A), (C) $x^3-x$ vanishes at $0,\pm1$: many-one. $x^2+1$ is even: many-one.
(B) $2x+|x|$ is $3x$ for $x\ge0$ and $x$ for $x\lt0$: strictly increasing and taking every real value — a bijection, so it is onto.
(D) For $x\ge0$, $\dfrac{x}{1+x}=1-\dfrac{1}{1+x}$ increases from $0$ towards $1$; for $x\lt0$, $\dfrac{x}{1-x}$ increases from near $-1$ to $0$. So $f$ is strictly increasing (one-one) with range $(-1,1)\ne\mathbb{R}$ (into).
Answer (D).
⏱ Shortcut A bounded function on $\mathbb{R}$ can never be onto $\mathbb{R}$: $\left|\dfrac{x}{1+|x|}\right|\lt1$ shows (D) is into at a glance.

E2. JEE Main · Numerical Find the number of onto functions $f:\{1,2,3,4,5\}\to\{a,b,c\}$ with $f(1)=a$. Give the answer to the nearest integer.

Reduce $a$ is already hit. The function is onto exactly when $2,3,4,5$ (mapped freely into $\{a,b,c\}$) hit both $b$ and $c$.
Inclusion–exclusion All maps of $\{2,3,4,5\}$: $3^4=81$; missing $b$: $2^4=16$; missing $c$: $16$; missing both: $1$. So $81-16-16+1=50$.
Answer $50$.
⏱ Shortcut By symmetry, one third of the $150$ onto functions (Exercise III.7) have $f(1)=a$: $150/3=50$.

E3. JEE Main · MCQ A function $f$ satisfies $3f(x)-f\!\left(\dfrac1x\right)=8x$ for all $x\ne0$. Then $f(2)$ equals (A) $6$ (B) $\dfrac{13}{2}$ (C) $7$ (D) $\dfrac{25}{4}$

Second equation Replace $x$ by $\tfrac1x$: $3f\!\left(\tfrac1x\right)-f(x)=\dfrac8x$.
Eliminate Three times the given equation plus this one: $9f(x)-f(x)=24x+\dfrac8x$, so $f(x)=3x+\dfrac1x$.
Answer (B) $f(2)=6+\tfrac12=\tfrac{13}{2}$.
⏱ Shortcut Only $x=2$ and $x=\tfrac12$ matter: $3f(2)-f(\tfrac12)=16$ and $3f(\tfrac12)-f(2)=4$; then $8f(2)=48+4$. Check: $3\left(3x+\tfrac1x\right)-\left(\tfrac3x+x\right)=8x$ ✓.

E4. JEE Main · Numerical Let $f(x)=x^2-2x$ and $g(x)=2x+3$. Find the sum of the squares of all real $x$ for which $f(g(x))=g(f(x))$. Give the answer to the nearest integer.

Composites $f(g(x))=(2x+3)^2-2(2x+3)=4x^2+8x+3$; $\ g(f(x))=2(x^2-2x)+3=2x^2-4x+3$.
Solve $4x^2+8x+3=2x^2-4x+3\iff2x^2+12x=0\iff x=0$ or $x=-6$.
Answer $0^2+(-6)^2=36$.

E5. JEE Main · MCQ Let $f:A\to B$ and $g:B\to C$ be functions such that $g\circ f:A\to C$ is a bijection. Then necessarily (A) $f$ and $g$ are both bijections (B) $f$ is onto and $g$ is one-one (C) $f$ is one-one and $g$ is onto (D) $g$ is one-one, and nothing can be said about $f$

Theorem 1.10(4) $g\circ f$ one-one $\Rightarrow$ $f$ one-one; $g\circ f$ onto $\Rightarrow$ $g$ onto.
Nothing more $A=C=\{1\}$, $B=\{1,2\}$, $f(1)=1$, $g\equiv1$: $g\circ f$ is a bijection, but $f$ is not onto and $g$ is not one-one — so (A), (B), (D) can fail.
Answer (C).
⏱ Shortcut "Inner one-one, outer onto." The inner function $f$ must keep inputs apart; the outer function $g$ must reach everything.

E6. JEE Main · Numerical Let $f(x)=\dfrac{2x+3}{x-2}$ for $x\ne2$. Writing $f^{(n)}$ for the $n$-fold composite $f\circ f\circ\dots\circ f$, find $f^{(2027)}(3)$. Give the answer to the nearest integer.

Compose once $f(f(x))=\dfrac{2\cdot\frac{2x+3}{x-2}+3}{\frac{2x+3}{x-2}-2}=\dfrac{(4x+6)+(3x-6)}{(2x+3)-(2x-4)}=\dfrac{7x}{7}=x$. So $f\circ f$ is the identity ($x\ne2$).
Odd power $2027$ is odd, so $f^{(2027)}=f$, and $f(3)=\dfrac{9}{1}=9$.
Answer $9$.
⏱ Shortcut $f(x)=\dfrac{ax+b}{cx-a}$ satisfies $f\circ f=I$ whenever $a^2+bc\ne0$ (here $a=2$, $b=3$, $c=1$): its graph is symmetric about $y=x$. Recognise the pattern and the composite is free.
🔬 Research–Teaching NexusResearch-tutored · optional, about 45 minutes

Research question. A computer stores records in $k$ "slots" chosen by a hash function $h$ from record numbers to slots. With more possible records than slots, $h$ cannot be one-one. How many records can be stored before two are likely to land in the same slot (a collision)?

Why it matters. Hash functions sit inside databases, compilers, password storage and the checksums that confirm a downloaded file is intact. Engineers choose the number of slots so that collisions stay rare; security researchers search for collisions to break weak hash functions. The underlying question is about many-one functions and the pigeonhole principle of Theorem 1.8.

What to do.

  1. Take $k=97$ slots and the hash $h(N)=N \bmod 97$ (the remainder when $N$ is divided by $97$). Generate $40$ random six-digit roll numbers (a spreadsheet's random-number function works).
  2. Insert them one by one and record when the first collision happens. Repeat the experiment about $30$ times and find the average number of records stored before the first collision.
  3. Theory: if each record lands in a random slot, the chance that the first $r$ records all differ is $\left(1-\tfrac1k\right)\left(1-\tfrac2k\right)\cdots\left(1-\tfrac{r-1}{k}\right)$. Compute it for $r=1,\dots,25$ and find the first $r$ at which a collision becomes more likely than not.
  4. Compare your experiment with the theory. Then use the roll numbers $970,1067,1164,\dots$ (steps of $97$): what happens, and why?

Tools: Spreadsheet (MOD and RAND functions) or a few lines of Python.

Hand in: Your table of first-collision positions, the theoretical curve, the value of $r$ where it passes $\tfrac12$, and two sentences on why a hash function is deliberately many-one.

Going further. The same calculation with $k=365$ is the "birthday problem": how many people are needed in a room for a shared birthday to be more likely than not? Why does the answer grow like $\sqrt k$ rather than like $k$?

Instructor note: for $k=97$ the probability of at least one collision first exceeds $\tfrac12$ at $r=12$ records (about $0.51$); the rough rule $r\approx1.18\sqrt k\approx11.6$ agrees. The arithmetic sequence of roll numbers all hash to slot $0$ — a vivid example of a structured input defeating a hash function that behaves well on random input.

🧪 Self-check quiz

0/5 correct

Q1. The number of functions from a set with $3$ elements to a set with $2$ elements is

Q2. The function $f:\mathbb{R}\to\mathbb{R}$, $f(x)=x^2$, is

Q3. If $f(x)=x+1$ and $g(x)=2x$, then $(f\circ g)(x)$ is

Q4. The number of bijections from $\{1,2,3,4\}$ to $\{a,b,c,d\}$ is

Q5. $f:\mathbb{R}-\{0\}\to\mathbb{R}$ is defined by $f(x)=x+\dfrac1x$. Then $f$ is