# How to take floor function out?

#### Mos5180d

##### New member
Floor((n+1)/2)^2 - floor(n/2)^2 - 1/2(1-(-1)^n)(n)=0

It works for every n and I can simplify it down here and there but can’t seem to get near the answer.
The floor functions keep restricting me.

I can get floor out by adding variables in but this gives me more to work with and doesn’t seem to cancel down. E.g (((n+1)/2)+a)^2 - ((n/2)+b)^2

I could separate it for n=even and n=odd, but surely if this is true for all values of n then it can be rearranged.

Help would be greatly appreciated
Thanks.

Last edited:

#### Dr.Peterson

##### Elite Member
Just break it into two cases: n is even (2k), or n is odd (2k+1). In each case, you can drop the floor.

Then show use your work so we can see if you are close, or need another hint.

• topsquark

#### Mos5180d

##### New member
Just break it into two cases: n is even (2k), or n is odd (2k+1). In each case, you can drop the floor.

Then show use your work so we can see if you are close, or need another hint.
Sorry I should have mentioned that I could do it this way but surely there is a way to do this in one go if I know that for all values of n the answer is 0.
Thank you for your input though! #### pka

##### Elite Member
Floor((n+1)/2)^2 - floor(n/2)^2 - 1/2(1-(-1)^n)(n)=0
It works for every n and I can simplify it down here and there but can’t seem to get near the answer.
The floor functions keep restricting me.
$$\displaystyle \left\lfloor {\frac{{n + 1}}{2}} \right\rfloor^2-\left\lfloor {\frac{{n}}{2}} \right\rfloor^2 -\frac{1}{2}[1-(-1)^n]n$$
Factor difference of two squares,
$$\displaystyle \left(\left\lfloor {\frac{{n + 1}}{2}} \right\rfloor+\left\lfloor {\frac{{n}}{2}} \right\rfloor\right)\left(\left\lfloor {\frac{{n + 1}}{2}} \right\rfloor-\left\lfloor {\frac{{n}}{2}} \right\rfloor\right)-\frac{1}{2}[1-(-1)^n]n$$

If $$\displaystyle n$$ is even then then both $$\displaystyle \left(\left\lfloor {\frac{{n + 1}}{2}} \right\rfloor-\left\lfloor {\frac{{n}}{2}} \right\rfloor\right)$$ and $$\displaystyle -\frac{1}{2}[1-(-1)^n]n$$ are zero.

If $$\displaystyle n$$ is odd then then both $$\displaystyle \left(\left\lfloor {\frac{{n + 1}}{2}} \right\rfloor-\left\lfloor {\frac{{n}}{2}} \right\rfloor\right)$$ and $$\displaystyle -\frac{1}{2}[1-(-1)^n]n$$ what can you say about those?

If you need help with the floor function see here.

• topsquark

#### Mos5180d

##### New member
$$\displaystyle \left\lfloor {\frac{{n + 1}}{2}} \right\rfloor^2-\left\lfloor {\frac{{n}}{2}} \right\rfloor^2 -\frac{1}{2}[1-(-1)^n]n$$
Factor difference of two squares,
$$\displaystyle \left(\left\lfloor {\frac{{n + 1}}{2}} \right\rfloor+\left\lfloor {\frac{{n}}{2}} \right\rfloor\right)\left(\left\lfloor {\frac{{n + 1}}{2}} \right\rfloor-\left\lfloor {\frac{{n}}{2}} \right\rfloor\right)-\frac{1}{2}[1-(-1)^n]n$$

If $$\displaystyle n$$ is even then then both $$\displaystyle \left(\left\lfloor {\frac{{n + 1}}{2}} \right\rfloor-\left\lfloor {\frac{{n}}{2}} \right\rfloor\right)$$ and $$\displaystyle -\frac{1}{2}[1-(-1)^n]n$$ are zero.

If $$\displaystyle n$$ is odd then then both $$\displaystyle \left(\left\lfloor {\frac{{n + 1}}{2}} \right\rfloor-\left\lfloor {\frac{{n}}{2}} \right\rfloor\right)$$ and $$\displaystyle -\frac{1}{2}[1-(-1)^n]n$$ what can you say about those?

If you need help with the floor function see here.
I did try the difference of two squares but this has made me see it in a different light thanks!
Do you think there’s a way without stating when n is odd or even though?

#### pka

##### Elite Member
Do you think there’s a way without stating when n is odd or even though?
It is ironic that you ask that question because it is usually the other way round.
That is the floor function is used to simply other expressions such as mod function, fractional part function , etc. See that link.
$$\displaystyle \left( {\left\lfloor {\frac{{n + 1}}{2}} \right\rfloor + \left\lfloor {\frac{n}{2}} \right\rfloor } \right)=n$$ for all n. SEE HERE
$$\displaystyle \left( {\left\lfloor {\frac{{n + 1}}{2}} \right\rfloor - \left\lfloor {\frac{n}{2}} \right\rfloor } \right)=\begin{cases}0 &: n\text{ is even} \\ 1 &: n\text{ is odd}\end{cases}$$ SEE HERE

• topsquark

#### Dr.Peterson

##### Elite Member
Sorry I should have mentioned that I could do it this way but surely there is a way to do this in one go if I know that for all values of n the answer is 0.
Thank you for your input though! Why would you want a harder way?

There are many problems for which breaking into cases is the most natural method, and I think this is one of them. For example, pka's method also uses cases, though in a more elaborate way than I had in mind. "All in one go" is not better; cases are a powerful and respectable method.

I don't think your "surely" is justified. Any other way would probably be a complicated workaround, or just use theorems (like those pka just showed) that are themselves proved by cases. In particular, anything involving (-1)^n is a way to smuggle even and odd into an equation, and is best handled by breaking it back up into those cases.

• topsquark