3

Does the following have a closed formula?

$$\sum_{i=1}^{k-1}\left\lceil \log_2\frac{N}{i}\right\rceil$$

  • k and N are different? Any relation, like k < N or something? – Wonder Jun 25 '14 at 13:56
  • BTW if you play around with the values a bit, you can see that for k = N this is roughly equal to $N \times \sum_{i=1}^{N}(log(1+1/i)/i)$. By the Taylor series this is roughly equal to $N \times \sum_{i=1}^{N}(1/i)^2$. So even for this case it is hard to give a simple closed form solution. – Wonder Jun 25 '14 at 14:06
  • Though I guess you can use the Basel formula to roughly say that this expression $\le N \times \pi^{2}/6$. Can be useful if you only want approximate values say in an algorithmic context. – Wonder Jun 25 '14 at 14:09
  • Does $\log$ refer to the natural logarithm or the common logarithm? – Yiyuan Lee Jun 25 '14 at 14:10
  • @Wonder - $k$ and $N$ are different and you may assume $k$ < $N$. – eli benayahu Jun 25 '14 at 14:29
  • @YiyuanLee - it's $log_2$, updated in the question, thanks. – eli benayahu Jun 25 '14 at 14:30
  • @Wonder - thanks for the approximation reference, unfortunately I'm trying to implement a memory efficient data structure and the summation is my formula for the bit-offset of the $k$-th item, so I need it to be exact. – eli benayahu Jun 25 '14 at 14:32
  • That's unfortunate, we could work around things a bit if $\sum_{i=i}^{N}(1/i)^2$ had a closed form (for example, k < N does not really bother us here - we could just find the sum till $k1 = N/floor(N/k)$ by the methods I have described and then add (k-k1)(log(N/k1)+1)), but as the function clearly grows like the expression of the Basel problem for large N, we can be reasonably sure of not having an exact answer. – Wonder Jun 25 '14 at 14:41
  • It is clearly contained between $\log_2\dfrac{N^{k-1}}{(k-1)!}$ and $\log_2\dfrac{(2N)^{k-1}}{(k-1)!}$ . If the relation between N and k is known, and one of them is large, use Stirling's approximation. – Lucian Jun 25 '14 at 15:06

1 Answers1

1

Let \begin{align*} S(k,N) &= \sum_{i=1}^{k-1}\left\lceil \log_2\frac{N}{i}\right\rceil \end{align*}

We can have a closed form for $S(N,N)$ which is: \begin{align*} S(N,N) &= 2^{\lceil\log_2N \rceil+1}-\lceil\log_2N \rceil-2 \end{align*}

and the sequence $S(N,N)-S(k,N)\; \; , k = N,N-1,N-2,\ldots, 3,2,1$ is A005187, which gives us interesting information.

gar
  • 4,948