# To find whether the function is one-one and onto and also to proof a function bijective.

$f$ is a function from $\mathbb{N}$ to $\mathbb{N}$. \begin{align} f(x)&=x+1,\text{ if x is odd} \\ &=x-1,\text{ if x is even} \end{align}

I have proved it one-one by taking $x_1,x_2$ either even or odd and putting $f(x_1)=f(x_2)$, which gives $x_1=x_2$. And for onto, I took $f(x)=y$, for both cases, and then found its inverse, which is defined for all $x$ belonging to $\mathbb{N}$.

There is another function from $\mathbb{N}$ to $\mathbb{N}$ \begin{align} f(x)&=(n+1)/2,\text{ if n is odd} \\ &=n/2,\text{ if n is even} \end{align} To find: whether it is bijective or not. I followed the same procedure as above but it gives that it is bijective. But the answer is that it's not one-one but it's onto. Someone suggested to take one more case as $x_1$ is odd and $x_2$ as even while finding the proof for one-one, and here I got totally stuck.

• Take n=1 and n=2 and you will se it is not injective, in general if n is odd then f(n)=f(n+1) – la flaca Feb 24 '16 at 16:36
• that's a proof of it, not an example. If the function were injective then for any n=\=m it must be the case that f(n)=\=f(m), so to prove f is not injective you must prove that there are some naturals n and m s.t n=\=m for which f(n)=f(m). – la flaca Feb 24 '16 at 16:42
• $f$ is a function from $\mathbb{R}$ to $\mathbb{R}$... Is $\pi$ even or odd ? – J.-E. Pin Feb 24 '16 at 17:07
• Even or odd is a property that only integers (the whole numbers, including positives, negatives, and zero) have. We do not call other numbers (fractions, irrational numbers, imaginary numbers, and so on) either even or odd. Therefore pi is neither even nor odd. – Adesh Tamrakar Feb 24 '16 at 17:26
• @AdeshTamrakar - The point of J.-E.Pin's comment is you claim your first function $f$ is from $\Bbb R$ to $\Bbb R$. But the definition you give for it only works for integers. Your function is not defined if $x$ is not an integer. So please clarify: is $f$ actually from $\Bbb Z$ to $\Bbb Z$, or is there more to the definition of $f$ that you have not provided? – Paul Sinclair Feb 24 '16 at 18:54

If I understand correctly, your function $f$ from $\mathbb R$ to $\mathbb R$ being defined just for integers, we have to interpolate in order to get a bijection.

It is clear that $f$ must be necessarily non-continuous because of intermediate values theorem.

There are a lot of possibilities for such an $f$ as suggested by the figure below. The analytic expression of an example can be given by $$f(x)=\begin{cases} x-1\space\text{for}\space 2n+1\lt x\le 2n\\x+1\space \text{ for}\space 2n\lt x\le 2n+1\end{cases}$$ in which the black arcs in the figure are just segments of the given lines $y=x-1$ and $y=x+1$

• Thanks for your answer, it explained me everything, can you please also proof this from where I got stuck ( by using $x_1$ odd and $x_2$ even as explained in the question) – Adesh Tamrakar Feb 25 '16 at 4:42
• I see you have changed $\mathbb R$ to $\mathbb R$ by $\mathbb N$ to $\mathbb N$. This change the problem. I shall try to answer later. Regards. – Piquito Feb 26 '16 at 11:53
• All integer is either odd or even. You have $f(n-1)=n$ if $n$ is odd and $f(n+1)=n$ if $n$ is even. I think this is enough. Am I wrong? – Piquito Feb 26 '16 at 12:03
• OK, here n is even and odd (respectively in the two cases) but $n+1$ and $n-1$ will become odd and even. And then the respective functions will change. But I understood. Thank you. – Adesh Tamrakar Feb 28 '16 at 5:17