# Given $\lceil x−1 \rceil$, how can I compute $\lfloor x \rfloor$ without using $modulo$?

I have $\lceil x \rceil = -\lfloor -x \rfloor$, but I can't figure out how to rely on this in order to get $\lfloor x \rfloor$ from $\lceil x−1 \rceil$.

For the record, I am only interested in non-negative real values.

I wish to avoid the use of $modulo$, $abs$, $round$ and $if$.

The motivation behind this question is as follows:

$$x-\frac{1}{2}-\frac{\arctan(\tan(\pi(x-\frac{1}{2})))}{\pi}=\lceil x-1 \rceil$$

How do I "manipulate" the value of $x$ in order to get $\lfloor x \rfloor$ instead of $\lceil x-1 \rceil$?

UPDATE:

I also have this if it helps:

$$x+\frac{1}{2}+\frac{\arctan(\tan(\pi(-x-\frac{1}{2})))}{\pi}=\lceil x \rceil$$

• If $x\in\mathbb N$, $\lceil x-1 \rceil = x-1 = \lfloor x \rfloor - 1$, else $\lceil x-1\rceil = \lfloor x \rfloor$. Without additional information, this is impossible. ($\pm0$) – AlexR Apr 10 '14 at 16:15
• What about $\lceil{x-1\rceil}=\lceil{x\rceil}-1$? – npisinp Apr 10 '14 at 16:16
• You can pull integer addition from ceiling. From there you already have all you need... – The Great Duck Mar 4 '16 at 5:11

You know that $\lfloor x\rfloor=-\lceil-x\rceil$, so if you replace $x$ by $-x$ and multiply the equation by $-1$, you get $$x-\frac{1}{2}-\frac{\arctan(\tan(\pi(x-\frac{1}{2})))}{\pi}=-\lceil -x \rceil=\lfloor x\rfloor$$

• Can you please see updated question, as to the motivation behind it? – barak manos Apr 10 '14 at 16:30
• No it doesn't. Take a look at your proposed function. It is identical to the first one in my question, which yields $\lceil x-1 \rceil$. – barak manos Apr 10 '14 at 16:43
• @barakmanos Right. I forgot $x$ can't be an integer, then it's even true that $\lceil x-1\rceil=\lfloor x\rfloor$ and you don't have to derive it from the updated version like I did. Is it clear how I did it? – user2345215 Apr 10 '14 at 16:47
• Yes it is. But it doesn't provide an answer to my question, unless I use $if$ inside the function. – barak manos Apr 10 '14 at 17:03
• @barakmanos Well, graphing it [here] alongside a floor function seems to be the exact same function as a result. [here]=desmos.com/calculator/yuousd7vdl – Conor O'Brien Dec 10 '14 at 2:54

If $x\in\mathbb N$, $\lceil x-1 \rceil = x-1 = \lfloor x \rfloor - 1$, else $\lceil x-1\rceil = \lfloor x \rfloor$. Without additional information, this is impossible.

• Thanks @AlexR, but what do you mean by "additional information"? Also, I wish to avoid the use of $modulo$, $abs$, $round$ and $if$ (updated the question accordingly). – barak manos Apr 10 '14 at 16:19
• @barakmanos This means if $\lceil x-1 \rceil$ is the only piece of information you have, you can't figure out $\lfloor x \rfloor$. You need the information if $x\in\mathbb N$ in some form or another. For example $(x-\lceil x-1\rceil > 0)$ (as a boolean) would suffice. If it is false, $x\in\mathbb N$, else $x\notin\mathbb N$. And from there you can use the two formulas given. – AlexR Apr 10 '14 at 16:21

Changing the $\dfrac{1}{2}$ found in the equation to a $\dfrac{1}{-2}$, we are resulted with this:

# Equation

$$f(x)=x+\frac{1}{-2}+\frac{\arctan \left(\tan \left(\pi \left(-x-\frac{1}{2}\right)\right)\right)}{\pi }=\lfloor x\rfloor$$

# Tests

$$f(1)=1$$ $$f(1.5)=1$$ $$f(\pi)=3$$ $$f(e)=2$$ $$f(-1)=-1$$ $$f(-1.5) = -2$$