# Difference of expressions having ceiling functions

How can I simplify this expression having ceiling function? Assume $k\in \mathbb{N}$.

$$\left \lceil \frac{k^2+k+3}{6} \right \rceil- \left \lceil \frac{k^2-k+2}{6} \right \rceil$$

I know it is a positive expression. But can I get it as a simple expression in terms of $k$?

• Hint: $\lceil x \rceil = x +u$ where $0\le u < 1$, plus your result is an integer. It doesn't solve everything but it's a good start. – Gribouillis Dec 13 '16 at 14:10
• Good hint @Gribouillis – Sushil Verma Dec 13 '16 at 18:16

\begin{array}{|c|c|c|} \hline k \pmod 6 & k^2 + k + 3 \pmod 6 & \left \lceil \dfrac{k^2 + k + 3}{6} \right \rceil\\ \hline 0 & 3 & \dfrac{k^2 + k + 6}{6}\\ 1 & 5 & \dfrac{k^2 + k + 4}{6}\\ 2 & 3 & \dfrac{k^2 + k + 6}{6}\\ 3 & 3 & \dfrac{k^2 + k + 6}{6}\\ 4 & 5 & \dfrac{k^2 + k + 4}{6}\\ 5 & 3 & \dfrac{k^2 + k + 6}{6}\\ \hline \end{array}

For example, when $k \equiv 0 \pmod 3$, then $k^2 + k+3 \equiv 3 \pmod 6$. So, adding $3$ to $k^2 + k + 3$ will make it a multiple of $6$. That is $\dfrac{k^2 + k + 6}{6}$ will be the first integer greater than $\dfrac{k^2 + k + 3}{6}$.

\begin{array}{|c|c|c|} \hline k \pmod 6 & k^2 - k + 2 \pmod 6 & \left \lceil \dfrac{k^2 - k + 2}{6} \right \rceil\\ \hline 0 & 2 & \dfrac{k^2 - k + 6}{6}\\ 1 & 2 & \dfrac{k^2 - k + 6}{6}\\ 2 & 4 & \dfrac{k^2 - k + 4}{6}\\ 3 & 2 & \dfrac{k^2 - k + 6}{6}\\ 4 & 2 & \dfrac{k^2 - k + 6}{6}\\ 5 & 4 & \dfrac{k^2 - k + 4}{6}\\ \hline \end{array}

Straightforward computation results in

\begin{array}{|c|c|} \hline k \pmod 6 & \left \lceil \dfrac{k^2 + k + 3}{6} \right \rceil - \left \lceil \dfrac{k^2 - k + 2}{6} \right \rceil\\ \hline 0 & \dfrac k3\\ 1 & \dfrac{k - 1}{3}\\ 2 & \dfrac{k + 1}{3}\\ 3 & \dfrac k3\\ 4 & \dfrac{k - 1}{3}\\ 5 & \dfrac{k + 1}{3}\\ \hline \end{array}

which simplifies to

\begin{array}{|c|c|c|} \hline k \pmod 3 & \left \lceil \dfrac{k^2 + k + 3}{6} \right \rceil - \left \lceil \dfrac{k^2 - k + 2}{6} \right \rceil & \text{Which equals...}\\ \hline 0 & \dfrac k3 & \left \lfloor \dfrac{k+1}{3} \right \rfloor\\ 1 & \dfrac{k - 1}{3} & \left \lfloor \dfrac{k+1}{3} \right \rfloor\\ 2 & \dfrac{k + 1}{3} & \left \lfloor \dfrac{k+1}{3} \right \rfloor\\ \hline \end{array}

I found that last equation by trial and error. I just kept diddling with it until I got something that worked.

That is to say

$$\left \lceil \dfrac{k^2 + k + 3}{6} \right \rceil - \left \lceil \dfrac{k^2 - k + 2}{6} \right \rceil = \left \lfloor \dfrac{k+1}{3} \right \rfloor$$

• can you just explain, just for one row of the first table, how you are finding third column from second column @steven – Sushil Verma Dec 14 '16 at 5:31

HINT:

If $k=6a,k^2+k+3=(6a)(6a+1)+3,k^2-k+2=6a(6a-1)+2$

$$\left\lceil\frac{k^2+k+3}6\right\rceil - \left\lceil\frac{k^2-k+2}6\right\rceil=6a+1+1-(6a-1+1)=2$$

If $k=6a+1,k^2+k+3=(6a+1)(6a+2)+3=6a(6a+3)+5$ $,k^2-k+2=(6a+1)(6a)+2$

$$\left\lceil\frac{k^2+k+3}6\right\rceil - \left\lceil\frac{k^2-k+2}6\right\rceil=6a+3+1-(6a+1+1)=2$$

• There is something strange here as I would expect the values to be close to $\dfrac{k}{3}$ or $2a$ – Henry Dec 13 '16 at 13:59

Make a table showing $k$, $k^2+k+3$, and $k^2-k+2$ modulo $6$:

$$\begin{array}{c|c|c} k&k^2+k+3&k^2-k+2\\ \hline 0&3&2\\ 1&5&2\\ 2&3&4\\ 3&3&2\\ 4&5&2\\ 5&3&4 \end{array}$$

Thus, if $k\equiv0\pmod3$, then

$$\left\lceil\frac{k^2+k+3}6\right\rceil-\left\lceil\frac{k^2-k+2}6\right\rceil=\frac{k^2+k+6}6-\frac{k^2-k+6}6=\frac{k}3\;.$$

If $k\equiv1\pmod3$, then

$$\left\lceil\frac{k^2+k+3}6\right\rceil-\left\lceil\frac{k^2-k+2}6\right\rceil=\frac{k^2+k+4}6-\frac{k^2-k+6}6=\frac{k-1}3\;.$$

And if $k\equiv2\pmod3$, then

$$\left\lceil\frac{k^2+k+3}6\right\rceil-\left\lceil\frac{k^2-k+2}6\right\rceil=\frac{k^2+k+6}6-\frac{k^2-k+4}6=\frac{k+1}3\;.$$

If you wish to combine these into a single formula, one possibility is

$$\left\lceil\frac{k^2+k+3}6\right\rceil-\left\lceil\frac{k^2-k+2}6\right\rceil=\left\lfloor\frac{k+1}3\right\rfloor\;.$$

By following the hint I gave you yesterday, you can write

$$R=\lceil\frac{k^2+k+3}{6}\rceil - \lceil\frac{k^2-k+2}{6}\rceil =\frac{k^2+k+3}{6} +u- \frac{k^2-k+2}{6} - v =\frac{2 k+1}{6} + (u-v)$$ where $0 \le u, v < 1$, which imply that $-1 < u-v < 1$. It means that the result $R$ is an integer which distance from $\frac{2k+1}{6}$ is smaller than 1. It must be either $\lfloor\frac{2k+1}{6}\rfloor$ or $\lceil\frac{2k+1}{6}\rceil$ depending on the sign of $u-v$. Now, Steven Gregory's tables above show that $u -v<0$ unless $k\ (\mod 6) = 2 \text{ or } 5$. Hence $R = \lceil\frac{2k+1}{6}\rceil$ when $k\ (\mod 6) = 2 \text{ or } 5$ and $R = \lfloor\frac{2k+1}{6}\rfloor$ otherwise.