[Math] Prove a floor function is onto/surjective

ceiling-and-floor-functionsdiscrete mathematicsformal-proofs

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?

Best Answer

You cannot take the inverse of the floor function because it is not injective. For example, the floor function of 1.1 and 1.2 are both 1.

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.

Related Question