# Generating Numbers with Unary Functions

This is a revised version of my article "A puzzle of function calculator"
that appeared as a problem of Nanopico Classroom
in the January 1989 issue of Kyoritsu Shuppan's **bit**.

## Introduction

This is a revised version of my article "A puzzle of function calculator"
that appeared as a problem of Nanopico Classroom
in the January 1989 issue of Kyoritsu Shuppan's **bit**.

You can play with the puzzle in the following web page.

## A puzzle of function calculator

Suppose the calculator has the following 11 unary functions over real numbers.

$$ \begin{align*} \mathrm{inv}(x) & = 1/x \qquad (x \ne 0) \\ \mathrm{sqrt}(x) & = \sqrt{x} \qquad (x \ge 0) \\ \mathrm{sq}(x) & = x^2 \\ \mathrm{log}(x) & = \log_{10} x \qquad (x > 0) \\ \mathrm{ex10}(x) & = 10^x \\ \mathrm{sin}(x) & = \sin x \\ \mathrm{asin}(x) & = \arcsin x \qquad (-1\le x\le 1,\ -90\le\mathrm{asin}(x)\le 90) \\ \mathrm{cos}(x) & = \cos x \\ \mathrm{acos}(x) & = \arccos x \qquad (-1\le x\le 1,\ 0\le\mathrm{acos}(x)\le 180) \\ \mathrm{tan}(x) & = \tan x \qquad (x \ne 180n+90,\ n\in\mathbb{Z}) \\ \mathrm{atan}(x) & = \arctan x \qquad (-90<\mathrm{atan}(x)<90) \end{align*} $$

The left side denotes the names of functions used in this problem, and the right side describes their definitions, domains, and ranges. Note that the angles are measured in degrees, not radians.

Now, it is possible to get various values by applying the above functions to 0 (zero). For example, two can be obtained by: $$ \mathrm{log}(\mathrm{sq}(\mathrm{ex10}(\mathrm{cos}(0)))) = 2 $$

In general, when $$ f_m(f_{m-1}(\cdots f_2(f_1(x))\cdots )) = y \qquad (m\ge 0), $$ the sequence of functions $$ f_1 f_2 \cdots f_{m-1} f_m $$ is called "a sequence of generating $y$ from $x$" and, in particular, it is called "s sequence of generating $y$" if $x=0$, and $m$ is called the number of steps. This means that $y$ can be obtained by applying the functions in that order when $x$ is displayed on the calculator. For example, $$ \mathrm{cos\ ex10\ sq\ log} $$ is a sequence of generating 2, that is, the result will be two by pushing these function keys when 0 is displayed.

Here is the first question.

- Quention 1
- For each integer $k$ from 1 to 20, find a sequence of generating $k$ with the shortest number of steps possible.

There might be several possible sequences of generating $k$ in general. For example, "ex10" can be used instead of "cos" in the above sequence of generating 2. Therefore, use "cos" to generate 1 in the first step. Also, when applying "sqrt", "inv", "sq" several times successively, use them in this order. For example, use "sqrt inv" instead of "inv sqrt".

The next two quentions are proof problems.

- Question 2
- Prove that there exists a sequence of generating $k$ for any integer $k$.

- Question 3
- Prove that there exists a sequence of generating $r$ for any rational number $r$.