# Prove a floor function is onto/surjective

I have function $$u(x) = \lfloor x \rfloor$$ mapped from $$\mathbb{R}$$ to $$\mathbb{Z}$$ which I need to prove is onto.

I know that standard way of proving a function is onto requires that for every $$Y$$ in the co-domain there should exist an $$x$$ in the domain such that $$u(x) = y$$

I usually go about this by finding the inverse of the function and then plugging the inverse into the function itself to show that the function $$u(x) = y$$

Intuitively, I know that $$u$$ is onto because for every integer $$y$$, there exists a real number $$x$$ that can plugged into $$u$$ that returns $$y$$,

I just have no clue how to prove this since I don't understand how one would take the inverse of a floor function. How should I approach this problem in order to prove it?

• You don't need an inverse function (and there isn't one). The end of your sentence that begins "intuitively" IS a proof. Just tell the reader what $x$ gives a floor of an integer $y$. Commented Feb 15, 2018 at 1:12
• $\forall z\in \mathbb Z, u(z) = z$ Commented Feb 15, 2018 at 1:14
• Can you find an $x$ that maps to $2?$ to $-2$? Commented Feb 15, 2018 at 1:15
• @EthanBolker any function that is surjective automatically has a right-inverse Commented Jun 23 at 11:31
• @SeekingAMathGeekGirlfriend Yes, there is a right inverse. But there is no inverse, and you don't need the right inverse to prove surjectivity. In this case proving surjectivity is the best way to find a right inverse. Commented Jun 23 at 14:21

To prove surjectivity, as you have said, for any number $n\in \mathbb{Z}$, you need a real number such that its floor function is $n$. Notice that the floor function of an integer is itself, so you would be done.
Note that for an integer $z$, $$\lfloor z \rfloor=z$$
Thus the function $$u(z) = \lfloor z \rfloor$$ is onto.