# Prove this function is onto and one-to-one

$f:R \rightarrow R$

$f(x)$ = $(-1)^x$ $\lfloor(1+x)/2\rfloor$

So how do you prove it when you have a floor function?

-
Hi, welcome here.Are you sure your function is $\mathbb R \to \mathbb R$ ? As putting $x= -\frac 12$ contradicts this?? – TheJoker Nov 9 '12 at 5:29
Matthew: I'd suggest changing the first $R$ to $N$ and the second $R$ to $Z$, and maybe use $n$ instead of $x$ for the variable (most math folks think of $x$ as representing a real number, and if they see $n$ will assume it's a natural number). – coffeemath Nov 9 '12 at 15:58

Your function should be from the natural numbers $N$ to $Z$ where $N=\{0,1,2,...\}$ and $Z$ is the set of integers (positive, negative, zero whole numbers.
Then for even $x=2k$ we get $f(x)=k$ because the floor of $(2k+1)/2=k+1/2$ is $k$ and $(-1)^{2k}=+1.$
And for odd $x=2k-1$ we get $f(x)=-k$ since the floor of $((2k-1)+1)/2=k$ is $k$ and $(-1)^{2k-1}=-1$
To summarize: $$f(2k)=k$$ $$f(2k-1)=-k$$ From these you can see one to one and onto, since the even natural numbers are each divided by 2 to get one of the elements of $N$, and thus covering $N$ once, and the odd natural numbers cover the negative integers under $f$.
You can "see" how the function $f(x)$ is working by listing its values on $N$ for $x=0,1,2,...$: $$0,-1,1,-2,2,-3,3,-4,4,-5,5,...$$ This list of values obviously has each integer in it exactly once, so it's one to one and onto.