Can this expression: $\left \lfloor \left(\frac x 2 \right)^2\right \rfloor$ be rewritten without the floor part?

I was working on a graph theory problem that asks the maximum amount of edges on a bipartite graph of $x$ vertices, I got to the conclusion it should be: $$\left \lfloor \left(\frac x 2 \right)^2\right \rfloor$$

Note that if $x$ is even, the floor part is redundant.

• Are you only referring to integers? Commented Aug 12, 2015 at 22:00
• If $x$ is an odd integer the expression can be written as $\frac{x^2-1}{4}$. Commented Aug 12, 2015 at 22:01
• @CᴏɴᴏʀO'Bʀɪᴇɴ: I would find it difficult to imagine a non-integer number of vertices in a graph... Commented Aug 12, 2015 at 22:05
• @CᴏɴᴏʀO'Bʀɪᴇɴ Yes, only to integers, although it would be nice to see an expression for arbitrary reals just for fun. Commented Aug 12, 2015 at 22:07
• We have $x=2k+1\implies \lfloor\frac{x^2}{4}\rfloor = \lfloor k^2+k + \frac{1}{4}\rfloor = k^2+k = k(k+1) = \frac{x-1}{2}\frac{x+1}{2} = \frac{x^2-1}{4}$. Commented Aug 12, 2015 at 22:08

$$\left\{\begin{matrix} (x/2)^2 & \text{if }x\text{ is even}\\ (x^2-1)/4 & \text{if }x\text{ is odd} \end{matrix}\right.$$
For arbitrary reals? You can define $a(x)=\frac{2\left(\cos \left(x\pi \right)-1\right)}{4}+1$ and define your function to be $a\left(x\right)\left(\frac{x}{2}\right)^2+a\left(x-1\right)\left(\frac{x^2-1}{4}\right)$. This works since $a(x)$ is $0$ for odd numbers and $1$ for even numbers. Expanded, it would look like this: $$\left(\frac{2\left(\cos \left(x\pi \right)-1\right)}{4}+1\right)\left(\frac{x}{2}\right)^2+\left(\frac{2\left(\cos \left(x\pi-\pi\right)-1\right)}{4}+1\right)\left(\frac{x^2-1}{4}\right).$$ Oh yes. That was fun.