Is it true that $$\forall x>y\in\mathbb N:\lceil\log_2 x\rceil - \left\lfloor\log_2 y\right\rfloor\leq \left\lceil\log_2\frac{x}{y}\right\rceil+1$$?
I reached this inequality when further analyzing the expression I got in this question (I keep a set of counters that each has a potentially different size).
Thanks !!
Set $a=\lceil \log_2 x\rceil$ and $b=\lfloor \log_2 y\rfloor$. We have $2^{a-1}<x\le2^a$ and $2^b\le y<2^{b+1}$. Dividing, we get $$2^{(a-1)-(b+1)}<\frac{x}{y}\le 2^{a-b}$$ Hence $$\log_2\left(\frac{x}{y}\right)\in (a-b-2,a-b]$$ and $$\lceil \log_2\left(\frac{x}{y}\right)\rceil\in \{a-b-1,a-b\}$$
Now, your desired inequality is $$a-b\le \lceil \log_2\left(\frac{x}{y}\right)\rceil+1$$ which holds for either $a-b-1$ or $a-b$, as desired.