$\left\lfloor \frac{a-b}{2} \right\rfloor + \left\lceil \frac{a+b}{2} \right\rceil = a$ when $a,b$ are integers?

If $a$ and $b$ are both odd (or both even), then $a-b$ and $a+b$ are both even, and thus $$\left\lfloor \frac{a-b}{2} \right\rfloor = \frac{a-b}{2} \quad\text{and}\quad \left\lceil \frac{a+b}{2} \right\rceil = \frac{a+b}{2}.$$

Otherwise, if exactly one of $a$ and $b$ is odd, then $a-b$ and $a+b$ are both odd, and thus $$\left\lfloor \frac{a-b}{2} \right\rfloor = \frac{a-b}{2} - \frac12 \quad\text{and}\quad \left\lceil \frac{a+b}{2} \right\rceil = \frac{a+b}{2} + \frac12.$$

In either case, it's easy to check that your equation holds.


BTW, as noted by Gareth McCaughan, your equation in fact holds for all real numbers $b$, as long as $a$ is an integer. One fairly simple way to show this is to note that $\frac{a+b}{2} = a - \frac{a-b}{2}.$ Thus, we can rewrite your equation as $$\left\lfloor \frac{a-b}{2} \right\rfloor + \left\lceil a - \frac{a-b}{2} \right\rceil = a.$$

Since $a$ is an integer (by assumption), and since $\lceil k + x \rceil = k + \lceil x \rceil$ for any integer $k$, we can extract $a$ from the ceiling term to get $$\left\lfloor \frac{a-b}{2} \right\rfloor + a + \left\lceil - \frac{a-b}{2} \right\rceil = a,$$ and finally, by applying the identity $\lceil -x \rceil = - \lfloor x \rfloor$, rewrite this as $$\left\lfloor \frac{a-b}{2} \right\rfloor + a - \left\lfloor \frac{a-b}{2} \right\rfloor = a.$$ Cancelling the floor terms then just leaves the identity $a = a$.

On the other hand, as also noted by Gareth, your equation cannot hold for any non-integer $a$, since its left-hand side is always an integer.


The equality only depends on the parity of $a+b$, as it is the same as that of $a-b$. Then

$$\left\lfloor\frac02\right\rfloor+\left\lceil\frac02\right\rceil=0$$ and $$\left\lfloor\frac12\right\rfloor+\left\lceil\frac12\right\rceil=1$$ are enough as a proof.


This actually works whatever the value of $b$ -- it doesn't need to be an integer. Clearly it's true when $b=0$. Now imagine changing $b$ smoothly from $0$ to its final value. When does the value of our expression change? Precisely when $(a+b)/2$ or $(a-b)/2$ passes an integer; that is, when $a\pm b$ is an even integer; that is, when $b$ differs from $a$ by an even integer. When this happens, both terms change in opposite ways, so the expression as a whole doesn't change its value. So by the time $b$ reaches its final value, our expression still hasn't changed.

(On the other hand, if $a$ isn't an integer then the equation never holds because one side is an integer and the other isn't.)