---
author:
- 
bibliography:
- 'ConstantRecognition.bib'
title: Criteria for the numerical constant recognition
---

[Introduction]{}

Experimental mathematics become very important nowadays [@BorweinBailey]. Using modern computers we are able to perform sequential brute-force searches of various mathematical objects and models at stunning scale. Multi-core processors [@epyc], GPUs, vectorization, FPGA and future quantum computers allow us to reach depths incomprehensible by humans. In essence, this is some form of artificial intelligence [@Eurega], because obtained results are indistinguishable from those provided by reasoning or more sophisticated algorithms [@SR]. Particularly interesting problem is a numerical constant recognition [@plouffe]. We are given decimal expansion, and ask if there is equivalent formula? There is strong demand from users of mathematical software to provide such a feature (identify/Maple [@Maple], nsimplify/SymPy [@symPy], RIES [@RIES], FindFormula [@Mathematica] ). In typical situation we encounter some decimal number, resulting from numerical simulation or experiment, e.g: 1.82263, and ask ourselves if it is equivalent to some symbolic expression, like e.g: $\sqrt{2}^{\sqrt{3}}$. Unfortunately, such a problem without additional constraints is ill-posed, and provided ”answers” nonsense. Often ridiculously complicated [@ISCwayback]. This is not a surprise, as Cardinality of real/complex transcendental numbers is uncountably infinite (continuum $\mathfrak{c}$), while number of formulas and symbols is countable ($\aleph_0$). Therefore probability for randomly chosen real number to be equivalent to some formula is zero. We must therefore restrict to numbers with finite decimal expansion. This is also practical approach, due to widespread of floating-point hardware, with double precision [@double] being *de facto* standard. However, in this case we encounter infinity from the other side. Assuming floating-point constant is a truncated real number[^1], we can produce arbitrary number of formulas which numerically differ only at more distant decimal places: $1.8226300001, 1.8226300000009 ,1.822630000100017$ etc. Fortunately, one still can ask which one of these formulas has *lowest* Kolmogorov complexity [@complexity]. But to do this, we must specify ”programing language” first. This lead to the following formulation of the numerical constant recognition problem. Imagine a person with hand-held scientific calculator, who secretly push a sequence of buttons, and print out the decimal/numerical result. We ask: could this process be reversed? In other words, given numerical result, are we able to recover sequence of some particular calculator buttons? Since every meaningful combination of buttons is equivalent to some explicit, closed-form [@closed], mathematical formula, above thought experiment becomes practical formulation of the constant recognition problem. In real world implementation, human and calculator are replaced by a computer program[^2], increasing speed billion-fold. Mathematically, results which can be explicitly computed using hand-held scientific calculator are members of so-called $\exp-\log$ (EL) numbers [@chow]. Above formulation has many advantages over set-theoretic or decimal string matching approach. It is well-posed, tractable, and can be either answered:\
a) positively,\
b) in terms of probability, or\
c) falsified.\
This depend on both maximum length of button sequence (code length, Kolmogorov complexity), as well as precision of the numerical result. One could anticipate, that for high-precision numbers (arbitrary precision in particular) and short code length identification must be unambiguous. For intermediate case (double precision, unspecified code length) we expect to provide some probability measure for identification. For low-accuracy numbers (e.g. of experimental or Monte Carlo origin) failure seems inevitable. Article is devoted to quantify above considerations. Certain statistical criteria are presented for practical number identification. Hopefully, this will convince researchers, that constant recognition problem can be solved practically. Instead of software used mainly for recreational mathematics and random guessing, it could become reliable tool for numerical analysis and computer algebra systems.

Article is organized as follows. In Sect. \[ELnumbers\] we discuss simplified computer language (in replacement for physical scientific calculator) used to define Kolmogorov complexity of the formulas. In Sect. \[enum\] we discuss some practical issues regarding numerical implementation of the sequential formula generators. Then, we combine experience/knowledge of Sect. \[ELnumbers\] and \[enum\] to find properties and typical behavior of the constructed EL numbers. Sections \[Criterion1\]-\[Criterion3\] propose three criteria for number recognition: (1) instant error drop-off to machine epsilon instead statistically expected $e$-folding; exponential growth of number of formulas indicates failure of search (2) maximum likelihood formula in the view of statistical process (3) compression ratio of the decimal constant in terms of RPN calculator code.

[Elementary complex $\exp-\log$ numbers \[ELnumbers\]]{}

Our first task is to precisely define set of formulas/numbers we want to identify using decimal expansion. We restrict ourselves to explicit formulas [@chow] i.e. those computable using hand-held scientific calculator. We assume root-finding procedure is absent. Therefore, as notable exception, most of algebraic numbers are not in above class, because polynomials of the order 5 and larger are not explicitly solvable in general. To be specific, we consider any complex number created from:

1.  integers: $0,1,-1,2,-2, \ldots$

2.  rationals: $\frac{1}{2},\frac{1}{3}, \frac{3}{2}, \ldots$

3.  mathematical constants: $0, 1, 2, e,\pi, i, \phi, \ldots$

4.  addition/subtraction, multiplication/division, exponentiation/logarithm (arbitrary base)

5.  elementary functions of one variable:

    -   trigonometric: $\sin, \cos, \tan$

    -   inverse trigonometric (cyclometric): $\arcsin, \arccos, \arctan$

    -   hyperbolic: $\sinh, \cosh, \operatorname{arsinh}, \operatorname{arcosh}, \operatorname{tgh}, \operatorname{artgh}$

    -   $\sqrt{\quad}  \;, \; \lg_2 \; , \;  \ln \;, \; \exp$

    -   usually unnamed functions: $1/x, x+1, -x, x^2, 2x, x^x \ldots$

6.  function composition

The choice of complex instead of real field is justified by mathematical simplicity. In practical numerical implementation it might be sub-optimal, due to reduced numerical performance and still missing implementation of some elementary functions (e.g: `clog2`) in standard libraries [@glibc]. Last item in the above list, function composition, is important for completeness. E.g: $\ln{(\ln{(\ln{x})})}$ is well-defined elementary expression, although rarely used in practice. No special functions are used.

Particularly troublesome are sets of symbols related to integers and rationals, as they both are potentially infinite. Without proper handling enumeration quickly get stuck on rational approximations with large integer numerator/denominator. Therefore, we must restrict to some ”small” subset of them. Standard computer languages (C, C++, Fortran) use ”small” integers still too large from our point of view, e.g. 8-bit signed and unsigned ones. Complexity of numbers 0, $2^{7}=128$, 188, …is identical using such an approach. The other extreme follows reductionist definition [@Tarski], staring from e.g: $-1$, and constructing all other integers as follows: $$1 = (-1) \times (-1), \; 0 = 1 + (-1), \; 2=1+1, \ldots$$ In calculators, ten digits are present: 0,1,2,3,4,5,6,7,8,9 and integers are entered in sequence using standard positional numeral system. RIES [@RIES] follow similar way, except for 0 and 1. Use of positional base-10 numerals is simple reflection of human anatomy/history, and difficult to include in our virtual calculator. Therefore we restrict to really small magnitude integers, $-1,0,1,2$ in particular. All other integers must be constructed from above four. Noteworthy, these integers are also among essential mathematical constants included in famous [@e] Euler formula: $$\label{euler}
e^{i \pi} + 1 = 0, \qquad e^{2 \pi i} - 1 = 0.$$ Two is also smallest possible integer base for logarithm $\log_2$. Binary system is now used in virtually all modern computer hardware.

The same reasoning applies to rationals. One might enumerate them using Cantor diagonal method, Stern-Brocot tree, or generate unambiguously by repeated composition[^3] of a function: $$\operatorname{next}(x) = \left(1 + 2 \lfloor x \rfloor -x  \right)^{-1},$$ starting from zero: $$0,1,\frac{1}{2},2,\frac{1}{3},\frac{3}{2},\frac{2}{3},3,\frac{1}{4},\frac{4}{3},\frac
   {3}{5},\frac{5}{2},\frac{2}{5}, \ldots$$ Usually the best is to leave language without explicit rationals, and let them appear by division of integers. Alternatively, addition of reciprocal $\operatorname{inv}(x) \equiv 1/x$ and successor $\operatorname{suc}(x) \equiv x+1$ functions allow for construction of continued fractions, see Appendix B in Supplemental Material.

Set of (named) mathematical constant certainly must include $e$, $\pi$, and $i = \sqrt{-1}$ due to , as long as we consider complex numbers. Besides this, some mathematicians consider other constants [@const] as ”important”, like first square roots ($\sqrt{2}, \sqrt{3}, \sqrt{5}$), golden ratio $\phi = (1+\sqrt{5})/2$ [@RIES], $\ln{2}$, $e^{1/e}$ and so on. Noteworthy, all of them are itself in $\exp-\log$ class, i.e., we can generate them from integers and elementary functions. They do not define any new numbers. Their inclusion only alter language definition and therefore Kolmogorov complexity. Other situation is with inclusion of mathematical constants of unknown status/memberships (unknown to be rational or transcendental), like Euler gamma $\gamma = 0.577216\ldots $ or Glaisher constant $A=1.28243\ldots$. They may, or may not, extend $\exp-\log$ class. This is itself an application for constant recognition.

Commutative operations like addition and multiplication are in general $n$-ary. To simulate calculator behavior we must treat them as repeated binary operations: $$x+y+z = (x+y) + z.$$

Elementary functions are not independent, e.g: $$\sinh{x} = \frac{e^x - e^{-x}}{2}, \tan{x} = \frac{\sin{x}}{\cos{x}}.$$ Scientific calculators sometimes distinguish less important, secondary functions which require pressing two buttons. But mathematically they are completely equivalent. You can compute $\sinh, \cosh$ using $\exp$, or *vice versa*. This is especially true in complex domain, where all elementary functions are reducible to $\exp$ and $\ln$.

Reduction is possible for binary operations as well, e.g: $$x \times y = e^{\ln{x} + \ln{y}}, \quad   x \cdot y = \log_x{\left[ (x^y)^x \right] }.$$ Replacing multiplication by logarithms and addition is an achievement of medieval mathematics [@briggs] used without changes for 300 years. It was replaced with slide rule used in XX century. They both went extinct with modern computers. However, we point out, that using logarithms and addition you can not only do bottom-up translation to multiplication/exponentiation. You might go opposite way as well, from high-rank (grade) hyper-operation down do additions. Expressing addition/multiplication by exponentiation/logarithms only (up-bottom) is therefore possible, but tricky, see Appendix C in Supplemental Material.

Taking above considerations into account, important question arises: how many constants, functions and binary operations are required for our virtual calculator to be still fully operational? How far reduction process can go, without impairing our computational abilities? This is also known as ,,broken calculator problem” [@RIES]. Another related question is, if such a reduced calculator is optimal for the task of constant recognition. Obviously, maximally reduced button set makes theoretical and statistical analysis convenient, therefore it is very useful as mathematical model. In practice, as we will show later, Kolmogorov complexity of formulas in maximally reduced language, which are considered as simple by humans, might become surprisingly large. On the contrary, formulas *simple* in reduced operation set, like nested power-towers, look inhuman, and are out of scope traditional mathematical aesthetics, despite small Kolmogorov complexity.

The simplest possible language we found has a length three ($n=3$). It is still able to perform all operations of the scientific calculator. It includes:

\[base-3\] $$\begin{aligned}
\label{e}
\text{either} & \qquad e \quad  \text{or}  \quad \pi. \end{aligned}$$ $$\begin{aligned}
\text{binary exponentiation} & \qquad x^y,\end{aligned}$$ $$\begin{aligned}
\text{arbitrary base (two-argument) logarithm} &\qquad  \log_x{y}.\end{aligned}$$

Another very simple language of length four is:

\[base-4\] $$\begin{aligned}
\text{any constant}& \qquad x.\end{aligned}$$ $$\begin{aligned}
\label{e1}
\text{natural exponential function}& \qquad \exp{x}  \equiv e^x,\end{aligned}$$ $$\begin{aligned}
\label{e2}
\text{natural logarithm}& \qquad \ln{x}  \equiv \log_e{x},\end{aligned}$$ $$\begin{aligned}
\text{subtraction}& \qquad x-y.\end{aligned}$$

Detailed proofs by exhaustion are presented in Appendices C,D in Supplemental Material. Above two examples clearly justify name $\exp-\log$ for class of explicit elementary numbers discussed in this section. We were unable to find any shorter languages. At least one (noncommutative?) binary operation seem required to start abstract syntax (AST) tree growth (see however Appendix B), and at least one constant to terminate leafs. One of the essential constants $e$ or $\pi$ probably also is required, either explicitly, like in , or hidden in function/operation definition (\[e1\],\[e2\]). But we cannot prove that further reduction to 2 buttons is impossible. We also cannot prove, that above language of length three is unique. Therefore, one cannot estimate Kolmogorov complexity of EL number unambigously. Existence of both smallest and unique language, generating all $\exp-\log$ numbers, would provide natural enumeration of mathematical formulas, similar to Peano arithmetic for natural numbers. Anyway, or are the sets of irreducible operations, for now. Calculator/language can be extended, but under no circumstances any of the buttons defined by or can be removed. Failure to abide by above requirement might result in catastrophic failure of the number recognition software even in the simplest test cases. This is plague of existing implementations, letting unaware end-users to choose base building blocks on their own. This leaves impression of random failures without any obvious reason. Users can use their own set of constants, functions and binary operations, but they must be merged with irreducible set or .

It is illustrative to compare and with *Mathematica* core language [@Mathematica], composed of:

\[mma\] $$\begin{aligned}
\text{addition (Plus)} & \qquad x+y,\end{aligned}$$ $$\begin{aligned}
\text{multiplication (Times)} & \qquad x \times y,\end{aligned}$$ $$\begin{aligned}
\text{exponentiation (Power)} & \qquad x^y,\end{aligned}$$ $$\begin{aligned}
\text{natural logarithm (Log)} &\qquad  \ln{x},\end{aligned}$$ $$\begin{aligned}
\text{mathematical constants (E, Pi, I)} \qquad e, \pi, i, \ldots\end{aligned}$$

augmented with arbitrarily large integers, including their complex combinations (Complex) and rationals (Rational). Visual comparison of , and is presented in Fig. \[BaseSet\].

![\[BaseSet\] Illustration of base constants, functions and binary operations used to define $\exp-\log$ number class. Irreducible set is labeled ”up-botton”, because it is based on highest rank complex (hyper-)operation currently implemented (exponentiation), while (bottom-up) starts with low-rank arithmetic (subtraction). *Mathematica* core language is included for comparison. All three sets allow generation of any explicit elementary transcendental constant in the EL class. Question mark symbolize unknown ”holy-grail” complex function, which could, if exists, by repeated composition, generate all $\exp-\log$ numbers in unique order. ](figs/BaseSet){width="50.00000%"}

Accounting for the above considerations, for further analysis we have selected four base sets (buttons) to attack the inverse calculator problem:

\[CALC\]

1.  `E`, `POW`, `LOG` \[$n=3$ buttons, eq.  \] $$\label{CALC1}$$

2.  `X`, `EXP`, `LN`, `-` \[$n=4$ buttons, eq. \] $$\label{CALC2}$$

3.  `Pi`, `E`, `I`, `-1`, `2`, `1/2`, `Log`, `Plus`, `Times`, `Power` \[$n=10$ buttons, eq.  \] $$\label{CALC3}$$

4.  full scale scientific calc \[$n=36$ buttons, see below\] $$\label{CALC4}$$

Calculator 1 (up-bottom), based on is the simplest found. It use one constant ($e\simeq 2.71828\ldots$, PUSH on stack operation), no functions, and only two non-commutative binary operations: arbitrary base logarithm $\log_x{y}$ and exponentiation $y^x$. Noteworthy, AST is a binary tree in case of .

Calculator 2 (bottom-up), based on is the second shortest, and have remarkable property: it can use any numerical constant/symbol $x$ to generate all other numbers. For example, $0 = x - x$, $1 = \exp{(0)}$, $e=\exp{(1)}$ and so on. We can use any of $x=0$, $x=-1$, $x=e$, $x=i$, $x=\phi$, …This property can be exploited in two applications: (1) use our calculator to operate on vectors, (2) use $x$ with large Kolmogorov complexity to ”shift” formula generator. The former can be used e.g. to take advantage of modern CPU AVX extensions, the latter to use $x$ as some form of random seed for enumeration procedure. This can be done extending any of calculators with $x$ as well, but only for it is visible *explicite* in definition. In presentation of results we used $x=2$.

Calculator 3 is designed to mimic *Mathematica* behavior. Constants beyond $\pi,e$ and $i$ were chosen as follows. To enable rapid integer generation via addition, multiplication and exponentiation we use -1 and 2. Incidentally, these numbers are also are initial values for Lucas numbers. Rational numbers are easily generated via continued fractions, thanks to $-1$ constant, allowing for construction of reciprocal $1/x \equiv x^{-1}$. Rational constant $1/2$ together with $i$ form trigonometric functions $e^{ix} = \cos{x} + i \sin{x}$ and square roots $\sqrt{x} = x^{1/2}$. Number of instructions equal to ten is selected intentionally. It will allow for instant estimate of the compression factor in Sect. \[Criterion3\]. Both target numerical constant and RPN calculator code can be expressed as string of base-10 digits `0123456789`, see next Sect. \[enum\].

Fourth calculator is the largest one. Maximum number of 36 buttons is limited by a current implementation of the fast `itoa` function used to convert string variables into base-36 numbers, i.e. alphanumeric lowercase digits and letters. It is the most close to what people usually expect from scientific hand-held device. Full list of buttons:

-   constants: $1,2,3,4,5,6,7,8,9,e,\pi,i,\phi$

-   functions:$\ln, \exp, \operatorname{inv}, \operatorname{minus}, \mathrm{sqrt}, \operatorname{sqr},$ $\sin, \arcsin, \cos, \arccos, \tan, \arctan,$ $\sinh, \operatorname{arsinh}, \cosh, \operatorname{arcosh}, \operatorname{tgh}, \operatorname{artgh},$

-   binary operations: $+, -, \times, / , y^x$.

”Full” calculator defined above use 13 constants, 18 functions of one variable, and 5 binary operations.

[Efficient formula enumeration \[enum\]]{}

Once calculator buttons, equivalent to some truncated computer language specification, are fixed, we face the next task: enumeration of all possible formulas. We exclude recursive implementation. While short and elegant, it quickly consumes available memory, and is hard to parallelize [@RIES]. For sequential generation, we notice that formulas are equivalent to set of all abstract syntax trees (AST) or valid reverse polish [@RPNorig] notation (RPN, [@RPN]) calculator codes. The former description has an advantage in case where efficient tree enumeration algorithm exists [@Knuth], e.g: binary trees [@tree]. Unfortunately, this is applicable only to the simplest calculator . Other mix binary and unary trees. Therefore, to handle variety of possible calculators, including future extension to genuine $n$-ary special functions (e.g: hypergeometric, Meijer G, Painleve transcendents) our method of choice is enumeration of RPN codes. This has two major advantages. First, enumeration is trivially provided by `itoa` function with base-$n$ numbers (including leading zeros), where $n$ is number of buttons. Second, while majority of enumerated codes is invalid, checking RPN syntax is very fast, almost negligible compared to `itoa` itself, let alone to computation of complex exponential and logarithmic functions. Procedure has two loops: outer for code length $K$, inner enumerating $n^K$ codes of length $K$. Inner loop is trivial to parallelize using OpenMP directives without effort, scaling linearly with number of physical cores. Moreover, hyper-threading is utilized as well, although scaling is only at quarter of core count. Therefore, prospects for high-utilization of modern high-end multi-core CPU’s [@epyc] are looking good. Digits are associated with RPN calculator buttons. For simplest case they are ternary base digits `012`, which were assigned to three RPN calculator buttons as: 0 $\to$ E ($e$), 1 $\to$ LOG ($\log_x{y}$), 2 $\to$ POW ($x^y$). Detailed example of the algorithm for is presented in Appendix A of Supplemental Material.

Combinatorial growth of the enumeration is characterized, in addition to Kolmogorov complexity (RPN code length) $K$, by a total number of possible codes tested so far $k_1$. It grows with $K$ as: $$k_1 = \sum_{K'=1}^{K} n^{K'} = \frac{n^K-1}{n-1} n.$$ Total number of syntactically correct codes $k_2$ and total number of *unique* numbers $k_3$ are additonal useful characterizations of the search depth. Obviously, $k_3 \leq k_2 \leq k_1$. For perfectly efficient enumeration $k_1=k_2=k_3$. Unfortunately, this is currently possible only for rational numbers, see Appendix B. Case $k_1=k_2$ is equivalent to knowledge of unique tree enumeration algorithm. To achieve $k_2=k_3$ ($p=1$ in Fig. \[k2k3\], dashed diagonal line) algorithm must magically somehow know in advance all possible mathematical simplifications. Not only those trivial, like $e^{ \ln{x} } = \ln{(e^x)}=x$ but anything mathematically imaginable, e.g, $2^{1-\ln{\ln{\pi}}} = 2 (\ln{\pi})^{-\ln{2}}$. We doubt this is possible at all. Some ideas, based on solved rational numbers enumeration, are presented in Appendix B. In practice, we achieved $k_3/k_2 = 0.59, 0.06, 0.08, 0.49$ for calculators 1-4 , respectively. Large $k_3/k_2$ ratio for is a result of very simple tree structure, in which only every nine-th odd-$K$ RPN codes are valid. Without taking this into account, $k_3/k_2=0.59/2/9 = 0.03$, i.e., the worst of four. Full calculator perform surprisingly well.

![\[k2k3\] Number of unique formulas $k_3$ *versus* number of valid codes $k_2$. Solid lines show $k_3 = {k_2}^p$ fits, with $p=0.96491, 0.826455, 0.848559, 0.948259$ for calculators 1-4, respectively. Dashed diagonal line shows perfect case $k_3=k_2$. ](figs/k2k3){width="50.00000%"}

[Quasi-convergence of enumerated formulas and constant recognition \[Criterion1\] ]{}

Enumerated formulas provide sequence of elementary transcendental $\exp-\log$ (EL) numbers. For they are, in order of increasing Kolmogorov complexity $K$: $$\begin{aligned}
\label{ELseq}
K=1&\qquad e,                    \\
K=2&\qquad \text{none},   \nonumber        \\ 
K=3&\qquad 1, e^e,        \nonumber         \\
K=4&\qquad \text{none},    \nonumber         \\
K=5&\qquad 0, 1/e, e^{e^e}, e^{e^2}, \nonumber \\
\ldots  \nonumber\end{aligned}$$ where repeated numbers were omitted. Position within the same level of $K$ is unspecified, but follows from presumed enumeration loop and base-$n$ digits association with buttons. From sequence we can extract subsequence of progressively better approximations for target number $z$, e.g., using example from the introduction, $z=1.8226346549662422143937682155941\ldots$. Analysis of sequences obtained this way is main goal of current section. We are interested in convergence properties and criteria for termination of sequence.

Let us assume for the moment, that we are able to provide on demand as many decimal digits for target number $z$ as required. There are two mutually exclusive possibilities: (i) number $z$ is in $\exp-\log$ class, defined e.g. by or , or (ii) $z$ is true non-elementary transcendental constant outside EL class. In the former case, we expect that error eventually, at some finite $K$, will drop to an infinitesimally small value, limited only by currently used precision. Search algorithm could then terminate and switch to some high-precision or symbolic algebra verification method. Unfortunately, equivalence problem is undecidable in general [@richardson]. One cannot exclude, that both numbers deviate at some far more distant decimal place. In the case of (ii) i.e. truly transcendental number, however, sequence will converge indefinitely, by generation of approximations, with progressively more complicated formulas. Realistic convergence examples, computed using extended precision (`long double` in C) to prevent round-off errors, are presented in Figure \[SmokingGun\]. The example target $z=\sqrt{2}^{\sqrt{3}}$ from introduction was selected. Number is obviously in $\exp-\log$ class. But is not *explicite* listed in any of , so it must be entered using appropriate sequence of buttons. For RPN calculator it is obvioulsy 2, SQRT, 3, SQRT, POW with $K=5$. In Fig. \[SmokingGun\] is is visible at $K=5.28$, where decimal part show inner loop progress.

![\[SmokingGun\] Typical behavior of absolute error $\epsilon$ for subsequence of progressively better approximations in terms of $\exp-\log$ formulas generated with ”calculators” , as a function of Kolmogorov complexity $K$. For we have used $x=2$. For (blue) and (black) sudden error drop-off to machine epsilon (zero) is observed for small $K$, marking possible ”exact” formula match. Calculations were done using extended precision (`long double` in C) while horizontal line mark machine epsilon for IEEE 754-2008 (binary64). ](figs/Convergence1){width="50.00000%"}

Two types of behavior can be observed in Fig. \[SmokingGun\]. Vertical absolute error $\epsilon$ scale is adjusted to range $\{ 2^{-63}, 1 \}$, i.e., `long double` machine epsilon for this and related Figs. \[Convergence2\], \[Convergence3\]. In typical situation absolute error $\epsilon$ for best approximation decreases exponentially with code length. However, if ”true” $\exp-\log$ formula is encountered, error instantly drops off to limiting value. In example from Fig. \[SmokingGun\] it is small multiple of machine epsilon for `long double` precision ($2^{-63}$) or binary zero.

Criterion directly based on Kolmogorov complexity is inconvenient, if one deals with languages of various size, like our calculators 1-4, eq. (\[CALC\]). Convergence rate also depends on language size $n$, cf. Fig. \[SmokingGun\]. One could use Kolmogorov complexity corrected for language size, or compile formulas generated in extended calculators or down to one of primitive forms given by or . The former approach usually underestimate, and the latter heavily overestimates true complexity. Therefore we propose another criterion, independent of the language used to generate formulas. Instead of plotting error as a function complexity, we plot $N$-th best approximation (Fig. \[Convergence2\]). Now all curves nearly overlap, and observed lower error limit is $\epsilon > e^{-N}$.

Above considerations provide the first criterion for constant identification:

Criterion 1:\
Identification candidate: *if absolute error $\epsilon$ in subsequence of progressively better approximations in terms of $\exp-\log$ formulas deviates ”significantly” from estimated upper limit $e^{-N}$ (drops to numerical ”zero”/machine epsilon in particular) we can stop search and return formula code, as possible identification candidate.*

Failure of search: *if absolute error in subsequence of progressively better approximations in terms of $\exp-\log$ formulas follow $e^{-N}$ and reach numerical precision limit, or computational resources are exhausted, search failed.*

Candidate code must be then verified using symbolic methods, high-precision numerical confirmation test, and ultimately proved using standard mathematical techniques. Above criterion do not provide any numerical estimate for probability of successful identification. However, we point out, that even in case of possible misidentification, unexpected drop of error to machine epsilon marks stop of the search anyway. This is because finding better approximation would require formula with complexity already above threshold, given by intersection of dotted lines in Fig. \[Convergence2\]. Beyond that, number of formulas with identical decimal expansion grows exponentially. This behavior mark search STOP criterion for cases, where ”smoking gun” feature from Fig. \[SmokingGun\] was not encountered. In practice this still require a lot of computational resources, beyond capabilities of mid-range PC/laptop. That is why curves in Figs. \[SmokingGun\]-\[Convergence3\] are still far from double epsilon, marked with `DBL_EPSILON` dotted line.

![\[Convergence2\] Similar to Fig. \[SmokingGun\], but $K$ has been replaced by number of subsequent best approximations $N$ found so far. This allows for direct comparison of languages of different length. Possible identification is marked by error for next approximation significantly below $e^{-N}$.](figs/Convergence2){width="50.00000%"}

Expected decrease of approximation error for next best one is $1/e \simeq 0.37$ of previous. Therefore, we use $e$-folding name for Criterion 1.

![\[Convergence3\] Similar to Fig. \[Convergence2\], but $N$ has been replaced by number $k_2$ of valid RPN codes tested so far. Power-law is observed, with $\epsilon \propto k_2^{-1}$. Upper axis show estimated by power-law fit $k_3 \simeq k_2^{0.83}$ number of *unique* formulas.](figs/Convergence3){width="50.00000%"}

Remarkable observation is provided by yet another Figure \[Convergence3\]. Instead of $K$ or $N$ we used total number $k_2$ of *valid* RPN codes tested before encountering next approximation. Power law behavior is found, and band of data points (Fig. \[Convergence3\]) can be roughly approximated as proportional to $1/k_2$. Therefore, obtaining definite negative answer for constant known with machine precision of $\sigma$ in terms of Criterion 1 require testing of $\sigma^{-1}$ codes. For double precision machine epsilon it is above $10^{15}$. You need either hundreds of CPU cores, or a lot of patience (days of search). Positive identification can be much faster, of course, like for calculators 3, 4 in Figures \[SmokingGun\], \[Convergence2\].

[Statistical properties of the $\exp-\log$ numbers \[Criterion2\] ]{}

Observation from Fig. \[Convergence3\] and results of previous section lead to another view of constant identification problem. It can be described as a random process. Consider following numerical *Monte Carlo* experiment. We generate pseudo-random numbers $\xi>0$ from exponential distribution with some scale $\lambda$ and Probability Distribution Function (PDF): $$\label{Pexp}
P(\xi) = \frac{e^{-\xi/\lambda}}{\lambda}.$$ Next, we compare $\xi$ with our target number $z>0$, and generate sequence of progressively better approximations. Surprisingly, observed behavior is similar to Fig. \[Convergence2\], but with larger fluctuations. Let’s further assume $z$ is known with numerical precision $\sigma < z$. In other words, true number is in the interval $[z-\sigma,z+\sigma]$. Assuming we can easily obtain probability of random hit into vicinity $z$: $$P(z,\sigma, \lambda) = \int_{z-\sigma}^{z+\sigma} P(\xi) \; d \xi$$ what gives average number of tries: $$k_2 = \frac{e^{z/ \lambda}}{2 \sinh{\sigma/\lambda}} \sim  \frac{const}{\sigma}.$$ Above agrees qualitatively with result presented in Fig. \[Convergence3\] if $\sigma \ll z$.

However, statistical distribution of $\exp-\log$ numbers is unknown, PDF was chosen intuitively. Statistical properties of EL numbers should not depend on on language used to generate them, at least in the limiting case of large complexity. Numerical evidence, obtained by collecting real numbers generated according to procedure presented in Sect. \[enum\], is presented in Fig. \[StatReals\]. Numbers with $\operatorname{Im}(z) \neq 0$ were discarded[^4] to simplify analysis and presentation.

![\[StatReals\] Histogram of first 20k real numbers generated with use of calculators 1-4. Dashed line show exponentially transformed Cauchy distribution . ](figs/StatReal){width="50.00000%"}

None of the widespread distributions match numbers presented in Fig. \[StatReals\]. The most close are: Pareto, Levy and Cauchy distributions. Noteworthy, all of them have undefined mean and infinite dispersion. If we look at statistics of base 10 logarithm, it mimic t-Student, Cauchy and Laplace (double $\exp$) distributions. Probably this is indeed a brand new statistics, following some empirical distribution. True distribution of real EL numbers (Fig. \[StatReals\]) is, however, quite well described by transformed Cauchy distribution with PDF: $$\label{cauchy}
P(x) = \frac{1}{\pi x} \frac{1}{1+(\ln{x})^2}.$$ Therefore, later, statistical distribution of (real) EL numbers will be approximated by Cauchy-like distribution .

Let us assume statistical distribution of real EL constants has PDF $P(x)$ empirically derived from histogram in Fig. \[StatReals\] or is given by . Let the target number $z$ is know with precision $\sigma$, and statistical distribution of error for $z \pm \sigma$ is $Q(x, z, \sigma)$. $Q$ might be normal or uniform distribution, for example. Then conditional probability $p_k$, that $k$-th tested formula **is not random** match for target value $z \pm \sigma$ is: $$\begin{aligned}
p_k =  \prod_{i=1}^k   \left( 1-  \frac{\int_{-\infty}^{\infty} P(\xi) Q(\xi) \; d \xi}{Q(z)} \right) = \\ \nonumber
=
\left( 1-  \frac{\int_{-\infty}^{\infty} P(\xi) Q(\xi) \; d \xi}{Q(z)} \right)^k.\end{aligned}$$

Then, replacing $P(\xi) \simeq P(z)$ and integrating, likelihood $\mathcal{L}$ for proper identification of target constant $z$ with i-th unique value $x_i$ is: $$\label{Id_likelihood}
\mathcal{L} = \left[ 1-   \frac{P(z)}{Q(z)} \right]^{k_3} Q(x_i, z, \sigma),$$ where $i=k_3$, i.e. number of unique values tested so far. To understand , it might be approximated by $$\label{Id_likelihood2}
\left( 1- \kappa \, \sigma \; P(z) \; k_3 \right) Q(x_i, z, \sigma),$$ assuming $\sigma \ll z$ and using Maclaurin expansion $(1+\alpha)^k \simeq 1 + \alpha k + \ldots$. Value of $\kappa$ depends on error distribution $Q$, e.g., $\kappa=2$ for uniform and $\kappa=\sqrt{2 \pi} \simeq 2.5$ for normal distribution.

Likelihood becomes zero for large $k_3$, where search for $k_3>1/\sigma$ is pointless anyway due to Criterion 1 (Sect. \[Criterion1\]). The most intriguing application of is when $\sigma$ is still large compared with machine epsilon, and has uncertainty of statistical nature. This allow for selection of maximum likelihood formula(s) in marginal sense, i.e. for $k_3 \sim \sigma^{-1}$. Because calculation of $k_3$ requires storage of all previously computed values, it is reasonable to replace it with $k_2$ using power-law fit from Fig. \[k2k3\]:

$$\label{Id_likelihood3}
\left[  1- \kappa \;  {k_2}^p \;  \sigma\;  P(z) \right] \times  Q(x_i, z, \sigma).$$

Noteworthy, as a function of $k_2$, i.e. number of tested syntactically correct RPN codes, must have a maximum. Formula for $x_i$ with maximum probability is well defined. For limited precision maximum is very pronounced (Fig. \[likelihood\]), but for very small $\sigma$ we might not be able to reach it at all, due to limited computational resources (e.g: Fig. \[likelihood\], solid blue). Equations (\[Id\_likelihood\]-\[Id\_likelihood3\]) can be understood as follows. If we find remarkably simple and elegant formula at the very beginning of the search, which is however quite far from target $z$, e.g., several $\sigma$’s in Gaussian distribution, we reject it on the basis of improbable error in measurement/calculation. Similarly, if we find formula well within error range, e.g. $4 \sigma$, but after search covering billions of formulas, we reject it expecting random coincidence. Somewhere in the middle lays optimal formula, with maximum likelihood, estimated with use of . In practice, likelihood is very small, and $\log$-likelihood is more convenient: $$\log \mathcal{L} = -k_3 \ln \left(1 -  \frac{P(z)}{Q(z,z,\sigma)} \right) + \ln Q(x_i,z,\sigma).$$ Expanding $\ln{(1-\epsilon)} \simeq -\epsilon$ and assuming $Q$ is Gaussian, we have following useful approximation for $\log$-likelihood: $$\label{logL}
\log \mathcal{L} = k_3 \frac{P(z)}{Q(z,z,\sigma)} - \ln{(\sqrt{2 \pi} \sigma)} - \frac{(x_i-z)^2}{2 \sigma^2}.$$

We note, that probability of the identification related to could be, in principle, estimated directly, especially for single precision floats, as there are only $2^{32}$ of them. Using floats as bins for sequentially generated EL numbers, we can fill them with numbers associated with their complexity.

![ \[likelihood\] Log-likelihood of subsequent best $\exp-\log$ approximations, as estimated from . Red, green, blue and black lines are for calculators 1,2,3 and 4, respectively. Target values are approximations to our introduction example $z=\sqrt{2}^{\sqrt{3}}$ in form $z \pm \sigma$ with: $z=1.82 \pm 0.005$ (dot-dashed, x), $z=1.823 \pm 0.0005$ (dotted, o), $z=1.8226 \pm 0.00005$ (dashed, +), $z=1.82263 \pm 0.000005$ (solid, \#). ](figs/Likelihood1 "fig:"){width="50.00000%"}\
![ \[likelihood\] Log-likelihood of subsequent best $\exp-\log$ approximations, as estimated from . Red, green, blue and black lines are for calculators 1,2,3 and 4, respectively. Target values are approximations to our introduction example $z=\sqrt{2}^{\sqrt{3}}$ in form $z \pm \sigma$ with: $z=1.82 \pm 0.005$ (dot-dashed, x), $z=1.823 \pm 0.0005$ (dotted, o), $z=1.8226 \pm 0.00005$ (dashed, +), $z=1.82263 \pm 0.000005$ (solid, \#). ](figs/Likelihood2 "fig:"){width="50.00000%"}\
![ \[likelihood\] Log-likelihood of subsequent best $\exp-\log$ approximations, as estimated from . Red, green, blue and black lines are for calculators 1,2,3 and 4, respectively. Target values are approximations to our introduction example $z=\sqrt{2}^{\sqrt{3}}$ in form $z \pm \sigma$ with: $z=1.82 \pm 0.005$ (dot-dashed, x), $z=1.823 \pm 0.0005$ (dotted, o), $z=1.8226 \pm 0.00005$ (dashed, +), $z=1.82263 \pm 0.000005$ (solid, \#). ](figs/Likelihood3 "fig:"){width="50.00000%"}\
![ \[likelihood\] Log-likelihood of subsequent best $\exp-\log$ approximations, as estimated from . Red, green, blue and black lines are for calculators 1,2,3 and 4, respectively. Target values are approximations to our introduction example $z=\sqrt{2}^{\sqrt{3}}$ in form $z \pm \sigma$ with: $z=1.82 \pm 0.005$ (dot-dashed, x), $z=1.823 \pm 0.0005$ (dotted, o), $z=1.8226 \pm 0.00005$ (dashed, +), $z=1.82263 \pm 0.000005$ (solid, \#). ](figs/Likelihood4 "fig:"){width="50.00000%"}

Discussion above provides second criterion for constant identification:

Criterion 2:\
Identification candidate: *if likelihood given by has reached maximum, formula has the highest probability, and should be returned.*

One might return a few highest likelihood formulas near maximum as well, or one with largest value so far, if computational resources are limited. Noteworthy, likelihood value provide also relative quantitative estimate of identification probability. We may estimate likelihood , using calculator , for $z=1.82263\pm0.00005$ (Fig. \[likelihood\], solid blue line) to be identified as $\sqrt{2}^{\sqrt{3}}$ $$\log \mathcal{L} = 8.33 \qquad   (\mathcal{L} = 4 \times 10^{3})$$ compared to $$\log \mathcal{L} = -62.3 \qquad  (\mathcal{L} = 9 \times 10^{-28})$$ for $(\ln{4})^{\ln{2\pi}}$. From our Criterion 3, the former is more than $10^{30}$ times more probable than the latter. Without this sort of ”ranking”, discussion, if e.g. $\sinh ^{-1}\left(\phi  \sinh ^{-1}(\pi )\right)$ is ”simpler” or ”more elegant” compared to, e.g., $\sin( \cosh{4} ) + \sqrt{\tanh{5}}$ might continue indefinitely, leading to nothing. Likelihood or provide numerical form of the Occam’s razor. It can be applied automatically, within software (CAS) environment.

[Constant recognition as data compression \[Criterion3\] ]{}

Sequence of progressively better approximations in form of RPN calculator codes can be viewed as a form of lossy compression. If exact formula is found, then compression becomes lossless. In the intermediate case, compression ratio provides measure, how good is some formula to recover decimal expansion. This process is illustrated in Table \[compress\]. Calculator 3 defined in eq.  has been used, because both decimal expansion of the target number $z$ and RPN code are strings of the same base-10 digits, i.e. `0123456789`. Therefore, compression ratio is simply a number of correct digits divided by code length $K$.

  --------------------------------- ----------- ------------- --------------------------------
                          Numerical        Code  Compression              Formula
                              value                 ratio     
                            \[2mm\]                           
    \[2mm\] 3.141592653589793238512           0     0.00                   $\pi$
            2.718281828459045235428           1     0.00                    $e$
            0.000000000000000000000           2     0.00                    $0$
            2.000000000000000000000           7     0.00                    $2$
        **1**.718281828459045235428         164     0.33                   $e-1$
        **1**.772453850905516027310         809     0.33                $\sqrt{\pi}$
        **1**.648721270700128146893         819     0.33                 $\sqrt{e}$
        **1.8**37877066409345483606        0043     0.50              $\ln{(\pi+\pi)}$
        **1.8**37877066409345483606        7053     0.50               $\ln{(2 \pi)}$
        **1.82**0796326794896619256       08485     0.60       $\frac{1}{2}(\pi+\frac{1}{2})$
        **1.82**0796326794896619256       80485     0.60      
        **1.82**0796326794896619256       80845     0.60      
        **1.82**0796326794896619256       88045     0.60      
        **1.82**1126701185962651818     0338975     0.43           $2^{1-\ln{\ln{\pi}}}$
        **1.82**1126701185962651818     7033895     0.43      
        **1.82**1126701185962651818     8303975     0.43          $2 (\ln{\pi})^{-\ln{2}}$
        **1.82**4360635350064073446     8819745     0.43      
        **1.82**4360635350064073446     8781945     0.43      
        **1.82**4360635350064073446     8197485     0.43      
        **1.82**4360635350064073446     7819485     0.43      
        **1.82**1126701185962651818     7830395     0.43      
        **1.82**1662858741926632288     6091579     0.43      
        **1.822**361069544464599575     2298979     0.57      
        **1.822**413909696397869321    77408934     0.50      
        **1.822**722133555469366033    80790539     0.50      
        **1.8226**90334737686312645   004377539     0.56      
        **1.822634654966242214**488   888854979     2.11      
  --------------------------------- ----------- ------------- --------------------------------

  : \[compress\]

In Table \[compress\], compression ratio of the target number $z=\sqrt{2}^{\sqrt{3}} \simeq 1.8226346549662422143937682155941\ldots$ in form of $n=10$ RPN calculator codes is shown.

Buttons/operations were assigned as follows:\
0 $\to$ ,\
1 $\to$ ,\
2 $\to$ ,\
3 $\to$ ,\
4 $\to$ ,\
5 $\to$ ,\
6 $\to$ ,\
7 $\to$ ,\
8 $\to$ ,\
9 $\to$ .

In fact, last code in Table \[compress\] `888854979`, with pronounced compression ratio of $19/9\simeq2.11 > 1$, is equivalent to exact formula, with RPN sequence , , , , $\times$, $+$, , 2, , i.e., $2^{\sqrt{3}/2}$.

In general case, compresion ratio $r$ is given by: $$\label{r}
r = \frac{-\log_{10} \max{(\epsilon, \sigma)}}{K \; \log_{10} n},$$ where $\epsilon$ is absolute precision of the approximation, $K$ - RPN code length, $n$ - number of calculator buttons.

Now we can formulate the last criterion for constant recognition:

Criterion 3:\
Identification candidate: *if compression ratio given by is $r \gg 1$, or $r$ reaches maximum in the course of search, then formula should be returned.*\
Failure: *if $r \ll 1$ formula/code is unlikely match.*

Criterion 3 has an advantage of being very simple. It do not require recorded history of search, like Criterion 1 (Sect. \[Criterion1\]), of searching for maximum and knowledge of statistics, like Criterion 2 (Sect. \[Criterion2\]). If indeed $r$ has a maximum, then it strenghten identification, but this is not required. You might ask for compresion ratio of any combination of decimal expansion and formula. The only required action is to compile formula to RPN code or similar one. Therefore, it will work with any searching method, e.g: *Monte Carlo*, genetic or shortest path tree algorithms. It is weak compared to $e$-folding or statistical criteria, but could easily exclude most of formulae produced in variety of software, especially very complicated ones, and those including large ($i \gg 2$) integers.

[Conclusions]{}

Three criteria proposed in the article provide robust tool for decimal constant identification.

![\[3C\] Recognition indicators as a function of $N$. Solid red line shows absolute $e$-folding $e_1$, while dotted red line relative $e$-folding $e_2$ (upper panel). Green line show likelihood (middle panel), and blue compression ratio (bottom panel).](figs/ThreeCriteria){width="50.00000%"}

Process of recognition, applying all three criteria, is illustrated in Fig. \[3C\], using blind-test target value of $z=201.06192983$. Assuming all digits are correct, we adopted (gaussian) error $\sigma=0.000000005$. Using calculator , we plot three indicators of matching quality. For $e$-folding measure we use $$e_1 = \frac{z}{\epsilon_N} e^{-N},$$ and additionally: $$e_2 = \frac{\epsilon_{N-1}}{\epsilon_N} \frac{1}{e},$$ where $N$-th best approximation error is $\epsilon_N$. For likelihood, we used , and for compression ratio . Clearly, three subsequent data points, for $N=16,17,18$, stand out (Fig. \[3C\]).

From first criterion perspective (Sect. \[Criterion1\]), error dropped nearly $10^5$ times compared to expected $e^{-N}$ (Fig. \[3C\], upper panel, solid red). Is also was $10^8$ times smaller compared to previously found $x_{15}=e^e (1/2+\pi)^2$, while statistically anticipated decrease was $1/e$ (Fig. \[3C\], upper panel, dotted red). Using criterion 2 (Sect. \[Criterion2\]) we found likelihood many many orders of magnitude larger compared to any other formulas. Three data points with nearly equal $\log L\sim 18.193$ (Fig. \[3C\], middle panel, green crosses), 16,17,18-th best approximations, are in fact the same formula typed using different RPN sequences. Differences are due to round-off errors. Shortest one is preferred in terms of criterion 3 (Sect. \[Criterion3\]), see Fig. \[3C\], lower panel. Constant $z$ is then unambiguously recognized by all three criteria as $64 \pi$, with no other candidates in sight.

Above example show possible way to precise formulation of decimal constant recognition problem, as a task reverse to pushing button sequence, and its solution. Using three proposed criteria we are able to judge which formulas, matching given floating-point constant, are the most likely. In original formulation they require enumeration of all possible codes with growing complexity, but statistical and compression criteria are in fact independent of the method used to obtain expression. They require only formula to be compiled into RPN code. Then, Criterion 3 can be applied directly, and Criterion 2 indirectly, using code length $K$ to find upper limit on $k_1,k_2,k_3$ (Fig. \[k2k3\]).

Calculator used to enumerate codes can be arbitrary, as long as it includes ”irreducible” buttons equivalent to or . However, search results (required depth in particular) depend on calculator definition. This is especially visible in search of human-provided test cases, with strong bias towards decimal numerals, and repulsive reaction to power-towers and nested (exponential) function compositions. Unfortunately, the latter are strong at approximation, with multi-layer neutral networks being notable example using sigmoidal functions. Therefore, for numbers provided by humans, full calculator is usually the best, for mathematical results and for randomly generated expressions or .

Actually, while searching for constants, we are implicitly dealing with enumeration of all EL functions of one complex variable. This is especially visible in definition of calculator . Constant functions are just subset of them. Therefore, mathematical and statistical tools developed to solve constant identification problem, could be extended to identification of functions of one variable. This is a task for further research, with many more potential applications.

Supplemental Materials

Enumeration example \[enum\_example\]
=====================================

Detailed example of formula enumeration algorithm. Top-down base system (see main text) has been used for simplicity. Ternary base digits were assigned to three RPN calculator buttons as: 0 $\to$ E ($e$), 1 $\to$ LOG ($\log_x{y}$), 2 $\to$ POW ($x^y$). After code length 3 invalid codes were omitted to save space.

  ------ ------- --------- ----------------------- -----------------------
   Enum   CODE    Syntax        RPN sequence               formula
    0       0      VALID              E                      $e$
    1       1     INVALID                          
    2       2     INVALID                          
    3      00     INVALID                          
    4      10     INVALID                          
    5      20     INVALID                          
    6      01     INVALID                          
    7      11     INVALID                          
    8      21     INVALID                          
    9      02     INVALID                          
    10     12     INVALID                          
    11     22     INVALID                          
    12     000    INVALID                          
    13     100    INVALID                          
    14     200    INVALID                          
    15     010    INVALID                          
    16     110    INVALID                          
    17     210    INVALID                          
    18     020    INVALID                          
    19     120    INVALID                          
    20     220    INVALID                          
    21     001     VALID          E, E, LOG             $\log_e{e}=1$
    22     101    INVALID                          
    23     201    INVALID                          
    24     011    INVALID                          
    25     111    INVALID                          
    26     211    INVALID                          
    27     021    INVALID                          
    28     121    INVALID                          
    29     221    INVALID                          
    30     002     VALID         E, E, POWER                $e^e$
    31     102    INVALID                          
    32     202    INVALID                          
    33     012    INVALID                          
    34     112    INVALID                          
    35     212    INVALID                          
    36     022    INVALID                          
    37     122    INVALID                          
    38     222    INVALID                          
    …                                              
   210    00101    VALID      E, E, LOG, E, LOG        $\log_e{1} = 0$
   219    00201    VALID     E, E, POWER, E, LOG      $\log_e{e^e} = e$
   228    00011    VALID      E, E, E, LOG, LOG             $nan$
   255    00021    VALID     E, E, E, POWER, LOG    $\log_{e^e}{e} = 1/e$
   291    00102    VALID     E, E, LOG, E, POWER          $e^1 = e$
   300    00202    VALID    E, E, POWER, E, POWER        $e^{(e^e)}$
   309    00012    VALID     E, E, E, LOG, POWER          $1^e = 1$
   336    00022    VALID    E, E, E, POWER, POWER    $(e^e)^e = e^{e^2}$
    …                                              
  ------ ------- --------- ----------------------- -----------------------

Enumeration of integer and rational numbers \[rat\]
===================================================

If we restrict ourselves to simplest case of integer and rational numbers, enumeration procedure without repetition, i.e., one-to-one mapping of non-negative integers $i$ into integers $j$ is known: $$j = \frac{1}{4} (-1)^i \left( -2 i+(-1)^i-1 \right).$$

Positive rationals $r$ can be enumerated by repeated composition of the function: $$\operatorname{next}{(r)} = \frac{1}{1 + 2 \lfloor r \rfloor  - r },$$ starting with zero.

Surprisingly, function $\operatorname{next}$ is composition of two *self-inverse* functions: $$\operatorname{inv}(x) = \frac{1}{x}, \quad \operatorname{ladder}{(x)} = 1 + 2 \lfloor x \rfloor  - x.$$

![\[SelfInv\] Self-inverse function, able to generate all integers and rationals without repetitions. ](figs/SelfInv){width="66.60000%"}

Illustrative example is provided as follows. Let us define two additional self-inverse functions: $$\operatorname{minus}(x)  = -x,$$ and $$\operatorname{pre}(x)  = -x + 1.$$

Any integer and rational (including negative) can be obtained be repeated composition of functions $\operatorname{inv}, \operatorname{minus}$ and $\operatorname{pre}$, cf. Fig. \[SelfInv\], starting with number (or a function) zero. Moreover, the appear in non-repetitive order: $$0,1, \infty, -1,2,\frac{1}{2},-2,3,-\frac{1}{2},\frac{3}{2},\frac{1}{3},
   -3,\frac{2}{3},4,-\frac{1}{3},-\frac{3}{2},\frac{4}{3},\frac{5}{2},\frac{1}{4},-\frac{2}{3},
   -4,\frac{3}{4},\frac{5}{3},5,\frac{2}{5},-\frac{1}{4},-\frac{4}{3},-\frac{5}{2}, \ldots$$

Above properties are remarkable, and suggest possible way to non-repetitive generation of $\exp-\log$ numbers by function composition, in unique order. However, it is unclear what kind of function(s) is could be. For example, self-inverse function related to exponentiation is: $$e^{-1/\ln{x}},$$ where -1 can be replaced by any other constant. In fact, it could be generalized to: $$p^{q/\log_p{x}},$$ with arbitrary $p,q$. So far, our attempts to find $p,q$ failed. We only guess they are somehow related to $e, \pi$ and possibly $i$.

Proof of completeness of up-bottom base set \[base-3-proof\] 
=============================================================

Goal of his section is to show, that all explicit elementary complex numbers can be reduced to three elements.

We start with symbols: $$e, x^y, \log_x{y}.$$

One can compute: $$\ln{x} = \log_e{x}, \quad 1=\ln{e}, \quad 0=\ln{1}, \quad 1/e = \log_{e^e}{e}, -1 = \ln{\log_{e^e}{e}}, 2 = \ln{\ln{(e^e)^e}}.$$

Reversing role of logarithm base and argument, we also get: $$1/2 = \log_{e^{e^2}}{e}.$$

This way one can compute all natural numbers and their reciprocals (egyptian fractions).

Multiplication can be computed by: $$x \cdot y = \log_{x}{ \left[ (x^y)^x  \right]},$$ while division is: $$\frac{x}{y} = \log_{x^y}{x^x}.$$

Doing addition is tricky, but possible: $$x+y = \log_x \; \log_{x^x} \left( \left(   (x^x)^{x^y} \right)^{x^x}  \right).$$

Reciprocal is: $$1/x = \log_{x^x}{x},$$ and sign change: $$-x = \log_x { \log_{x^{x^x}}{x} }.$$

This complete basic 6 binary operations. We need only square root: $$\sqrt{x} = x^{\log _{\log _x\left(\left(x^x\right)^x\right)}(x)}$$ of -1: $$i = \log_x\left(\log _{x^x}(x)\right)^{\log _{\log _x\left(\left(x^x\right)^x\right)}(x)},$$ to compute remaining trigonometric functions. In particular (see Fig. \[pi\] for more readable form): $$\pi = \log \left(e^{\log \left(\log \left(e^e,e\right),e\right)^{\log \left(\log
   \left(\left(e^e\right)^e\right),e\right)}},\log \left(\log
   \left(e^e,e\right),e\right)\right).$$

This completes the proof.

![\[pi\] Tree form of $\pi$ computed using primitive calculator CALC1. ](figs/PiELogPowera.png){width="50.00000%"}

Proof of completeness of bottom-up base set \[base-4-proof\] 
=============================================================

Goal of his section is to show, that all explicit elementary complex numbers can be reduced to calulator with four buttons.

We start with symbols: $$\exp, \ln, x, -.$$

One can calculate: $$0 = x-x, \quad 1 = \exp{0} \equiv \exp{(x-x)}, \quad  e=\exp{(1)} \equiv \exp{(\exp{(x-x)})}.$$

Now, we know how to compute: $$\exp, \ln, x, -, 0, 1, e.$$

Addition is: $$x+y = x-(0-y) = x-((x-x)-y).$$

One can change sign and compute reciprocal with: $$-x = 0-x = (x-x)-x, \quad 1/x = \exp{(-\ln{x})}.$$ So far we have: $$\exp, \ln, x, -, 0, 1, e, +, 1/x,$$ succesor is: $$x+1 = x-(0-1) = x - \left( (x-x) - \exp{(x-x)}  \right).$$

Using succesor and reciprocal on can compute all integers and rationals. Multiplication and division using logarithms are well-known: $$x \cdot y  = \exp{(\ln{x} + \ln{y})}, \quad  \frac{x}{y} = \exp{(\ln{x} - \ln{y})}.$$

Binary exponentiation and logarithm are: $$x^y = \exp{(y \cdot \ln{x})}, \quad  \log_x{y} = \frac{\ln{y}}{\ln{x}}.$$

Let’s proceed to square root and $i$: $$\sqrt{x} = x^{1/2}, \quad i = \sqrt{-1}.$$

Number $\pi$ is: $$\pi = -i \ln{(-1)}.$$

Now, calculating trigonometric functions is straightforward: $$\sin{x} = \frac{\exp{(i x)} - \exp{(-i x) }}{2 i}, \ldots$$

Above shows, that all constants, functions and binary operations from Sect. 2 can be computed using CALC2.

Distribution of EL numbers on complex plane \[complex\]
=======================================================

Distrubution of the EL numbers generated by sequence on complex plane is presented in Figs. \[ComplexPlane\] and \[ComplexPlane\_FractionalPart\]. Visually, it is far from random. However, it is not fractal, a because EL numbers include rationals, which are everywhere dense.

![\[ComplexPlane\] Distribution of the EL numbers on complex plane for calculators 1-4. Calculator 1 (top-down) is shown in the upper-left panel. Only formulas with $\operatorname{Im}(z) \neq 0$ are shown, up to Kolmogorov complexity $K \leq 23$, what gives 1500k unique complex numbers. Upper-right panel is for CALC2 (down-top), up to $K \leq 16$; lower-left shows CALC3 (Mathematica) for $K \leq 9$; lower-right present full calculator CALC4 up to $K \leq 5$. ](figs/CALC1_complex_2Pi.png "fig:"){width="50.00000%"} ![\[ComplexPlane\] Distribution of the EL numbers on complex plane for calculators 1-4. Calculator 1 (top-down) is shown in the upper-left panel. Only formulas with $\operatorname{Im}(z) \neq 0$ are shown, up to Kolmogorov complexity $K \leq 23$, what gives 1500k unique complex numbers. Upper-right panel is for CALC2 (down-top), up to $K \leq 16$; lower-left shows CALC3 (Mathematica) for $K \leq 9$; lower-right present full calculator CALC4 up to $K \leq 5$. ](figs/CALC2_complex_2Pi.png "fig:"){width="50.00000%"}\
![\[ComplexPlane\] Distribution of the EL numbers on complex plane for calculators 1-4. Calculator 1 (top-down) is shown in the upper-left panel. Only formulas with $\operatorname{Im}(z) \neq 0$ are shown, up to Kolmogorov complexity $K \leq 23$, what gives 1500k unique complex numbers. Upper-right panel is for CALC2 (down-top), up to $K \leq 16$; lower-left shows CALC3 (Mathematica) for $K \leq 9$; lower-right present full calculator CALC4 up to $K \leq 5$. ](figs/CALC3_complex_2Pi.png "fig:"){width="50.00000%"} ![\[ComplexPlane\] Distribution of the EL numbers on complex plane for calculators 1-4. Calculator 1 (top-down) is shown in the upper-left panel. Only formulas with $\operatorname{Im}(z) \neq 0$ are shown, up to Kolmogorov complexity $K \leq 23$, what gives 1500k unique complex numbers. Upper-right panel is for CALC2 (down-top), up to $K \leq 16$; lower-left shows CALC3 (Mathematica) for $K \leq 9$; lower-right present full calculator CALC4 up to $K \leq 5$. ](figs/CALC4_complex_2Pi.png "fig:"){width="50.00000%"}

![\[ComplexPlane\_FractionalPart\] Same as in Fig. \[ComplexPlane\], but his time distribution of the fractional part of the EL numbers on complex plane is shown. ](figs/CALC1_complex_frac.png "fig:"){width="50.00000%"} ![\[ComplexPlane\_FractionalPart\] Same as in Fig. \[ComplexPlane\], but his time distribution of the fractional part of the EL numbers on complex plane is shown. ](figs/CALC2_complex_frac.png "fig:"){width="50.00000%"}\
![\[ComplexPlane\_FractionalPart\] Same as in Fig. \[ComplexPlane\], but his time distribution of the fractional part of the EL numbers on complex plane is shown. ](figs/CALC3_complex_frac.png "fig:"){width="50.00000%"} ![\[ComplexPlane\_FractionalPart\] Same as in Fig. \[ComplexPlane\], but his time distribution of the fractional part of the EL numbers on complex plane is shown. ](figs/CALC4_complex_frac.png "fig:"){width="50.00000%"}

[^1]: If it is not, then it is a rational number, e.g 1.82263 = 182263/100000.

[^2]: Alternatively, database of the pre-computed results [@ISCwayback].

[^3]: See also Appendix B in Supplemental Material.

[^4]: See Appendix E in Supplemental Material for distribution of EL numbers on the complex plane.
