# Looking for a formula to compute $\left\lceil \frac{x+1}{2} \right\rceil$

I'm looking for a formula to easily compute: $$\left\lceil \frac{x+1}{2} \right\rceil$$ The formula shouldn't use any floor, ceil or round function. I'm looking for something "simple".

• Which one? Floor or ceiling? – Ty. Jun 11 at 19:57
• What's wrong with $\operatorname{ceil}$? – Jair Taylor Jun 11 at 19:57
• @Ty. ceil. Thank you for pointing out the mistake. – Jay Jay Jun 11 at 19:58
• @JayJay does a summation count as "simple"? – Ty. Jun 11 at 19:58
• Why is that expression itself a simple formula. Not sure how to make it simpler. – fleablood Jun 11 at 19:59

No closed-form expression with $$+,-,\times,\div$$ can "emulate" the ceiling function (in particular because these operators are continuous; all they allow are rational fractions). With these basic operators, you would need an expression of infinite size.

Periodic functions and their inverses, like

$$\frac1\pi\arctan(\tan(\pi x))$$ give you access to the fractional part, from which you can build the floor/ceiling. But this is by no means "simple".

The answer is essentially no way.

• "No closed-form expression with +,−,×,÷ can "emulate" the ceiling function" Okay. Then what I was looking for isn't possible. I think this will be the closer to a "correct solution". Thank you. – Jay Jay Jun 11 at 20:06

If $$\frac{x+1}{2}$$ isn't an integer, then $$\left\lceil \frac{x+1}{2} \right\rceil=\left\lfloor \frac{x+1}{2} \right\rfloor+1$$ and $$(x+1) \pmod{2}=x+1-2\cdot\left\lfloor \frac{x+1}{2} \right\rfloor$$ $$\iff \left\lfloor \frac{x+1}{2} \right\rfloor=\frac{(x+1)-((x+1) \pmod{2})}{2}$$ $$\implies \left\lceil \frac{x+1}{2} \right\rceil=\frac{(x+1)-((x+1) \pmod{2})}{2}+1$$ Otherwise $$\left\lceil \frac{x+1}{2} \right\rceil=\frac{x+1}{2}$$

• What's the closed form of $x \pmod 2$? – fleablood Jun 11 at 20:21
• @AnasA.Ibrahim I appreaciate your answer and, even with the mistake, your result was useful in a certain way. Thanks for replying. :) – Jay Jay Jun 11 at 20:21
• By the way, $\lceil\frac{x+1}2\rceil=\lfloor\frac{x+1}2\rfloor+1$ is wrong ! This is not your day. – Yves Daoust Jun 11 at 20:26