I found an interesting infinite sequence recently in the form of a 'two storey continued fraction' with natural number entries:


The numerical computation was done 'backwards', starting from some $x_n=1$ we compute:


And so on, until we get to $x_0$. The sequence converges for $n \to \infty$ if $a_n>1$ (or so it seems).

For constant $a_n$ we seem to have quadratic irrationals, for example:


For $a_n=2^n$ we seems to have:


I found no other closed forms so far, and I don't know how to prove the formulas above. How can we prove them? What is known about such continued fractions?

There is another curious thing. If we try to expand some number in this kind of fraction, we can do it the following way:


$$a_0=\left[\frac{1}{x_0} \right]$$


$$a_1=\left[\frac{1}{x_1} \right]$$

However, this kind of expansion will not give us the above sequences. We will get faster growing entries. Moreover, the fraction will be finite for any rational number. For example, in the list notation:


You can easily check this expansion for any rational number.

As for the constant above we get:


Not the same as $[1,2,3,4,5,6,7,\dots]$ above!

We have similar sequences growing exponentially for any irrational number I checked.



By the way, if we try CF convergents, we get almost the same expansion, but finite:



So, the convergents of this sequence are not the same as for the simple continued fraction, but similar.

Comparing the expansion by the method above and the closed forms at the top of the post, we can see that, unlike for simple continued fractions, this expansion is not unique. Can we explain why?

Here is the Mathematica code to compute the limit of the first fraction:

Nm = 50;
Cf = Table[j, {j, 1, Nm}];
b0 = (Cf[[Nm]] - 1)/(Cf[[Nm]] + 1);
Do[b1 = N[(Cf[[Nm - j]] - b0)/(Cf[[Nm - j]] + b0), 7500];
 b0 = b1, {j, 1, Nm - 2}]
N[b0/Cf[[1]], 50]

And here is the code to obtain the expansion in the usual way:

x = (E^2 - 3)/(E^2 + 1);
x0 = x;
Nm = 27;
Cf = Table[1, {j, 1, Nm}];
Do[If[x0 != 0, a = Floor[1/x0];
  x1 = N[(1 - x0 a)/(x0 a + 1), 19500];
  Print[j, " ", a, " ", N[x1, 16]];
  Cf[[j]] = a;
  x0 = x1], {j, 1, Nm}]
b0 = (1 - 1/Cf[[Nm]])/(1 + 1/Cf[[Nm]]);
Do[b1 = N[(1 - b0/Cf[[Nm - j]])/(1 + b0/Cf[[Nm - j]]), 7500];
 b0 = b1, {j, 1, Nm - 2}]
N[x - b0/Cf[[1]], 20]


I have derived the forward recurrence relations for numerator and denominator:

$$p_{n+1}=(a_n-1)p_n+2a_{n-1}p_{n-1}$$ $$q_{n+1}=(a_n-1)q_n+2a_{n-1}q_{n-1}$$

They have the same form as for generalized continued fractions (a special case). Now I understand why the expansions are not unique.

Yuriy S
  • 30,220
  • 5
  • 48
  • 168
  • 2
    I am always thoroughly impressed with the length and detail in your posts. On the other hand, you might want to key in a little more on what your main question is here. – Brevan Ellefsen Feb 07 '17 at 22:25
  • 1
    @BrevanEllefsen, if these are known results, I would like a reference. If not, I would like a hint about a proof. And the most important question - why is the expansion not unique, even though the properties seem to be similar to simple continued fractions. Thanks, by the way. I'm glad I'm not the only one who likes my posts :) – Yuriy S Feb 07 '17 at 22:26
  • 1
    @Nemo, I'm not sure I understand what you did here, but I figured out the same thing after deriving the forward recurrence relations for numerator and denominator: $$p_{n+1}=(a_n-1)p_n+2a_{n-1}p_{n-1}$$ $$q_{n+1}=(a_n-1)q_n+2a_{n-1}q_{n-1}$$ Obviously, we have a special case of a generalized continued fraction. Which is why it is not unique – Yuriy S Feb 08 '17 at 09:18

1 Answers1


For the first one, you could write \begin{equation} f(n) = \frac{n-f(n+1)}{n+f(n+1)} \end{equation} Then you suggest \begin{equation} f(2) = \frac{e^2-3}{e^2+1} \end{equation} But this then gives \begin{align} f(1) = \frac{2}{e^2-1}\\ f(3) = \frac{4}{e^2-1} \\ f(4) = \frac{3e^2-15}{e^2+3}\\ f(5) = \frac{-2e^2+18}{e^2-3} \end{align} I don't know if there is a recurrence relation that solves this, but you have a few more closed forms...

The second one we have \begin{equation} g(2) = \frac{2 - g(2)}{2+g(2)} \end{equation} so we can solve the quadratic $x^2+3x-2$ to get $(\sqrt{17}-3)/2$.

For the third one, we have \begin{equation} h(n) = \frac{n-h(2n)}{n+h(2n)} \end{equation} using the trial version of $h(2)=1/2$, we get \begin{align} h(4)=\frac{2}{3}\\ h(8)=\frac{4}{5}\\ h(16)=\frac{8}{9} \end{align} then it is likely that \begin{equation} h(n)=\frac{n}{n+2} \end{equation} as this satisfies the recurrence and that $h(2)=1/2$.

Benedict W. J. Irwin
  • 3,881
  • 13
  • 42
  • Thank you, when I look back it's clear that quadratic radicals or rational numbers are easily proven (provided the limit exists), just as you show here. For irrational numbers see the comments and the update, linking this to generalized continued fractions, and the proofs for $e$ related numbers can be found elsewhere – Yuriy S May 31 '17 at 11:29