Could you generate any positive number given only a few specific operators and operands?

I saw a joke UI on another site where it was a phone number input using only the below commands:

$$n \times 3 \\ n + 7 \\ n \div 5 \\ n - 2 \\ \lfloor n \rfloor \\ \sqrt{n} \\ n^2 \\ \log_{10}(n)$$

Where $$n$$ is the current number (begins at $$0$$). I wonder if something like this could actually generate any positive number.

$$\mathbb Z^+$$ is easy: you can find any positive integer using only $$n + 7$$ and $$n - 2$$. For any integer, add sevens until you reach or pass your desired number, then subtract twos. If you want an odd number, add sevens until you hit that scenario and land on an odd number, otherwise even numbers.

But what about $$\mathbb Q^+$$? $$\mathbb R^+$$? Is there a more declarative way of proving (or disproving) this than just trial and error? What about negatives? If all negative integers can be found, can $$\mathbb{C}$$ be found?

To clarify, I'm asking specifically about the eight operations I mentioned above, with those specific operands.

• What actually is your question. You didn't make it really clear what your question actually is. Dec 6, 2019 at 4:22
• You need to make it explicit what number, $n_0$, you're starting from. Otherwise the answer is trivial that $x\in\mathbb{R}$ can be generated by starting from $n_0=x$.
– Jam
Dec 7, 2019 at 16:14

You can get arbitrarily close to any number in $$\Bbb R^+$$ You showed you can get any positive integer. Now to get sort of close to $$\pi$$ you can form $$1385$$ and take the log, getting about $$3.14145$$. You can get closer by forming the closest integer to $$10^{10^\pi}$$ and taking the log twice. Keep going with the tower until you get as close as you want. The negative reals work the same. If you want to approach $$x$$, which is less than $$0$$, let $$k$$ be large enough so that $$x+2k \gt 0$$, approximate that, and subtract off $$k\ 2$$s.

You can do the same thing by forming the closest integer to $$\pi^2$$, which is $$10$$, and taking the square root, getting $$3.162$$. Then form the closest integer to $$\pi^4$$, which is $$97$$ and take two square roots, getting $$3.138$$. Keep going through $$\pi^{2^n}$$ and $$n$$ square roots.

I don't think you can get all rationals exactly because you don't have enough tools to get good denominators.

• And of course one cannot get all reals with only countably many expressions. Dec 5, 2019 at 17:22

Yes: in fact just using $$+7$$ and $$-2$$ is enough:

If you are aiming for $$k$$ then starting from $$0$$ add $$7$$ a total of $$k$$ times and then subtract $$2$$ a total of $$3k$$ times. You will end up at $$0+7k-6k=k$$

• Ah, you caught me before my edit. You put it much more succinctly, I guess the set of integers is simple. I've edited it to be inclusive of other number systems. Dec 5, 2019 at 4:52
• I mean, yea, it works, but no, it's horribly inefficient (2 copies of +7 is undone by just seven copies of -2, so you will never need more than k+13, going to 7k is insanely wasteful).
– Nij
Dec 6, 2019 at 2:31

You can get all rationals with a power of two times a power of 5 in the denominator (that is, all terminating decimals).
To get $$a/(2^b * 5^c)$$:
Generate $$10^a$$, hit sqrt $$b$$ times, hit log10, then hit /5 $$c$$ times.

As you have already pointed out with your edit, you can cover $$ℤ$$ using the +7 and -5 operations.

By using the ÷5 operation the correct number of times, you can make any fraction with a power of 5 in the denominator. Also, as @ralphmerridew pointed out, you can get powers of 1/2 with combinations of log10 and √. However, I don't see a way to generate any other rationals.

With a finite but unbounded number of operations from a finite “alphabet” of operations, you're limited to a countably infinite set of operation sequences, and thus a countably infinite numbers you can generate. Which puts $$ℝ$$ out of reach, regardless of which operations you have.

• As @ralphmerridew’s answer points out, you can at least get any rational of the form $\frac{p}{2^a 5^b}$: to get the factors of 2, you use the combo of square root and taking logs. Dec 5, 2019 at 22:44

Questions about what values are obtainable by composition of functions often have "obvious" theorems that are not easily proven, if at all. A prime example is one of Skewes' numbers, $$e^{e^{e^{79}}}$$; it may be an open problem whether this number is even integral, let alone rational (Question 13054).

To begin, composition of only $$7+n$$, $$-2+n$$, $$3\times n$$, $$\lfloor n \rfloor$$ and $$n^2$$ on $$n_0=0$$ will take values in $$\mathbb{Z}$$ only. As the other answers have shown, all values in $$\mathbb{Z}$$ can be attained. Next, the compositions of the $$5$$ aforementioned functions with $$\frac15\times n$$ will only yield values of the form $$\frac{k}{5^i}$$, for $$k\in\mathbb{Z},i\in\mathbb{N}^0$$. This is a strict subset of $$\mathbb{Q}^+$$ excluding all quotients with a denominator that is not a nonnegative power of $$5$$. However, from this point onward, we now have a dense set of values and can approximate any $$x\in\mathbb{R}^+$$ to arbitrary precision.

Compositions of the $$6$$ aforementioned functions and $$\sqrt{n}$$ extends the range of values to a strict subset of $$\mathbb{A}$$, including (real and complex) irrational-algebraic numbers that can be expressed with a finite expression in nested radicals. However, this is certainly missing algebraic numbers such as the roots of many rational-coefficient polynomials of degree-$$5$$ and higher (Question 837948). Also, the set of attainable values is still a subset of the constructible numbers, so we are also missing numbers such as $$2^{1/3}$$, whose minimal polynomial is not a power of $$2$$. Up to this point (momentarily ignoring the function $$n^2$$) we may only construct numbers of the form, for $$c_r\in\mathbb{Z},k_r,i_r\in\mathbb{N}^0$$

$$c_0+\frac{3^{k_0}}{5^{i_0}}\sqrt{c_1+\frac{3^{k_1}}{5^{i_1}}\sqrt{c_2+\ldots}}$$

With $$n^2$$, we have more complicated expressions, since $$n^2$$ expands into a sum of products of terms with the aforementioned form, but with further compositions built upon them. I don't personally think it is clear what subset of the constructible numbers is now attainable, even with just these $$7$$ operations from your $$8$$ but we could possibly use tools from Galois theory to find out.

Inclusion of the last operation, $$\log_{10}{n}$$, complicates the matter even further. We have the issue of $$\log_{10}{n}$$ being multivalued when it can take complex values but can remedy this with the principal value. But since we now have access to transcendental values, the attainable values are a strict subset of $$\mathbb{C}$$. I believe they comprise, at most, the set of computable real (or complex) numbers, since the string of composed functions specifies an algorithm to compute them. This set is in turn is a subset of definable real (or complex) numbers since the cardinality of $$\mathbb{C}$$ is greater than the set of definitions.

Given a target-value of any computable $$z\in\mathbb{R}^+/\{0,1\}$$, at some point $$z^*=\sqrt{\sqrt{\ldots\sqrt{z}}}$$ must be irrational-algebraic and $$10^{z^*}$$ is therefore transcendental by the Gelfond-Schneider theorem. So then the power-tower 10^(10^(^...^(10^(z*)))) may or may not be integral, rational or transcendental. In fact, we know as little about this power-tower, as we do $$e^{e^{e^{79}}}$$. It is computationally intractable due to the enormous size and cannot be treated with theorems such as Lindemann-Weierstrass or Gelfond-Schneider, since the steps of the tower are not certain to be algebraic; they could even flip-flop between being algebraic and transcendental with successive compositions. Assuming it does equal an integer, $$n$$, we can easily reach $$n$$ from $$0$$, then invert the power-tower, such that

$$z=\log\left(\log\left(\ldots\log n\right)\right)^{2^k}$$

Thus, we might be able to counterintuitively attain any computable $$\mathbb{R}^+$$, so I think the problem of finding the attainable values is likely open.

The recreational maths problem of finding numbers using only compositions from a finite set of functions has been previously discussed. It is in the same camp as the "Four Fours Puzzle", which has many relevant questions on the site: (Q1791480), Q1661508, (Q1941296) and the problem of "pandigital" approximations, which specifically use all digits $$0-9$$ once: (Q2590961). In my answer here, I've provided some links to other pages that investigate the problem, including an interesting conjecture by Donald Knuth (link) that we can get all integers, starting from $$3$$ and using only the set of functions $$\left\{\sqrt{n},\lfloor n\rfloor, n!\right\}$$. These problems are difficult due to the exponential number of possible compositions and their disorganised, not-obviously-convergent nature that can easily run them through unfeasibly big numbers. However, we can still find many interesting approximate results.

• @gator I've added some other relevant questions onto the end of the answer that you might be interested in.
– Jam
Dec 8, 2019 at 22:00

The other answers note that even with just $$n-2$$ and $$n+7$$, you can generate $$\mathbb Z$$. However, $$\mathbb Q^+$$ is not possible, since a fraction like $$\frac17$$ can't be generated. (Note that $$\log$$ clearly can't generate it since a rational to an irrational is irrational, the floor function doesn't help, and neither do the root or square functions. The rest of the functions don't get a denominator of $$7$$).

• Is it known that no integers appear in the list sequence $1/7,\,e^{1/7},\,e^{e^{1/7}},\,e^{e^{e^{1/7}}},\,\ldots$? You don't just have to worry about logs, but also nested logs, which are less understood. I mean, I have little doubt that that's true, but it also looks like something that's beyond the current mathematics. Dec 5, 2019 at 14:56
• @EricTowers - in the edit history, I do not see any point that it allowed division by any denominator other than $5$. Dec 5, 2019 at 17:50
• @EricTowers You may be right, but nowhere in the question do I see any evidence for that interpretation of the question. I guess we'll wait for OP's response. Dec 5, 2019 at 18:27
• The OP has now clarified that it should be only the 8 specific operations in the list, so division only by 5. Dec 5, 2019 at 22:25
• Not sure you should be so confident that $\frac 17$ can't be generated. Certainly not obvious to me. Dec 6, 2019 at 0:11