# Proof of one-to-one and onto for a function

Im having a bit of trouble with the following question:

let $f:R\rightarrow \mathbb{Z}$ be the function where for each $x\in R$, $f(x)=\lfloor 2x \rfloor$.

a) Is f a one to one function?

I.E. $\forall x \in R$, $f(x_1)=f(x_2) \implies x_1 = x_2$)

Proof by counter example: let

$x_1=\frac{1}{2}$

$x_2=\frac{3}{4}$

now substitute into $f(x)$:

$f(1/2)=\lfloor 2(1/2) \rfloor = 1$

$f(3/4)=\lfloor 2(3/4) \rfloor = 1$

so $f(1/2)=f(3/4)$ but $x_1 \neq x_2$ so not one to one

b) Is f an onto function?

$f:R \rightarrow \mathbb{Z}$ is onto if and only if $\forall x_2\in Z,\exists x_1\in R$ such that $f(x_1)=x_2$

Proof:

f($x_1$)=$\lfloor 2(x_1) \rfloor$=$x_2$

$\lfloor x_1 \rfloor$ =$x_2/2$ (this is as far as i got before my train of thought hit a brick wall)

can someone please help me understand the last bit of this question? the part thats confusing me is that im unsure about how to solve when a floor or ceiling is involved. Also Im pretty sure my proof for part a) is correct but if not it would be a huge help if you could correct me where ive gone wrong.

-thanks

You are correct about part a).

For $f$ to be an "onto" function, as you put it (we call that "surjective" most of the time), you need that every element of $\mathbb{Z}$ gets mapped to by your function $f$ (your definition of "onto" as you put in your question, is incorrect).

$\mathbb{Z}$ only contains the integers. Can every integer be mapped to by your function $f$? If not, can you find a counter example? If so, you need to prove it! The best way to try to prove something like that is to consider an arbitrary integer, say $k$, and prove that it can be mapped to by $f$.

• i edited the question. Im still confused though, the floor of a real number is an integer so in saying that can i just treat the floor of 2x as just 2x? – kr1s Sep 29 '17 at 1:18
• @kr1s What you need to do is show that the function is surjective is to show that for each $n \in \mathbb{Z}$, there exists $x \in \mathbb{R}$ such that $n = \lfloor 2x \rfloor$. What value of $x$ will work? – N. F. Taussig Sep 29 '17 at 1:22
• I'm not sure what you mean. You must treat the floor of $2x$ as what it is, which is the floor of $2x$. – Matt Sep 29 '17 at 1:22
• I know intuitively that the product of 2 real numbers will give me another real number, and taking the floor of that real number will give me an integer but i dont know how to show that formally – kr1s Sep 29 '17 at 1:27
• All you need to show is that for any element of $\mathbb{Z}$ there exists a real number which, when you take the floor of it, gives you that element of $\mathbb{Z}$. For example, if I pick 4, you could say that you are going to take the floor of 4.5, and that will give you 4. If I pick -29, you could pick the floor of -28.1. You need to prove this for every single element of $\mathbb{Z}$. If I tell you an arbitrary integer, what number can you take the floor of to get me that integer? There are lots of choices, but one particularly obvious choice. – Matt Sep 29 '17 at 1:41

This is what I came to for part b

to prove that f is surjective, $\forall n \in \mathbb{Z}$, a real number $x$ is needed such that $n=\lfloor 2x \rfloor$:

dividing both sides by 2:

$\frac{n}{2}=x$

substituting back into f:

$n=\lfloor 2(\frac{n}{2}) \rfloor$

$n=\lfloor n \rfloor$

since n is an integer and also a real number and the floor of an integer is always that same integer, the function f is surjective/onto.

is this correct? if not can someone please correct me

• Your solution is correct. – N. F. Taussig Sep 30 '17 at 2:16