A function $f : A \to B$ is a special relation that assigns to every element of the domain $A$ exactly one element of the codomain $B$. Two demands must both hold: nothing in $A$ is left unmapped, and nothing in $A$ maps to two different outputs. In Class 12 we classify functions by how they fill the codomain.
One-one (injective) functions
$f$ is one-one (injective) if different inputs always give different outputs:
$$f(x_1)=f(x_2) \ \Rightarrow\ x_1=x_2 \qquad\text{equivalently}\qquad x_1 \ne x_2 \Rightarrow f(x_1)\ne f(x_2).$$
Graphically, a function of a real variable is one-one when no horizontal line meets its graph more than once (the horizontal-line test). A handy shortcut: a function that is strictly increasing or strictly decreasing on its whole domain is automatically one-one, because monotonicity rules out any repeat of a value. A function that is not one-one is called many-one.
How to disprove one-one: exhibit two distinct inputs with the same output. For $f(x)=x^2$ on $\mathbb{R}$, $f(-2)=f(2)=4$ settles it instantly.
Onto (surjective) functions
$f$ is onto (surjective) if every element of the codomain is actually hit — that is, the range equals the codomain:
$$\forall\, y \in B,\ \exists\, x \in A \text{ such that } f(x)=y, \qquad \text{i.e. } \operatorname{Range}(f) = B.$$
Onto-ness depends on the chosen codomain. The same formula can be onto or not depending on whether $B$ is $\mathbb{R}$, $[0,\infty)$, $\mathbb{N}$, and so on. So always read the codomain carefully. A function that is not onto is sometimes called into.
Bijective functions
$f$ is bijective if it is both one-one and onto. A bijection pairs up the two sets perfectly — each input has a unique output and each output has a unique pre-image. Only bijections are invertible (the subject of the next page).
Useful fact: when $A$ and $B$ are finite and of equal size, a function is one-one if and only if it is onto. This shortcut fails for infinite sets — for example $f:\mathbb{N}\to\mathbb{N},\ f(x)=2x$ is one-one but not onto.
How to prove it in an exam
- One-one: assume $f(x_1)=f(x_2)$ and algebraically force $x_1=x_2$.
- Onto: take an arbitrary $y\in B$, solve $f(x)=y$ for $x$, and check that this $x$ lies in $A$.
- To disprove: give one explicit counter-example.
Counting functions (finite sets)
For finite sets these counts come up repeatedly in MCQs. Suppose $|A|=m$ and $|B|=n$.
For example, the number of one-one maps from a $3$-element set to a $5$-element set is $\,{}^{5}P_{3}=5\times 4\times 3=60$, and the number of bijections between two $4$-element sets is $4!=24$.
Show that $f:\mathbb{R}\to\mathbb{R}$ defined by $f(x)=2x+3$ is bijective.
Solution
One-one: Suppose $f(x_1)=f(x_2)$. Then $2x_1+3 = 2x_2+3 \Rightarrow 2x_1=2x_2 \Rightarrow x_1=x_2$. So $f$ is one-one.
Onto: Take any $y\in\mathbb{R}$. Solve $2x+3=y \Rightarrow x=\dfrac{y-3}{2}$, which is a real number, so it lies in the domain $\mathbb{R}$ and $f(x)=y$. Hence $f$ is onto.
Answer: Being one-one and onto, $f$ is bijective.
Examine whether $f:\mathbb{R}\to\mathbb{R},\ f(x)=x^2$ is one-one and/or onto.
Solution
One-one? $f(-2)=4=f(2)$ but $-2\ne 2$, so $f$ is not one-one.
Onto? Outputs are squares, so $f(x)\ge 0$ always. A negative codomain value such as $y=-1$ has no pre-image. So $f$ is not onto.
Note: If we shrink both sides — restrict to $f:[0,\infty)\to[0,\infty)$ — then $f(x)=x^2$ becomes bijective. Domain and codomain are part of the function.
Answer: $f$ is neither one-one nor onto.
Let $f:\mathbb{N}\to\mathbb{N}$ be $f(x)=x^2$. Classify it.
Solution
One-one: For natural numbers, $x_1^2=x_2^2$ with $x_1,x_2>0$ forces $x_1=x_2$. So it is one-one.
Onto: The value $y=3\in\mathbb{N}$ is not a perfect square, so no natural $x$ gives $f(x)=3$. Not onto.
Answer: $f$ is one-one but not onto — a reminder that the finite "one-one $\Leftrightarrow$ onto" shortcut does not apply to infinite sets.
Show that $f:\mathbb{R}\to\mathbb{R},\ f(x)=x^3$ is bijective.
Solution
One-one: $x^3$ is strictly increasing on $\mathbb{R}$ (if $x_1
Onto: For any $y\in\mathbb{R}$, the real number $x=y^{1/3}$ satisfies $f(x)=y$. Onto.
Answer: Hence $f$ is bijective.
Show that $f:\mathbb{R}\to\mathbb{R},\ f(x)=|x|$ is neither one-one nor onto.
Solution
One-one? $f(-3)=3=f(3)$ but $-3\ne 3$, so two distinct inputs share an output. Not one-one.
Onto? Since $|x|\ge 0$ for all $x$, no negative number is an output. The codomain value $y=-2$ has no pre-image. Not onto.
Answer: $f(x)=|x|$ is neither one-one nor onto on $\mathbb{R}$ (it is many-one and into).
Let $A=\{1,2,3\}$ and $B=\{4,5\}$. Show that no function $f:A\to B$ can be one-one, and find how many onto functions exist.
Solution
One-one is impossible: $|A|=3 > 2=|B|$, so by the pigeonhole principle at least two of the three inputs must land on the same output. Hence no $f:A\to B$ is one-one.
Onto count: Total functions $A\to B$ are $2^3=8$. The non-onto ones send everything to a single element of $B$ — either all to $4$ or all to $5$ — that is $2$ functions. So onto functions $=8-2=6$.
Answer: No one-one function exists, and there are $\mathbf{6}$ onto functions from $A$ to $B$.
Show that $f:\mathbb{R}\setminus\{2\}\to\mathbb{R},\ f(x)=\dfrac{x-1}{x-2}$ is one-one. Is it onto $\mathbb{R}$?
Solution
One-one: Suppose $f(x_1)=f(x_2)$, i.e. $\dfrac{x_1-1}{x_1-2}=\dfrac{x_2-1}{x_2-2}$. Cross-multiplying: $(x_1-1)(x_2-2)=(x_2-1)(x_1-2)$. Expanding both sides gives $x_1x_2-2x_1-x_2+2 = x_1x_2-2x_2-x_1+2$, so $-2x_1-x_2=-2x_2-x_1 \Rightarrow -x_1=-x_2 \Rightarrow x_1=x_2$. One-one.
Onto $\mathbb{R}$? Solve $y=\dfrac{x-1}{x-2}$ for $x$: $y(x-2)=x-1 \Rightarrow x(y-1)=2y-1 \Rightarrow x=\dfrac{2y-1}{y-1}$, which fails when $y=1$. So $y=1$ has no pre-image and the range is $\mathbb{R}\setminus\{1\}$.
Answer: $f$ is one-one but not onto $\mathbb{R}$; it becomes a bijection if the codomain is taken as $\mathbb{R}\setminus\{1\}$.
How many one-one functions are there from a set of $4$ elements to a set of $6$ elements?
Solution
For a one-one function we choose distinct images for the $4$ inputs from the $6$ available outputs, in order.
That is a permutation count: $\dfrac{6!}{(6-4)!}={}^{6}P_{4}=6\times 5\times 4\times 3$.
$$6\times 5\times 4\times 3 = 360.$$
Answer: There are $\mathbf{360}$ one-one functions.
Show that $f:\mathbb{R}\to[-1,1],\ f(x)=\sin x$ is onto but not one-one.
Solution
Onto: The range of $\sin x$ is exactly $[-1,1]$, which equals the stated codomain, so every value in $[-1,1]$ is attained. Onto.
One-one? $\sin 0 = 0 = \sin \pi$, yet $0\ne\pi$. Two distinct inputs share an output. Not one-one.
Answer: $f(x)=\sin x$ from $\mathbb{R}$ to $[-1,1]$ is onto but not one-one (it is many-one).
Let $f:\mathbb{R}\to\mathbb{R}$ be defined by $f(x)=3-4x$. Classify $f$ as one-one / onto / bijective.
Solution
One-one: If $f(x_1)=f(x_2)$ then $3-4x_1=3-4x_2 \Rightarrow -4x_1=-4x_2 \Rightarrow x_1=x_2$. One-one.
Onto: For any $y\in\mathbb{R}$, solve $3-4x=y \Rightarrow x=\dfrac{3-y}{4}\in\mathbb{R}$. So every $y$ has a pre-image. Onto.
Answer: $f(x)=3-4x$ is both one-one and onto, hence bijective.