I'm looking for a really simple example of $f:\mathbb{N}\to\mathbb{Z}$ which is surjective but not injective. I thought about: $$ f(x)=\begin{cases} 0 & x=0\\ \frac{x+1}{2} & x\text{ is odd}\\ -\frac{x}{2} & x\text{ is even}\wedge x\neq0 \end{cases} $$ Is there a better and more simple example I can use?
$f:\mathbb{N}\to\mathbb{Z}$ which is surjective but not injective
267 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 3 best solutions below
On
$0 \notin \mathbb{N}$.
Let $f:\mathbb{N} \to \mathbb{Z}$ be a surjective and injective function. Define:
$$g(n) = \cases {f(1),\quad n =1\\ f(1),\quad n =2\\ f(n-1),\quad n\geq3}$$
Then $g:\mathbb{N} \to \mathbb{Z}$ is surjective but not injective.
On
$$ f(x)=\begin{cases} 0 & x=0\\ \frac{x+1}{2} & x\text{ is odd}\\ -\frac{x}{2} & x\text{ is even}\wedge x\neq0 \end{cases} \implies f(n)=(-1)^{n+1}\bigg\lfloor\frac{n+1}{2} \bigg\rfloor $$
$$ f(0)=(-1)^1\bigg\lfloor\frac{1}{2}\bigg\rfloor=0\quad f(1)=(-1)^2\bigg\lfloor\frac{2}{2}\bigg\rfloor=1\quad f(2)=(-1)^3\bigg\lfloor\frac{3}{2}\bigg\rfloor=-1\\ f(3)=(-1)^4\bigg\lfloor\frac{4}{2}\bigg\rfloor=2\quad f(4)=(-1)^5\bigg\lfloor\frac{5}{2}\bigg\rfloor=-2\quad f(5)=(-1)^6\bigg\lfloor\frac{6}{2}\bigg\rfloor = 3$$
Of course, the following alone also meets the criteria: $$f(x)=(-1)^x$$
as does the floor function alone unless you talk about infinities.
You can take, for instance, $f(n)=(-1)^n\left\lfloor\dfrac n2\right\rfloor$ (assuming, as you did, that $0\in\Bbb N$).