Is it possible to solve for $i$ in the following equation?
EDIT- WolframAplha says it is possible but how do I do it?
$$\left \lfloor{\displaystyle \frac n{2^i}}\right \rfloor =1 $$
I am not sure on how to separate the floor to solve for $i$
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It only takes a minute to sign up.
Sign up to join this communityIs it possible to solve for $i$ in the following equation?
EDIT- WolframAplha says it is possible but how do I do it?
$$\left \lfloor{\displaystyle \frac n{2^i}}\right \rfloor =1 $$
I am not sure on how to separate the floor to solve for $i$
$\lfloor x \rfloor = 1$ if and only if $1 \le x < 2$. Thus you want $2^i \le n < 2^{i+1}$. Take base-$2$ logarithms of both sides, and you find $i = \lfloor \log_2(n) \rfloor$.
We can introduce a slack variable $\epsilon$: $$ 1 = \lfloor n / 2^i \rfloor = n/2^i - \epsilon \quad (\epsilon \in [0,1)) $$ Then $$ 1 + \epsilon = n / 2^i \iff \\ 2^i = n /(1+ \epsilon) \iff \\ i = \log_2(n/(1+\epsilon)) $$ This means $$ \log_2(n/2) < i \le \log_2(n) $$ You might want $i \in \mathbb{Z}$ as well (going by the name). Because we have $$ \log_2(n) - \log_2(n/2) = \log_2(n/(n/2)) = \log_2(2) = 1 $$ we can now go reverse and have $$ i = \log_2(n) - \epsilon' = \lfloor \log_2(n) \rfloor \quad (\epsilon' \in [0,1)) $$