How to define a function which takes a real number and gives as a result the closest $\le$ natural number?

How can I define a function which takes as an only parameter a real number and gives as a result the closest smaller natural number? E.g. $f(3.554)=3, f(4.95485)=4, f(2.001)=2$.

-
The function is called $floor$ and written as $\lfloor x\rfloor$ – Shard Jan 12 '13 at 11:56
If you're looking for a function that can be expressed in terms of elementary functions, you're out of luck. Floor and ceiling functions can be represented as infinite series that converge, but only in part of the domain. You can't use those representations in practice. – GregRos Jan 12 '13 at 12:12
Yes, exactly what I wanted to know. I asked my Mathematics teacher(I'm in High school) and he told me that I got the definiton of the function with my question. So I decided to search or ask how it could be defined in pure math notation, not in a specific language. – user1113314 Jan 12 '13 at 12:46

First, if your real number $k < 1$, then the function $f$ is not defined at $k$ since there is no natural number lesser than the value of $k$.

The function $f$ you are trying to define is just a subset of the floor function where $f:\{x|x\ge 1\} \mapsto \mathbb{N}$. Thus we can define your function as $f(x) = \max (y\in \mathbb{N}|y\le x), x \in [1,\infty)$.

-
Phew, I needed too many corrections on this one. – Parth Kohli Jan 12 '13 at 12:09
Thank you, really comprehensive answer. – user1113314 Jan 12 '13 at 13:04
@user1113314: No problem! – Parth Kohli Jan 12 '13 at 13:34

You can define such a function directly by it's desired properties, i.e. for $x\geq 1$, define $$f(x) :=\max \left\{ n\in\mathbb{N}:n\leq x \right\}.$$ As has already been pointed out, $f(x)$ is commonly denoted by $\lfloor x\rfloor$. Clearly $f$ is discontinuous, so it cannot be expressed as a finite composition of continuous functions (which probably is what you've actually been looking for) or a power series.

One obvious representation of $f$ would be to write it as a limit of step functions: $$f = \lim_{n\rightarrow \infty}\sum_{k=1}^n k \cdot\chi_{[k,k+1)}$$ where $\chi_I$ is the characteristic function of the interval $I$, but this is really nothing more than toying with the definition.

-
Thank you for the answer. the representation is too complicated for me. I'll take a look at the floor(x) implementation in Wikipedia. – user1113314 Jan 12 '13 at 13:06