1 Introduction

Let \(a,b \ge 1\) be integers, and let \(\mathbf{prim} (a)\) and \(\mathbf{prim} (b)\) be the sets of prime factors of a and b. If \(\mathbf{prim} (b) \subseteq \mathbf{prim} (a)\) there is an easily computable constant k that only depends on the exponents in the prime decompositions of a and b such that for any irrational number \(\alpha \) with \(0< \alpha < 1\) and any \(n \in \mathbb {N}\), the first n digits of the base-b expansion of \(\alpha \) can be obtained efficiently knowing only the first kn digits of the base-a expansion of \(\alpha \).

However, if \(\mathbf{prim} (b) \nsubseteq \mathbf{prim} (a)\), there are irrational numbers whose base-a expansion can be computed efficiently (say, in polynomial time), but whose base-b expansion cannot. Early partial results go back to Specker [21] and Mostowski [16], while Lachlan [13] showed that the set of primitive recursive reals to base b are a subset of the primitive recursive reals to base a iff \(\mathbf{prim} (b) \subseteq \mathbf{prim} (a)\), a result recently extended by Kristiansen [12] to show that for each sufficiently large subrecursive class \(\mathcal {S}\), there are irrationals with base-a expansion computable in polynomial time, but whose base-b expansion is not \(\mathcal {S}\)-computable.

The above phenomena all concern non-uniform complexity in the sense that the complexity of expansions of single numbers are concerned. One can also study a uniform version where the complexity of Turing machines provided with a, b, and the base-a expansion of any irrational number from a well-behaved set must produce the digits of the base-b expansion without unbounded search. If good subrecursive bounds on such uniform conversion exists for some subset \(\mathcal {T}\) of the irrational numbers, it follows that numbers exhibiting the “wild” behaviour of [12, 13, 16, 21] cannot be elements of \(\mathcal {T}\).

This paper is devoted to proving that set \(\mathbb {R} \setminus (\mathbb {Q} \cup \mathcal {L})\) of irrational numbers that are not Liouville numbers is an example of such a set \(\mathcal {T}\)—and thus that any “wild” number must be Liouville. As almost all “naturally occurring” irrational numbers (algebraic numbers, \(\pi \), e, numbers with very slow-growing partial quotients, etc.) are not Liouville, this shows that “wild” differences in the computational complexity across integer bases is a somewhat artificial property of irrationals. We believe that some of the machinery we introduce to prove this result may be useful to reveal the connections between the computational complexity of expansions to integer bases and traditional number theory beyond what is already done in the literature (see, e.g. [3, 4, 8]).

1.1 Some Intuition

Converting a number from base a to base b is easy if the number of digits that need to be examined is limited—colloquially, if the “lookahead” is small. Consider a Turing machine converting an irrational number from base a to base b using the standard schoolbook algorithm. Write \(\langle x \rangle _{a}\) and \(\langle x \rangle _{b}\) for the base-a and base-b expansions of the irrational number x. To find the initial n digits \(v_1, \ldots , v_n \in \{0,\ldots ,b-1\}\) of \(\langle x \rangle _{b}\) amounts to finding a particular integer \(k = \sum _{i=1}^n v_i b^{n-i}\) such that \(kb^{-n}< x < (k+1)b^{-n}\); the standard schoolbook method of doing so is to write the rational number \(kb^{-n}\) in base a and compare the result to successive digits of the base-a expansion of x until a digit is found where the two sequences differ sufficiently. The number of digits that the machine needs to consider to find the nth digit of \(\langle x \rangle _{b}\) is bounded above by some integer s(n) where \(\vert x - k b^{-n} \vert \ge a^{-s(n)}\)—because, roughly, if the base-a expansions of x and \(k b^{-n}\) did not differ in the s(n)th digit, we would have \(\vert x - kb^{-n} \vert < a^{-s(n)}\). Hence, for efficient conversion from base a to base b, it is natural to consider real numbers x where the “lookahead” function s(n) does not grow too rapidly. Furthermore, as \(a^{-s(n)} = b^{-(\log a/\log b)s(n)}\), we can rewrite the above inequality as \(\vert x - k b^{-n} \vert \ge b^{-(\log a/\log b)s(n)}\), and it is thus natural to consider a subset of real numbers where the lookahead is not contingent on a, but efficient conversion to base b from any integer base is possible, in which case the criterion above naturally becomes \(\vert x - k b^{-n} \vert \ge b^{-t(n)}\) where the function t(n) should be independent of a (we call this criterion (bt)-sanity, see Sect. 3).

The reader should by now appreciate that the “lookahead” is a special case of the more general phenomenon of the convergence speed of rapidly converging sequences of rational approximations to x, that is, finding rational numbers p/q with \(\vert x - p/q \vert < g(q)\) where g is a rapidly decreasing function. Indeed, for base-a expansions q will always be a negative power of a, and we will always have \(p/q < x\) if p/q is a truncation of the base-a expansion of x. Thus, the study of finite truncations of base-a expansions is a limited special case of Diophantine approximation (see, e.g. [7]). Consider creating an irrational number x such that its base-a expansion is not efficiently computable; a typical first attempt would be to take a very rapidly growing function \(f : \mathbb {N} \longrightarrow \mathbb {N}\) such that f(n) is known to not be computable within appropriate bounds, and consider the irrational number \(x = \sum _{i=1}^\infty a^{-f(i)}\); this is essentially the same approach that Liouville used when defining Liouville’s constant \(\sum _{i=1}^\infty 10^{-i!}\) as the first irrational number explicitly proven to be transcendent [14]. It is thus not surprising that there should be strong connections between the wider class of Liouville numbers and the problem of converting between integer bases.

2 Preliminaries

We assume familiary with standard computability theory and basic complexity theory at the level of introductory textbooks (see, e.g. [2, 9, 20]). Familiarity with basic computable analysis (e.g., [11, 22]) will make the paper easier to read, but is not needed.

Notation. We write \(\mathbb {N}\) for the set of positive integers and \(\mathbb {Q}\) for the set of rationals. If \(f : \mathbb {N} \longrightarrow \mathbb {N}\) and \(j\ge 1\) is an integer, we write \(f^{\circ j}\) for the jth iterate of f, that is, \(f^{\circ 1}(n) = f(n)\) and \(f^{\circ j}(n) = f(f^{\circ (j-1)}(n))\) for all \(n \in \mathbb {N}\). We write \(\mathbf{poly} (n)\) for an unspecified polynomial in n. For \(a \in \mathbb {N}\), we write \(\varSigma _a = \{0,\ldots ,a-1\}\). We usually view \(\varSigma _a\) as an alphabet of a symbols and denote by \(\varSigma ^*\) the set of finite, possibly empty, strings over \(\varSigma \), by \(\varSigma ^+\) the set of finite non-empty string over \(\varSigma \), by \(\varSigma ^\omega \) the set of right-infinite strings over \(\varSigma \), and set \(\varSigma ^{\le \omega } = \varSigma ^* \cup \varSigma ^{\omega }\). The binary representation of a is denoted by \(\mathtt {a}_{\text {bin}}\). The open interval of all reals between 0 and 1 is denoted by (0, 1), and if \(x \in (0,1)\) is a real number and \(a > 1\) is an integer, we denote by \(\langle x \rangle _{a}\) the greedy base-a expansion of x, that is \(\langle x \rangle _{a} = (e_n)_{n\in \mathbb {N}}\) where \(x = \sum _{i=1}^\infty e_i/a^i\) such that each \(e_i \in \{0,\ldots ,a-1\}\) and each successive \(e_i\) is chosen as large as possible. We write \(\langle x \rangle _{a}\vert _{\le n}\) for the length-n initial prefix of \(\langle x \rangle _{a}\), \(\langle x \rangle _{a}\vert _n\) for the nth element of \(\langle x \rangle _{a}\), and define \(k_{x,a,n} = \sum _{i=1}^{n} e_i a^{n-i}\), i.e. \(k_{x,a,n} \cdot a^{-n} = \sum _{i=1}^n e_i a^{-i}\), so \(k_{x,a,n} a^{-n}\) is the multiple of \(a^{-n}\) corresponding to the length-n prefix \(\langle x \rangle _{a}\vert _{\le n}\) of the base-a expansion of x.

Turing Machines and Conversion Between Bases. Let \(a \ge 2\) be an integer and \(f : \mathbb {N} \longrightarrow \{0,\ldots ,a-1\}\) be a map. A Turing machine M with input and output alphabet \(\{0,1\}\) is said to compute f if, for each positive integer n, M will, on input \(\mathtt {n}_{\text {bin}}\), output \(\mathtt {f(n)}_{\text {bin}}\). We assume that if x is a real number and is given as input to a Turing machine M, then (a binary encoding of the infinite sequence of elements of) \(\langle x \rangle _{a}\) is supplied to M on a particular input tape. All Turing machines considered in this paper will thus be (type-2) Turing machines: Let \(\varSigma \) be a finite alphabet with \(0,1 \in \varSigma \). A type-2 Turing machine M is a Turing machine with k read-only input tapes accepting infinite inputs (called \(\omega \)-tapes), m read-only input tapes accepting finite inputs, one (write-only, one-way) output tape and finitely many additional work tapes. Such a machine computes a partial function \(\phi _M : (\varSigma ^\omega )^k \times (\varSigma ^+)^m \rightharpoonup \varSigma ^*\) in the usual way (i.e., it has to reach a halting state in finite time, and the output is what is present on the output tape at that time). Time and space-complexity will throughout the paper be specified in terms of the content on the input tapes accepting finite inputs (if a Turing machine runs in time at most T(n), then it can examine at most the initial T(n) elements on the \(\omega \)-tapes). Note also that we will typically give the desired number of output symbols (e.g., the first n elements in \(\langle x \rangle _{b}\)) as input in binary \(\mathtt {n}_{\text {bin}}\), hence using at most \(1 + \lfloor \log n \rfloor \) bits, but time complexities will be specified as functions of n, not \(\mathtt {n}_{\text {bin}}\). We assume that both the input \(\omega \)-tapes and the output tape has binary alphabet. Thus, \(\langle x \rangle _{a}\) will be coded on the input as an infinite sequence of binary representations of elements of \(\{0,1\ldots ,a-1\}\) (each taking space \(1 + \lfloor \log a \rfloor )\); similarly, output in base b will be encoded as elements of \(\{0,\ldots ,b-1\}\) with each digit using \(1 + \lfloor \log b \rfloor \) bits of space.

Liouville Numbers. The irrationality measure of a real number x, denoted \(\mu (x)\), is the infimum of the set of positive reals \(\mu \) such that the inequality \(\vert x - p/q \vert < 1/q^\mu \) has only finitely many distinct solutions \((p,q) \in \mathbb {Z}\times \mathbb {N}\) (conversely, \(\mu (x)\) is the supremum of the set of positive reals such that the inequality has infinitely many distinct solutions).

A real number x is a Liouville number [14] if it is irrational and for every integer \(c \in \mathbb {N}\) there are integers p and q with \(q \ge 2\) such that \(\vert x - p/q \vert < q^{-c}\). We denote the set of Liouville numbers by \(\mathcal {L}\). Hence, \(\mathcal {L}\) is the set of reals having infinite (recall that \(\inf \emptyset = \infty \) by convention) irrationality measure.

An Ancillary Result. The multiple of \(b^{-n}\) that best approximates x is either \(k_{x,b,n}\) or \(k_{x,b,n} + 1\). We state this straightforward result explicitly as we shall refer to it several times:

Proposition 1

Let \(x \in (0,1)\) be irrational. Then, for all integers \(b \ge 2\) and \(n \ge 1\), we have \(k_{x,b,n}b^{-n}< x < (k_{x,b,n} + 1) b^{-n}\), and either (i) \(\forall k \in \mathbb {Z} . \vert x - k_{x,b,n} b^{-n} \vert \le \vert x - kb^{-n} \vert \), or (ii) \(\forall k \in \mathbb {Z} . \vert x - (k_{x,b,n}+1) b^{-n} \vert \le \vert x - kb^{-n}\vert \).

3 Rational Approximations and Sanity

The discussion in the paper’s introduction prompts the definition of sane numbers below.

Definition 1

Let \(x \in (0,1)\) be a real number, and \(b \ge 2\) an integer. Then, x is said to be: (bt)-sane if there is a non-decreasing and unbounded map \(t : \mathbb {N} \longrightarrow \mathbb {N}\) such that for all integers kn with \(n \ge 1\) we have \(\vert x - k\cdot b^{-n} \vert \ge b^{-t(n)}\). The map t is said to be a witness of (bt)-sanity of x. Furthermore, x is said to be uniformly sane if there exists a non-decreasing and unbounded map \(t : \mathbb {N} \longrightarrow \mathbb {N}\) such that x is (bt)-sane for all b. Again, t is said to be a witness of uniform sanity of x.

Sane numbers are irrational: If p/q is rational, then it has a finite base-q expansion, whence it cannot be q-sane witnessed by any unbounded map t.

Observe that for every irrational x and every b, there is a non-decreasing and unbounded function t such that x is (bt)-sane: for each \(n \in \mathbb {N}\), there is a \(k \in \mathbb {Z}\) such that \(\vert x - kb^{-n} \vert \) is minimal. Let \(k'\) be such a k, define \(d_n = \lceil - (\log \vert x - k'b^{-n} \vert )/\log b \rceil \), and define \(t(1) = d_1\), and \(t(n) = \max \{d_n,t(n-1)\}\) for \(n > 1\). Note that this t is unbounded as x is irrational.

If there is no slow-growing function t such that x is (bt)-sane, then–intuitively–bounding x away from very good rational approximations is difficult, and hence converting between bases may require large lookahead. As every irrational x is \((b,t_b)\)-sane for at least one function \(t_b\) depending on b (and x), it is natural to consider the function \(t' : \mathbb {N} \times \mathbb {N} \longrightarrow \mathbb {N}\) such that \(t'(b,n) = t_b(n)\). Having small lookahead in all bases b then intuitively corresponds to the function \(t'\) not growing too fast in either of its arguments.

Proposition 2

Let \(x \in (0,1)\) be irrational. If \(b \ge 2\) is an integer and \(t : \mathbb {N} \longrightarrow \mathbb {N}\) is a non-decreasing and unbounded map such that for all but finitely many integer pairs (kn) with \(n \ge 1\) we have \(\vert x - k\cdot b^{-n} \vert \ge b^{-t(n)}\), then there exists an \(e_x\) (which may depend on x) such that x is \((b,n \mapsto e_x t(n))\)-sane.

To show that the growth rate of the functions witnessing sanity actually matters, we now prove existence of a real number the sanity of which can be witnessed by a fast-growing function, but not witnessed by functions that grow slightly more slowly.

Proposition 3

Let \(b \ge 2\) be an integer. Furthermore, let \(t : \mathbb {N} \longrightarrow \mathbb {N}\) be a map such that \(t(1) \ge 3\) and \(t(n) - t(n-1) \ge n + 1\) for all \(n > 1\). Then, for any non-decreasing unbounded function \(s : \mathbb {N} \longrightarrow \mathbb {N}\) such that \(s(n) > t(n)\), the number \(x = \sum _{j=1}^\infty b^{-t^{\circ j}(1)}\) is (bs)-sane. However, if \(u : \mathbb {N} \longrightarrow \mathbb {N}\) is any function such that \(u(n) < t(n)\) for all sufficiently large n, then x is not (bu)-sane.

Proof

First observe that x is irrational as \(\langle x \rangle _{b}\) is not finite. Observe also that the requirement \(t(n) - t(n-1) \ge n + 1\) for all \(n > 1\) entails that t is non-decreasing (in fact, strictly increasing) and unbounded. Furthermore, note that we must have \(t(t(n)) > t(n+1)\) for all \(n \ge 1\), because the fact that t is strictly increasing implies that \(t(t(n))> t(t(n) - t(n-1)) > t(n+1)\). Finally, note that as \(t(1) \ge 3\) and \(t(n) \ge t(n-1) + n + 1\) by assumption, it follows that \(t(n) \ge n + 1\) for all \(n \in \mathbb {N}\).

For ease of notation, write \(z_1 = t(1), z_2 = t(t(1)), \ldots , z_j = t^{\circ j}(1), \ldots \). As t is strictly increasing, \(\langle x \rangle _{b}\) has ones at positions \(z_1, z_2, \ldots , z_j, \ldots \), and zeros at all other positions. Observe, for \(j \ge 1\), that the number of zeros following the occurrence of 1 at position \(z_j\) is at least

$$ z_{j+1} - z_j - 1 = t(z_j) - z_j - 1 \ge z_j + 1 + t(z_j-1) - z_j - 1 = t(z_j-1) > z_j $$

For each n, let j be the largest integer such that \(z_j \le n < z_{j+1}\) (such a j exists because t is strictly increasing, so \(z_j< z_{j+1} < n\) is only possible for finitely many j). Then \(\langle x \rangle _{b}\) has zeros at all positions \(z_j+1, \ldots ,z_{j+1}-1\), and we thus have \(\vert x - k_{x,b,n} b^{-n}\vert = \vert x - k_{x,b,z_j} b^{-z_j} \vert \). But as \(\langle x \rangle _{b}\) also contains a 1 at position \(z_{j+1}\), we have

$$\begin{aligned} k_{x,n,z_j}b^{-z_j} + b^{-z_{j+1}} = k_{x,n,z_{j+1}}b^{-z_{j+1}} \end{aligned}$$
(1)

Now, by the above, and by Proposition 1, we have \(k_{x,n,z_j} b^{-z_j}< k_{x,n,z_{j+1}}b^{-z_{j+1}} < x\), and thus \(\vert x - k_{x,b,z_{j}} b^{-z_{j}} \vert \ge b^{-z_{j+1}}\). Therefore:

$$ \vert x - k_{x,b,n}b^{-n} \vert = \vert x - k_{x,b,z_j} b^{-z_j} \vert \ge b^{-z_{j+1}} = b^{-t(z_j)} \ge b^{-t(n)} > b^{-s(n)} $$

where the last inequality follows from the fact that t is strictly increasing and \(z_j \le n\). Hence, \(\vert x - k_{x,b,n} b^{-n} \vert \ge b^{-s(n)}\).

By Proposition 1, we have \(0 < x - k_{x,b,z_{j+1}} b^{-z_{j+1}}\), and thus:

figure a

Now, \(z_{j+1} \ge t(t(1)) \ge t(3) \ge 4\), and we thus have:

$$ z_{j+2} = t(z_{j+1}) \ge z_{j+1} + 1 + t(z_{j+1} - 1) \ge z_{j+1} + 1 + t(3) \ge z_{j+1} + 5 $$

Hence, \(b^{-z_{j+2}} \le b^{-z_{j+1} - 5}\), and thus:

figure b

where the first inequality in the second line above follows from the fact that \(n < z_{j+1}\) and thus \(b^{-n} \ge b \cdot b^{-z_{j+1}} \ge 2 b^{-z_{j+1}}\). By Proposition 1, either \(k_{x,b,n}\) or \(k_{x,b,n}+1\) is an integer that minimizes \(\vert x - d b^{-n} \vert \) among all \(d \in \mathbb {Z}\). Hence, for all \(k \in \mathbb {Z}\), we have \(\vert x - kb^{-n} \vert \ge b^{-s(n)}\), showing that x is (bs)-sane, as desired.

Now, pick any \(j \ge 1\) and set \(n = z_j\). Then by (1) above we have:

$$\begin{aligned} \vert x - k_{x,b,n} b^{-n}\vert&= x - (k_{x,b,z_{j+1}} b^{-z_{j+1}} - b^{-z_{j+1}})\\&= \vert x - k_{x,b,z_{j+1}} b^{-z_{j+1}} \vert + b^{-z_{j+1}}\\&< 2b^{-z_{j+1}} = 2b^{-t(z_j)} = 2b^{-t(n)} \\&\le b^{-t(n)+1} \end{aligned}$$

But by assumption we have \(u(n) < t(n)\) for all sufficiently large n, whence \(b^{-t(n) + 1} \le b^{-u(n)}\), and thus \(\vert x - k_{x,b,n} b^{-n}\vert < b^{-u(n)}\) for infinitely many n (because \(n = z_j\), and \(j \in \mathbb {N}\) was chosen arbitrary). Hence, x is not (bu)-sane.    \(\square \)

Functions t satisfying the assumptions of Proposition 3 are not hard to devise. For example, any polynomial \(n \mapsto 2 + n^q\) (for \(q \ge 2\)) satisfies the requirements.

Proposition 3 shows that, for each b, there is a hierarchy of (bt)-sane numbers for successively faster-growing functions t, and there are numbers that require arbitrarily fast-growing witnesses for (bt)-sanity. It is natural to conjecture that the same phenomena hold for uniform sanity, but–surprisingly–it turns out (see Lemma 2) not to be the case.

We have the following key lemma:

Lemma 1

A number \(x \in (0,1)\) is uniformly sane iff it is irrational and is not a Liouville number.

Proof

Proceed as follows:

  • Let x be uniformly sane witnessed by the map t. Then, for all integers bkn with \(b \ge 2\) and \(n \ge 1\), we have \(\vert x - kb^{-n} \vert \ge b^{-t(n)}\), in particular \(\vert x - k/b \vert \ge b^{-t(1)}\). By the comments after Definition 1, x is irrational. Assume, for contradiction, that \(x \in \mathcal {L}\). As t(1) is a positive integer, there are integers bk with \(b \ge 2\) such that \(\vert x - k/b \vert < b^{-t(1)}\), and we obtain the contradiction. Hence, \(x \notin \mathcal {L}\).

  • Let \(x \notin \mathcal {L}\cup \mathbb {Q}\). Assume, for contradiction, that x is not uniformly sane. Then for each \(c \in \mathbb {N}\), the map \(n \mapsto cn\) does not witness uniform sanity, whence there are integers \(b_c,k_c,n_c\) with \(b_c \ge 2\) and \(n_c \ge 1\) such that \(\vert x - k_cb_c^{-n_c} \vert < b_c^{-cn_c}\). Setting \(q = b_c^{n_c}\) and \(p = k_c\) we obtain \(\vert x - p/q \vert < q^{-c}\). As \(c \ge 1\) was arbitrary, \(x \in \mathcal {L}\), a contradiction. Hence, x is uniformly sane.

   \(\square \)

Let \(\mathcal {E}^2\) be the set of total functions on the naturals in the second level of the Grzegorczyk hierarchy. A real number x is said to be \(\mathcal {E}^2\)-irrational if there is \(f \in \mathcal {E}^2\) such that for all integers pq with \(q > 0\) we have \(\vert x - p/q \vert > 1/f(q)\). By a result of Georgiev, a real number is \(\mathcal {E}^2\)-irrational iff it is irrational and not a Liouville number [10]; thus, by Lemma 1, the set of uniformly sane numbers is exactly the set of \(\mathcal {E}^2\)-irrational numbers.

Lemma 1 has the surprising consequence that fast-growing functions \(t : \mathbb {N} \longrightarrow \mathbb {N}\) are never needed as witnesses for uniform sanity—uniform sanity can always be witnessed by a linear map:

Lemma 2

A number \(x \in (0,1)\) is uniformly sane iff uniform sanity can be witnessed by a map of the form \(t(n) = cn\), for some \(c \in \mathbb {N}\) such that \(c \ge \mu (x)\).

Furthermore, no function \(t(n) = cn\) with \(c < \mu (x)\) witnesses uniform sanity of x.

Proof

If uniform sanity is witnessed by a linear map, then obviously x is uniformly sane.

Conversely, assume that x is uniformly sane and, for contradiction, that there is no map t of the form \(t(n) = cn\) that witnesses this. Then, for every \(c \in \mathbb {N}\) there are integers kbm with \(b \ge 2\) and \(m \ge 1\) such that \(\vert x - kb^{-m} \vert < b^{-cm} = (b^{m})^{-c}\). Set \(p = k\) and \(q = b^{m}\); thus, for each integer \(c \ge 1\), there are pq with \(q \ge 2\) such that \(\vert x - p/q \vert < q^{-c}\), whence \(x \in \mathcal {L}\), contradicting Lemma 1; hence, some map of the form \(t(n) = cn\) witnesses uniform sanity of x. Further assume, for contradiction, that \(c < \mu (x)\). Then, by uniform sanity, we have for all integers bkn with \(b \ge 2\) and \(n \ge 1\) that \(\vert x - k b^{-n} \vert \ge b^{-cn}\). Setting \(n=1\), we thus have for any real number d with \(c \le d \le \mu (x)\) and any integers pq with \(q \ge 2\) that \(\vert x - p/q \vert \ge q^{-c} \ge q^{-d} \ge q^{-\mu (x)}\). Thus, the inequality \(\vert x - p/q \vert < q^{-d}\) has only finitely many solutions in integers pq (namely the case \(q = 1\) where \(\vert x - p \vert < 1^{-c} = 1\) might have the solutions \(p=0\) or \(p=1\) as \(x \in (0,1)\)). Thus, as there are infinitely many d with \(c \le d < \mu (x)\), the number \(\mu (x)\) cannot be the supremum of the set of numbers d such that \(\vert x - p/q\vert < q^{-d}\) has infinitely many solutions in integers pq, a contradiction.    \(\square \)

We do not know whether it is always possible to choose \(n \mapsto \lceil \mu (x) \rceil n\) as a witness of uniform sanity.

Lemma 1 furnishes a method for proving that concrete real numbers are (uniformly) sane: the set of Liouville numbers is exactly the set of real numbers having irrationality measure infinity. Thus: if a real number has finite irrationality measure it is uniformly sane. By the Thue-Siegel-Roth theorem [18], all algebraic irrational numbers have irrationality measure 2 and are thus uniformly sane, as are numbers with continued fractions whose partial quotients grow very slowly as o(n), for example e. Further examples of specific uniformly sane numbers can be found where finite upper bounds on their irrationality measure have been proven. For example, \(\pi \) (the first bound by Mahler, \(\mu (\pi ) \le 30\) [15], has been improved on many occasions; at the time of writing, the best known bound is \(\mu (\pi ) \le 7.60630852\cdots \) [19]), and Apéry’s constant [1]. Similarly, all Martin-Löf random reals are not Liouville [8], hence are uniformly sane. Lemma 1 also implies that almost all real numbers are uniformly sane: By standard results, the set of Liouville numbers has Lebesgue measure zero [17] (and has Hausdorff dimension zero, hence d-dimensional Hausdorff measure zero for all positive integers \(d > 0\) [17]). Likewise, the set of uniformly sane numbers is a \(G_\delta \)-set, hence co-meagre.

3.1 A Digression: Normal Numbers

Recall that a real number x is b-normal [5] if every string of symbols \(s \in \{0,\ldots ,b-1\}^+\) occurs in \(\langle x \rangle _{b}\) with limiting frequency \(b^{-\vert s \vert }\), and b-simply normal if every element of \(\{0,\ldots ,b-1\}\) occurs in \(\langle x \rangle _{b}\) with limiting frequency 1/b. Clearly, a b-normal number is b-simply normal. We have:

Proposition 4

Let \(x \in (0,1)\) be irrational and let \(b \ge 2\) be an integer. If x is b-simply normal, then there is \(c_x \in \mathbb {N}\) such that x is \((b,n \mapsto c_x n)\)-sane.

Recall also that x is said to be absolutely normal if it is b-normal for every \(b \ge 2\). Proposition 4 yields the following corollary:

Corollary 1

For any absolutely normal number \(x \in (0,1)\) and any integer \(b \ge 2\), there is \(c_{b,x} \in \mathbb {N}\) such that x is \((b,n \mapsto c_{b,x}n)\)-sane.

By a result of Bugeaud [6] there are uncountably many absolutely normal Liouville numbers, hence, by Lemma 1 there are uncountably many absolutely normal numbers that are not uniformly sane. By Corollary 1 each of these normal numbers are \((b,n \mapsto c_{b,x} n)\)-sane for each b with some constant \(c_{b,x}\) dependent on b and x. However, for each absolutely normal Liouville number, the sequence \(c_{2,x}, c_{3,x}, \ldots \) must grow unboundedly as otherwise the numbers would be uniformly sane. Examples of computable absolutely normal Liouville numbers can be found in [4]. Another consequence of Proposition 4 is that every b-normal number has a very tame witness for sanity—and that numbers requiring fast-growing witnesses (such as the ones constructed in Proposition 3) cannot be b-normal for any b.

4 Uniform Conversion with Subrecursive Overhead Between Arbitrary Integer Bases

The following theorem shows that sanity implies that changing bases can be done without using unbounded search, indeed polynomial-time overhead is sufficient:

Theorem 1

There is a (type-2) Turing machine M and a polynomial P with positive integer coefficients satisfying the following:

For any integers \(a,b \ge 2\), any non-decreasing and unbounded \(t : \mathbb {N} \longrightarrow \mathbb {N}\), any (bt)-sane number \(x \in (0,1)\), and any \(n \in \mathbb {N}\), M will on input \(\mathtt {a}_{\text {bin}}\), \(\mathtt {b}_{\text {bin}}\), \(\mathtt {n}_{\text {bin}}\), and \(\langle x \rangle _{a}\) (on an \(\omega \)-tape) output \(\langle x \rangle _{b}\vert _{\le n}\) in time \(T(a,b,x)(n) \le P(t(n)\log (\max \{a,b\}))\).

Proof

The proof is essentially just an application of the schoolbook algorithm for changing the base of an irrational number. We first describe M and subsequently bound its running time.

(Start of Description of M)

M works in n stages, with each stage outputting the next digit of \(\langle x \rangle _{b}\) until the entire sequence \(\langle x \rangle _{b}\vert _{\le n}\) has been output. For \(1 \le i \le n\), at the beginning of the ith stage, M has on its work tapes the (binary representations of) (i) i, (ii) the string \(\langle x \rangle _{b}\vert _{\le i-1} = s_1 \cdots s_{i-1}\) of the first \(i-1\) digits of \(\langle x \rangle _{b}\), and (iii) the number \(z_{i-1} = s_1 b^{-1} + \cdots s_{i-1} b^{-(i-1)} = k_{x,b,i-1}b^{-(i-1)}\) in base b. Initially, \(i=0\), and \(\langle x \rangle _{b}\vert _{\le 0} = \epsilon \), and \(z_0 = 0\).

In stage i, M finds the ith digit, \(s_i = \langle x \rangle _{b}\vert _i\), as follows: M uses binary search in \(\{0,\ldots ,b-1\}\) to find the largest \(s \in \{0,\ldots ,b-1\}\) such that

$$ z_{i-1} + sb^{-i} = s_1 b^{-1} + \cdots + s_{i-1} b^{-(i-1)} + s b^{-i} < x $$

By definition, the largest such s is \(s_i = \langle x \rangle _{b}\vert _i\), and M increments i and sets \(\langle x \rangle _{b}\vert _{\le i} = \langle x \rangle _{b}\vert _{\le i-1} s\) and \(z_i = z_{i-1} + sb^{-i}\).

For each s, checking whether \(z_{i-1} + sb^{-i} < x\) is done by inspecting sufficiently many digits of \(\langle x \rangle _{a}\). For ease of notation, define \(r = \lceil (\log b)/(\log a)\rceil t(i)\). As x is (bt)-sane, we have \(\vert x - kb^{-i}\vert \ge b^{-t(i)} = a^{-\frac{t(i) \log b}{\log a}}\) for all integers k, so in particular for the number

$$ z_i + s b^{-i} = k_{x,b,i-1}b^{-(i-1)} + sb^{-i} = (bk_{x,b,i-1} + s)b^{-i} $$

we have:

$$ \vert x - (z_i + sb^{-i}) \vert = \vert x - (bk_{x,b,i-1} + s)b^{-i}\vert \ge a^{-\frac{t(i) \log b}{\log a}} \ge a^{-r} $$

By Proposition 1 we have:

$$ x - a^{-r}< k_{x,a,r} a^{-r}< x< (k_{x,a,r} + 1) a^{-r} < x + a^{-r} $$

and thus we have either

$$\begin{aligned} z_i + sb^{-i} < k_{x,a,r} a^{-r} \end{aligned}$$
(2)

or

$$\begin{aligned} z_i + sb^{-i} > (k_{x,a,r} + 1) a^{-r} \end{aligned}$$
(3)

Clearly, if (2) holds, \(s_i = \langle x \rangle _{b}\vert _i \ge s\), and if (3) holds, \(s_i = \langle x \rangle _{b}\vert _i < s\). Thus, M needs only scan the initial r base-a elements of \(\langle x \rangle _{a}\) (and compute the rational numbers above) to compute \(\langle x \rangle _{b}\vert _i\); each of these elements are representable in at most \((1 + \lfloor a \rfloor )\) bits, hence can be read in time \(O(r \log a) = \mathbf{poly} (t(i)\log (\max \{a,b\}))\). Observe that M does not need to know t or even compute r: it can simply compute \(z_o + sb^{-i}\) and then brute-force scan enough digits of \(\langle x \rangle _{a}\) until either (2) or (3) holds.

(End of Description of M)

By the above it is clear that M does not use unbounded search to output \(\langle x \rangle _{b}\vert _{\le n}\), and indeed the search in \(\langle x \rangle _{a}\) is limited to the r initial symbols of it, whence subrecursive conversion is obviously possible. We now show that the conversion is indeed efficient by establishing the existence of the polynomial P.

Time Use of M: In stage i, all computations are performed on integer arguments smaller than \(\max \{b^{i},a^{r}\}\), or on rational numbers p/q where \(p,q \le \max \{b^{i},a^{r}\}\). All exponentiation involves only computing powers of a and b, respectively, and all exponents involve negative powers of magnitude at most \(\max \{i,r\}\); by repeated squaring each power can be computed in time at most:

$$ \mathbf{poly} (\max \{i,r\}\log (\max \{a,b\})) = \mathbf{poly} (t(i) \log (\max \{a,b\})) $$

Apart from squaring, all multiplications and divisions involve at most two numbers, and by schoolbook arithmetic are thus computable in time polynomial in the logarithm of the largest integer involved, hence in time at most:

$$ \mathbf{poly} (\log (\max \{b^{i},a^{r}\}) = \mathbf{poly} (t(i)\log (\max \{a,b\})) $$

The remaining arithmetical operations are sums of at most \(\max \{i,r\}\) rational numbers with numerators and denominators that are positive integers bounded above by \(\max \{b^i,r\}\). By schoolbook arithmetic, this can be done in time at most:

$$ \max \{i,r\} \cdot \mathbf{poly} (\log (\max \{b^{i},a^{r}\}) = \mathbf{poly} (t(i)\log (\max \{a,b\})) $$

As there are n stages \(0,\ldots ,i, \ldots ,n\), and each stage–by the above analysis–takes time at most \(\mathbf{poly} (t(i)\log (\max \{a,b\}))\), the total time use of M to print \(\langle x \rangle _{b}\vert _{\le n}\) is at most \(O(n\mathbf{poly} (t(n)\log (\max \{a,b\}))) = \mathbf{poly} (t(n)\log (\max \{a,b\}))\), as desired.

   \(\square \)

Observe in Theorem 1 that the polynomial P is independent of x, a, and b. However t(n) will in general depend on both b and x. If we consider a class of reals for which t(n) is bounded above by a slow-growing function, we can obtain stronger results, to wit the following theorem for numbers that are not Liouville:

Theorem 2

There is a Turing machine M and a polynomial P with the following property: For any \(x \in (0,1) \setminus (\mathbb {Q} \cup \mathcal {L})\), there exists \(m_x \in \mathbb {N}\) such that for all integers \(a,b \ge 2\) and \(n \in \mathbb {N}\), M will on input \(\mathtt {a}_{\text {bin}}\), \(\mathtt {b}_{\text {bin}}\), \(\mathtt {n}_{\text {bin}}\), and \(\langle x \rangle _{a}\) (on an \(\omega \)-tape) output \(\langle x \rangle _{b}\vert _{\le n}\) in time \(T(a,b,x)(n) \le m_x \cdot P(n \log (\max \{a,b\}))\).

Proof

Let M and P be the Turing machine and polynomial of Theorem 1. By Lemma 1, every \(x \in (0,1) \setminus (\mathbb {Q} \cup \mathcal {L})\) is uniformly sane, and by Lemma 2, uniform sanity is witnessed by some function \(t(n) = c_x n\) for some \(c_x \in \mathbb {N}\) that depends on x. By Theorem 1, M outputs \(\langle x \rangle _{b}\vert _{\le n}\) in time at most \(P(c_x n \log (\max \{a,b\})) \le c_x^d \cdot P(n \log (\max \{a,b\}))\) (for some \(d \in \mathbb {N}\)). Setting \(m_x = c_x^d\) now furnishes the result.    \(\square \)

Inspection of the proof of Theorem 1 reveals that the Turing machine M reads at most \(r = \lceil (\log b)/(\log a)\rceil t(n)\) base-a symbols of \(\langle x \rangle _{a}\), and thus for a non-Liouville number x at most \(\lceil (\log b)/(\log a)\rceil c_x n\) base-a symbols for some \(c_x \ge \mu (x)\). If we fix x, we can absorb the constant \(m_x\) in Theorem 2 into the polynomial characterising the running time, and we obtain the following:

Corollary 2

Let \(x \in (0,1) \setminus (\mathbb {Q} \cup \mathcal {L})\). There is a polynomial R such that if \(a,b \ge 2\), and \(\langle x \rangle _{a}\vert _{\le n}\) is computable in time at most T(n) for all n, then there is a constant \(c_x\) such that \(\langle x \rangle _{b}\vert _{\le n}\) is computable in time at most \(R(T(c_x n))\) for all n.

Thus in particular, every real number x where finite prefixes of \(\langle x \rangle _{a}\) can be computed in polynomial time in n, but the finite prefixes of \(\langle x \rangle _{b}\) cannot, must be a Liouville number.

5 Future Work

This paper has concerned the connection between Liouville numbers and the construction of real numbers with great disparity in the computational complexity needed to compute their expansion in different bases, and more generally the computational complexity needed to obtain “good” rational approximations to irrationals—indeed, the notion of expansion to integer bases is an example of a very particular kind of approximation, but we expect the results of this paper to hold, mutatis mutandis for other approximations with rationals as well. Furthermore, the set of Liouville numbers is almost certainly an over-approximation of the set of “poorly behaved” irrationals where conversion with polynomial overhead is not in general possible; it is interesting to pinpoint a proper subset of the Liouville numbers—hopefully connected to existing areas of number theory—that precisely contain those numbers having egregious differences in the complexity of their various integer base expansions.