6

Let $x_n\,(n\in\Bbb N)$ be the sequence defined by $$x_{n+1}=\frac{x_n}{\sqrt{x_n^2+1}+1}\tag 1$$ then it's well know that $2^nx_n\xrightarrow{n\to\infty}\arctan(x_0)$.

This gives a very simple recursive algorithm to manually compute $\arctan$ on a pocket calculator (like this) with $+,-,\times,\div,\sqrt{\phantom{x}}$ and one memory cell with keys M+, M-, MR.

In particular, to calculate the arcotangent of the number displayed on the screen of this calculator it's enough to press the following sequence of keys (see below for a proof): \begin{align} &\div\,=\,=\,\texttt{M+}\,\div\,=\,=\,\times\,=\\ &\texttt{While display > 0}\\ &\qquad+\,1\,=\,\sqrt{\phantom{x}}\,-\,1\,=\,\div\,2\,\times\,\texttt{MR}\,=\,\texttt{M+}\,\div\,\texttt{MR}\,=\\ &\texttt{MR}\,\div\,=\,= \end{align} In particular, we can compute $\pi$ with the following algorithm: \begin{align} &1\,\texttt{M+}\\ &\texttt{While display > 0}\\ &\qquad+\,1\,=\,\sqrt{\phantom{x}}\,-\,1\,=\,\div\,2\,\times\,\texttt{MR}\,=\,\texttt{M+}\,\div\,\texttt{MR}\,=\\ &\texttt{MR}\,\div\,4\,\div\,=\,= \end{align}

Note that at each ripetition of the while loop the same sequence of keys is pressed. A similar algorithm is possibile also for $\log,\arccos$ and the inverse hyperbolic cosine function.

Question. I'm ask if is possible to compute $\exp,\sin,\cos$ with an algorithm of the form \begin{align} &\texttt{S1}\\ &\texttt{While display > 0}\\ &\qquad\texttt{S2}\\ &\texttt{S3} \end{align} where $\texttt{S1},\texttt{S2}$ and $\texttt{S3}$ are finite sequences of keys among $$=,+,-,\times,\div,\sqrt{\phantom{x}},\texttt{M+},\texttt{M-},\texttt{MR},0,1,2,3,4,5,6,7,8,9$$


By completeness, I give a proof of the algorithm above. Assuming $x_0\neq 0$, let define $m_0=x_0^{-1}$ and \begin{align} m_{n+1} &=m_n\frac{\sqrt{x_n^2+1}+1}2\\ &=\frac 1{x_0}\prod_{k=0}^n\frac{\sqrt{x_k^2+1}+1}2 \end{align} so that \begin{align} 2^{n+1}x_{n+1} &=2^nx_n\left(\frac{\sqrt{x_n^2+1}+1}{2}\right)^{-1}\\ &=x_0\left(\prod_{k=0}^n\frac{\sqrt{x_k^2+1}+1}{2}\right)^{-1}\\ &=\frac 1{m_{n+1}} \end{align} hence $m_n^{-1}\xrightarrow{n\to\infty}\arctan(x_0)$. Let $d_n=x_n^2$ and $$d'_n=m_n\frac{\sqrt{d_n+1}-1}{2}$$ so that \begin{align} m_{n+1}&=m_n+d'_n\\ d_{n+1}&=\frac{d'_n}{m_{n+1}} \end{align}

Now assume that on the screen of the calculator we have the number $x_0$. By pressing $\div\,=\,=\,\texttt{M+}$ we compute $m_0=x_0^{-1}$ and we put it into the memory cell. Then $\div\,=\,=$ gives $x_0$ again and $\times\,=$ squares it giving $d_0=x_0^2$.

I claim that at each repetition of while loop we have stored $m_n$ in the memory cell and we display $d_n$ on the screen. This clearly holds of $n=0$. We argue by inductionon $n$; assume that $m_n$ is stored in the memory cell and $d_n$ is displayed on the screen.

The sequences of keys $+\,1\,=\,\sqrt{\phantom{x}}\,-\,1\,=\,\div\,2\,\times\,\texttt{MR}\,=$ gives $d'_n$ which is now displayed on the screen. Then by pressing $\texttt{M+}$ we add $d'_n$ to the memory cell $m_n$ giving $m_{n+1}=m_n+d'_n$ which is now stored in the memory cell. Finally $\,\div\,\texttt{MR}\,=$ computes $d_{n+1}$ which is now displayed on the screen, as claimed.

When we display $0$ on the screen we have $d_n\approx 0$, hence no better approximation can be computed and the while loop terminates.

The last keys $\texttt{MR}\,\div\,=\,=$ gives $m_{n+1}^{-1}\approx\arctan(x_0)$ as required.

  • Have you heard of CORDIC algorithm? – Yuriy S Jan 26 '18 at 18:27
  • Note that recursive algorithms such as yours mostly exist for inverse functions (arctangent, arcsine, logarithm, etc). They don't work for exponential and trigonometric functions. This is where CORDIC comes in, among other methods – Yuriy S Jan 26 '18 at 18:29
  • For most pocket calculators look up tables and interpolation are used as well – Yuriy S Jan 26 '18 at 18:31
  • I don't know CORDIC algorithm; thank'you for your suggestion, I will looking for it. But do you know a proof that, for example, exponential function cannot be computed with an recursive algorithm such as described in my question? – Fabio Lucchini Jan 26 '18 at 18:35
  • 1
    I'm not saying there's no recursive algorithms for the exponential, but they are very different from the one you use for the logarithm. Simply because the functions are quite different. For example, logarithms can be expressed as integrals of algebraic functions. Exponential can't – Yuriy S Jan 26 '18 at 18:41
  • How does the $\arctan$ approx follow your rules? $2^n x_n$ does depend on $n$. – wlad Jan 27 '18 at 17:28
  • It's not possible to express $\arctan$ as $x=f(x)$ where $f$ is composed of arithmetic ops and $\sqrt{}$ because $\arctan$ can be transcendental. By definition a number satisfying $x = f(x)$ is algebraic. – wlad Jan 27 '18 at 17:34
  • What you're asking for is already impossible for $\arctan,\arcsin,\ln$. You contradicted yourself when you used $n$ in $2^n x_n$. Finally, not everyone is familiar with that model of calculator. I'm voting to close on the grounds that your question is unclear. – wlad Jan 27 '18 at 17:43
  • Wait a moment: I will add a proof and a better explanation of the algorithm. There is no contradiction: some manipulation are necessary to get the algorithm from the formula at the beginning of my question. – Fabio Lucchini Jan 27 '18 at 17:45
  • @FabioLucchini What manipulations? Why don't they apply to the following approximations: $e^x \approx (1+\frac x n)^n$, $\sin x = 2\sin\frac x 2 \sqrt{1-\sin^2\frac x 2}$? – wlad Jan 27 '18 at 18:00
  • I added a proof of the algorithm with exaplanation of each step. Now it's clearer that $\arctan$ can be computed recursively as asserted. – Fabio Lucchini Jan 27 '18 at 18:59
  • What about the squaroot+? In fact I alm a bite confused about the question what do you want exactly – Guy Fsone Jan 27 '18 at 19:23
  • I'm available to make my question clearer. What do you not understand about square root? – Fabio Lucchini Jan 27 '18 at 19:26
  • Added a link of an online pocket calculator for testing the algorithm. – Fabio Lucchini Jan 27 '18 at 19:38
  • 1
    I do not think that this question should be closed as too broad. There are simple classes of elementary functions which probably admit similar solutions. – qwr Jan 27 '18 at 20:27
  • @qwr By mistake I voted to close the question for being too broad. I actually found it unclear at the time. – wlad Jan 27 '18 at 20:27
  • I edited my question adding a precise formulation of the algorithm that I looking for. We can also confine yourself to the exponential function $e^x$ only. – Fabio Lucchini Jan 27 '18 at 20:54
  • You can do loan math with this type of calculator, even if it doesn't know order of operations. –  Feb 22 '19 at 16:20

0 Answers0