# A function f from the set of natural numbers to integers defined by

Question:

A function f  from the set of natural numbers to integers defined by

f(n)=\left\{\begin{aligned} \frac{n-1}{2}, & \text { when } n \text { is odd } \\-\frac{n}{2}, & \text { when } n \text { is even } \end{aligned}\right. is

(a) neither one-one nor onto
(b) one-one but not onto
(c) onto but not one-one
(d) one-one and onto both

Solution:

(d) one-one and onto both

Injectivity:

Let x and y be any two elements in the domain (N).

Case-1: Both $x$ and $y$ are even.

Let $f(x)=f(y)$

$\Rightarrow \frac{-x}{2}=\frac{-y}{2}$

$\Rightarrow-x=-y$

$\Rightarrow x=y$

Case-2: Both $x$ and $y$ are odd.

Let $f(x)=f(y)$

$\Rightarrow \frac{x-1}{2}=\frac{y-1}{2}$

$\Rightarrow x-1=y-1$

$\Rightarrow x=y$

Case-3 : Let $x$ be even and $y$ be odd.

Then, $f(x)=\frac{-x}{2}$ and $f(y)=\frac{y-1}{2}$

$x \neq y$

$\Rightarrow f(x) \neq f(y)$

From all the cases, $f$ is one-one.

Surjectivity:

Co-domain of $f=Z=\{\ldots,-3,-2,-1,0,1,2,3, \ldots\}$

Range of $f=\left\{\cdots, \frac{-3-1}{2}, \frac{-(-2)}{2}, \frac{-1-1}{2}, \frac{0}{2}, \frac{1-1}{2}, \frac{-2}{2}, \frac{3-1}{2}, \ldots\right\}$

$\Rightarrow$ Range of $f=\{\ldots,-2,1,-1,0,0,-1,1, \ldots\}$

$\Rightarrow$ Range of $f=\{\ldots,-2,-1,0,1,2, \ldots\}$

$\Rightarrow$ Co-domain of $f=$ Range of $f$

$\Rightarrow f$ is onto.