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

Let $$a$$ and $$b$$ be positive integers.

If $$b$$ is even, then we have $$\left\lfloor \frac{a-b}{2} \right\rfloor + \left\lceil \frac{a+b}{2} \right\rceil = a$$

I think the equality also hold when $$b$$ is odd. What could be a proof for it?

## closed as off-topic by user21820, Lord_Farin, Did, RRL, Trevor GunnJan 28 at 16:37

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please provide additional context, which ideally explains why the question is relevant to you and our community. Some forms of context include: background and motivation, relevant definitions, source, possible strategies, your current progress, why the question is interesting or important, etc." – user21820, Lord_Farin, Did, RRL, Trevor Gunn
If this question can be reworded to fit the rules in the help center, please edit the question.

• Write $b$ as $2k + 1$, where $k$ is a nonnegative integer. Then look at two cases: $a = 2s$ ($s$ a positive integer), and $a = 2s + 1$ ($s$ a nonnegative integer). What do you get for the left-hand side in each case? [You can show your work by clicking "edit" beneath your question.] – John Hughes Jan 25 at 12:58
• @JohnHughes why are you presuming the existence of work? Perhaps they have no work and no idea, and to now do work and retroactively add it to the question would be the equivalent of answering it, so they shouldn't edit to add new work that wasn't done before originally asking. – The Great Duck Jan 26 at 1:32
• You might notice that my comment appeared a few minutes after the question was asked, and before lots of other folks posted answers. Either way, I generally like to lead people in the direction of answering their own questions when I can (esp. when they look to me like homework questions). – John Hughes Jan 26 at 3:23

## 5 Answers

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.

• Thank you very much for the odd case, made very simple! – Adam54 Jan 25 at 13:05

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.)

If $$a$$ and $$b$$ are both odd then we have $$a=2m+1$$ and $$b=2n+1$$ where $$m$$ and $$n$$ are positive integers.

Then, we have \begin{align}\left\lfloor\frac{a-b}2\right\rfloor+\left\lceil\frac{a+b}2\right\rceil &= \left\lfloor\frac{(2m+1)-(2n+1)}2\right\rfloor+ \left\lceil\frac{(2m+1)+(2n+1)}2\right\rceil\\ &=\left\lfloor\frac{2m-2n}2\right\rfloor+ \left\lceil\frac{2m+2n+2}2\right\rceil\\ &=\lfloor m-n\rfloor + \lceil m+n+1\rceil\\ &= m-n + m+n+1\tag{*}\\ &= 2m+1\\ &=a\end{align}

We can get to $$(*)$$ because $$m$$ and $$n$$ are integers and so their floor (or ceiling) is just the number inside (two integers added or subtracted will always give an integer answer).

If $$a$$ is even and $$b$$ is odd, then we have $$a=2m$$ and $$b=2n+1$$, again for $$m$$ and $$n$$ integers.

So we have \begin{align}\left\lfloor\frac{a-b}2\right\rfloor+\left\lceil\frac{a+b}2\right\rceil &= \left\lfloor\frac{(2m)-(2n+1)}2\right\rfloor+ \left\lceil\frac{(2m)+(2n+1)}2\right\rceil\\ &=\left\lfloor\frac{2m-2n-1}2\right\rfloor+ \left\lceil\frac{2m+2n+1}2\right\rceil\\ &=\left\lfloor m-n-\frac 12\right\rfloor + \left\lceil m+n+\frac12\right\rceil\\ &= m-n -1+ m+n+1\tag{\dagger}\\ &= 2m\\ &=a\end{align}

Here we get to $$(\dagger)$$ because we round the first half down and the second half up to their respective nearest integers

As $$s:=a+b$$ and $$a-b$$ have the same parity, we can write

$$\left\lfloor\frac{s-2b}2\right\rfloor+\left\lceil\frac s2\right\rceil=\left\lfloor\frac s2\right\rfloor+\left\lceil\frac s2\right\rceil-b=s-b=a.$$