0

So I came across this fact in an algorithm that uses

Every real $x\in [1,2]$ can be written as infinite product $\displaystyle\prod_{k=1}^\infty(1+b_k2^{-k})$ with $b_k \in\{0, 1\}$

The representation is not unique in general, as can be seen in the following plot, where the $x$-coordinate is according to the mapping $$ x:\quad\{b_k\}_1^\infty ~ \mapsto ~ \sum_{k=1}^\infty b_k 2^{-k} ~ \in[1,2] $$ Plot of product against x(b) So the image does not have any obvious holes.

One way to compute $b_k$'s is by means of the following greedy algorithm; but why does this work?

INPUT x in [1, 2]
OUTPUT { bk }
k ← 0
LOOP
    k ← k + 1
    z ← 1 + 2−k
    IF x ≥ z THEN
        x ← x / z
        bk ← 1
    ELSE
        bk ← 0
    END IF
END LOOP

Note 1

The values that can be represented are actually in a larger interval $x\in[1,x_\text{max}]$ with $$ x_\text{max} = \prod_{k=1}^\infty (1+2^{-k}) = \frac{\sqrt[24]{2m}}{\sqrt[6]2\, \sqrt[12]{1-m}} \approx 2.38 $$ where $m$ is the inverse elliptic nome of $1/2$. I found this on a page of Uni Bonn, section "q - Products".

1 Answers1

2

Here is a more general result:

Theorem. Suppose $\{a_k\}_{k=0}^{\infty} \subseteq \mathbb{R}$ is a sequence of positive reals that converges to $0$ and satisfies $a_{k+1} \geq \frac{1}{2}a_k$ for all $k$. Let $M = \sum_{k=0}^{\infty} a_k$. Then every $x \in [0, M]$ can be written as $$ x = \sum_{k=0}^{\infty} b_k a_k $$ for some sequence $\{b_k\}_{k=0}^{\infty}$ with $b_k \in \{0,1\}$. Moreover, one such $\{b_k\}_{k=0}^{\infty}$ can be constructed by the following greedy algorithm:

def compute_b(x):
    s = 0
    b = []
    for k in range(inf):
        b[k] = 1 if (s + a[k] <= x) else 0
        s += b[k] * a[k]
return b

This theorem is related to OP's problem by noting that

  1. $a_k = \log(1 + 2^{-(k+1)})$ satisfies all the assumptions of the above theorem. (Hint: Use the concavity of $x \mapsto \log(1+x)$ to show $\log(1+\frac{1}{2}x) \geq \frac{1}{2}\log(1+x)$.)

  2. $\log [\prod_{k=1}^{\infty} (1 + b_k 2^{-k})] = \sum_{k=1}^{\infty} b_k \log(1 + 2^{-k})$ whenever $b_k \in \{0, 1\}$.


Proof of Theorem. We claim that the sequence $\{b_k\}_{k=0}^{\infty}$ returned by the greedy algorithm works.

Case 1. If $x = M$, then the algorithm clearly yields $b_k = 1$ for all $k$.

Case 2. Assume $x < M$. By the construction, $\sum_{k=0}^{N} b_k a_k \leq x$ for all $N$, hence $\sum_{k=0}^{\infty} b_k a_k \leq x$. In order to prove the equality, assume otherwise that $\sum_{k=0}^{\infty} b_k a_k < x$.

  • There are at most finitely many zeros in $\{b_k\}_{k=0}^{\infty}$. Indeed, let $\varepsilon = x - \sum_{k=0}^{\infty} b_k a_k$, and pick $N$ such that $a_k \leq \varepsilon$ whenever $k \geq N$. Then for any $n \geq N$, $$ \sum_{k=0}^{n-1} b_k a_k + a_n \leq \left( \sum_{k=0}^{\infty} b_k a_k \right) + \varepsilon = x$$ and hence the algorithm must yield $b_n = 1$.

  • Since $x < M$, not all $b_k$'s are $1$. From this and the observation above, we know that there exists a largest $N$ for which $b_N = 0$. Then \begin{align*} x > \sum_{k=0}^{\infty} b_k a_k &= \left( \sum_{k=0}^{N-1} b_k a_k \right) + \left( \sum_{k=N+1}^{\infty} a_k \right) \\ &\geq \left( \sum_{k=0}^{N-1} b_k a_k \right) + \left( \sum_{k=N+1}^{\infty} \frac{a_N}{2^{k-N}} \right) \\ &\geq \left( \sum_{k=0}^{N-1} b_k a_k \right) + a_N. \end{align*} This implies that the algorithm must have yielded $b_N = 1$, a contradiction! $\square$


Remark. The assumption $a_{k+1} \geq \frac{1}{2}a_k$ cannot be dropped, as in the case of $a_k = d^{-k}$ with $d > 2$. In this case, the set of all values of the form $\sum_{k=0}^{\infty} b_k d^{-k}$ with $b_k \in \{0,1\}$ is a Cantor-like set of measure-zero.

Sangchul Lee
  • 181,930
  • Thank you for the detailed answer. Do you know who proved the result from the question first? As fas as I know, it was used to compute logarithms for log tables, so should be several hundreds years old. – emacs drives me nuts Oct 07 '23 at 19:38