8

As I was graphing functions in Desmos graphing calculator, I typed in the function $$\lceil{x-\lfloor{x}\rfloor}\rceil$$

which, after some reasoning, unsurprisingly generates the values $0$ or $1$. My question is, can you - with any given amount of floor and ceiling functions - get a the values $0,1$ and $2$? In general, can you prove that with any amount of floor and ceiling functions you can obtain only whole numbers from $0$ to $n$.

Note???

Modular/remainder functions aren't allowed. I'm still in high school so I would appreciate an informal way of either proving the existence of such a function or actually showing a function that can cycle from $0$ to $n$.

Ian L
  • 889
  • 9
    "Modular/remainder functions aren't allowed." — $\ $ $x-\lfloor x\rfloor$ is exactly a remainder function: It's the remainder for division by $1$. – celtschk Aug 30 '16 at 07:38

3 Answers3

21

The function $f(x)$ that cycles through $0,1,...,n-1$ is $f(x) = x \bmod n$. So the question is basically how to write it without using $\operatorname{mod}$.

The largest multiple of $n$ lower than or equal to $x$ is $n \left\lfloor \frac{x}{n} \right\rfloor$ and $\operatorname{mod}$ is the difference between $x$ and this largest multiple of $n$. So, in the end:

$$ f(x) = x - n \left\lfloor \frac{x}{n} \right\rfloor $$

is equivalent to the $\operatorname{mod}$ function and will loop through $0,1,...,n-1$ for sequential $x \in \mathbb{N}$.


[ EDIT ] Also, for an example of a function that loops through the same values, but takes only integer values between them:

$$ \lfloor f(x) \rfloor = \left\lfloor{x}\right\rfloor - n \left\lfloor\frac{x}{n}\right\rfloor $$

dxiv
  • 76,497
  • 1
    You can write a congruency with parentheses using the LaTeX \pmod operator: f(x) \equiv x \pmod n renders as: $f(x) \equiv x \pmod n$. For a single $mod$ to appear in upright font declare it explicitly as an operator name: \operatorname{mod} → $\operatorname{mod}$. – CiaPan Aug 30 '16 at 15:59
  • @CiaPan Thanks for the tips. Edited to fix the typesetting. – dxiv Aug 30 '16 at 16:27
  • @CiaPan: is it correct to write $f(x) = x \pmod n$ ? With $n>0$, I use $a\equiv b\pmod n$ to mean that $n$ divides $b-a$; and $a=b\bmod n$ to additionally mean that $0\le a<n$. – fgrieu Aug 30 '16 at 16:39
  • @fgrieu $f(x) = x \pmod n$ is just shorthand for defining the function $f : x \mapsto x \pmod n$. – dxiv Aug 30 '16 at 19:09
  • 1
    @dxiv: my problem is with $x\pmod n$; unless I err, my math teacher (France, 1978-1982) thought that the remainder of the division of $x$ by $n$ (as meant here) is noted $x\bmod n$, not $x\pmod n$; that $y\equiv x\pmod n$ means $y-x$ is divisible by $n$; and that $x\pmod n$, if used at all, would be the infinite set of $y$ with $y\equiv x\pmod n$. – fgrieu Aug 30 '16 at 19:25
  • @fgrieu I believe $=$ means remainder and $\equiv$ means congruence (which is why I used $=$ in the answer). The $f(x) = x \pmod n$ usage for defining a function appears to be accepted as unambiguous, see for example the various answers to How can a = x (mod m) have multiple meanings in modular arithmetic That said, English is not my first (math) language either. – dxiv Aug 30 '16 at 19:40
  • 1
    @fgrieu is correct here. It is a common mistake to use "$x \pmod{n}$" instead of the intended "$x \bmod n$". The accepted answer to the very question you linked uses the right notation. Don't assume that the asker was using the correct notation. – user21820 Aug 31 '16 at 02:38
  • @user21820 Thank you. Edited (back) to $= x \bmod n$. FWIW one of the other upvoted answers to the linked question, also from a high rep user, did allow for $= x \pmod n$ though that seems to be the less popular between the two, indeed. – dxiv Aug 31 '16 at 02:58
8

Sure. $x-\lfloor x \rfloor$ is the fractional part of $x$, so it can take any value in the range $[0,1)$.

So $2(x-\lfloor x \rfloor)$ can take any value in the range $[0,2)$, which means $\lceil 2(x-\lfloor x \rfloor) \rceil$ can be any of $0$, $1$, or $2$.

Similarly $n(x-\lfloor x \rfloor)$ can take any value in the range $[0,n)$, which means $\lceil n(x-\lfloor x \rfloor) \rceil$ can take on any integer value between $0$ and $n$ inclusive.

Micah
  • 38,108
  • 15
  • 85
  • 133
  • This doesn't necessarily give $x \in \mathbb{N}$ which (is not entirely clear in the question, but) seems to be required. – dxiv Aug 30 '16 at 03:25
  • @dxiv When does this occur? – Ian L Aug 30 '16 at 03:29
  • @IanLimarta For example $\lceil 2(x - \lfloor x \rfloor) \rceil = 0$ for all $x \in \mathbb{N}$. Please edit the original question and clarify what you mean by "achieve the set of values ${x\space|\space\space{x\in{\mathbb{Z_{\geq0}}}}}$". – dxiv Aug 30 '16 at 03:34
  • @dxiv Edited. I'm sorry but I meant whole numbers. I should have just put that instead. – Ian L Aug 30 '16 at 03:45
6

$\def\floor#1{\lfloor#1\rfloor}$Take any positive integer $n$ and real $x$.

$\floor{x-n\floor{\frac{x}{n}}} = \floor{x} \bmod n$. [This cycles through $0$ to $n-1$ with one unit for each value.]

$\floor{n(x-\floor{x})} = \floor{nx} \bmod n$. [This cycles through $0$ to $n-1$ with period length $1$.]

The easiest way to see why is to notice that $n \floor{\frac{x}{n}}$ is the nearest multiple of $n$ no greater than $x$, so subtracting that from $x$ yields the remainder of $x$ modulo $n$. If you then perform a further floor, you will get the integer part of the remainder, as desired. You can first scale $x$ by a constant before the whole process, to change the period length. This is how we can get the second expression above.

user21820
  • 57,693
  • 9
  • 98
  • 256