### Fun with Continued Fraction

Sometime in early undergraduate, I remember encountering problems like evaluating $$1 + \dfrac{1}{1 + \dfrac{1}{1 + \frac{1}{1 + \frac{1}{\ddots}}}}.$$The trick was to denote this number by some symbol, say $x$, and observe that $x$, due to its self-similarity, satisfies the relation \[ \dfrac{1}{x - 1}= 1 + \dfrac{1}{1 + \dfrac{1}{1 + \frac{1}{1 + \frac{1}{\ddots}}}} = x . \]Multiply both sides of the equation by $x-1$ to arrive at $x^2 - x - 1 = 0$, get the two possible values of $x$, and pick out the answer $x = \frac{1}{2}\left(1 + \sqrt{5}\right)\approx 1.61803$. At that point I was aware of the existence of the golden ratio (lots of YouTube hours; don't tell my mom) and thought that was a neat place for it to show up!

The next step for me was to try to make up some similar problems that I could solve with my new-found powers. It didn't take long before I stumbled upon something like \[\dfrac{1}{1 + \dfrac{1}{2 + \frac{1}{3 + \frac{1}{\ddots}}}}, \]which I couldn't solve. It wasn't until way later that, prompted by this video by 3Blue1Brown, that I revisited the problem in a more precise context, viewing this object as the limit of a sequence of numbers coming from iterations of $f(x) = 1 + x^{-1}$. I even plotted a nice cobweb, but this didn't really resolve the more difficult question. Oh well.

A million years pass and I am once again led to

*continued fractions:*given a sequence of positive integers $a_0, a_1, ...$ one may consider the number \[ [a_0; a_1, a_2, a_3, \cdots, a_n] := \begin{matrix} a_0 + \dfrac{1}{a_1 + \ \ } & & \\ & \ddots & \\ & & \dfrac{1}{a_{n-1}+ \dfrac{1}{a_n}} \end{matrix}.\]Clear some denominators and you have a rational number, $r_n = p_n/q_n$. A little more playing around and an induction argument yields\[ p_n = a_n p_{n-1} + p_{n-2}, \quad p_0 = a_0, \ p_{-1} = 1, \] \[ q_n = a_n q_{n-1} + q_{n-2}, \quad q_0 = 1, \ q_{-1} = 0.\]

In fact, another induction argument give us \[ \left( \begin{matrix} p_n & p_{n-1} \\ q_n & q_{n-1} \end{matrix} \right) = \left( \begin{matrix}a_0 & 1 \\ 1 & 0 \end{matrix}\right) \left( \begin{matrix}a_1 & 1 \\ 1 & 0 \end{matrix}\right) \cdots \left( \begin{matrix}a_n & 1 \\ 1 & 0 \end{matrix}\right). \]

Considering determinants on both sides yields $p_n q_{n - 1} - p_{n-1}q_{n} = (-1)^n$ and from this and some work conclude that $\lim_{n \to \infty} p_n/q_n$ exists.

At this stage, it's no surprise we ran into the golden ratio when considering $[1;1,1,1 \cdots]$. If we let $F_n$ denote the Fibonacci numbers, then

\[ \left( \begin{matrix} p_n & p_{n-1} \\ q_n & q_{n-1} \end{matrix} \right) = \left( \begin{matrix}1 & 1 \\ 1 & 0 \end{matrix}\right)^n = \left( \begin{matrix}F_{n + 1} & F_n \\ F_n & F_{n - 1} \end{matrix}\right).\]

So $[1;1, 1, \cdots]$ is not just a sequence of rational numbers converging to the golden ratio, it is

*the*sequence of rational numbers that define the golden ratio.What about \[\dfrac{1}{1 + \dfrac{1}{2 + \frac{1}{3 + \frac{1}{\ddots}}}}? \] The numerators and denominators are defined by

\[ p_n = np_{n-1} + p_{n-2}, \quad p_0 = 0, \ p_{-1} = 1, \] \[ q_n = n q_{n-1} + q_{n-2}, \quad q_0 = 1, \ q_{-1} = 0.\]

As it turns out (this reads "Mathematica told me"), this recurrence is solved using modified Bessel functions of the first and second kind (see equation 10.29.1 here).

In particular, \[ p_n = \dfrac{I_n(-2) K_1(2) - I_1(-2) K_n(2)}{I_2(-2) K_1(2) - I_1(-2) K_2(2)}, \quad q_n = \dfrac{I_n(-2) K_0(2) - I_0(-2)K_n(2)}{I_2(-2) K_1(2) - I_1(-2)K_2(2)}, \]

In particular, \[ p_n = \dfrac{I_n(-2) K_1(2) - I_1(-2) K_n(2)}{I_2(-2) K_1(2) - I_1(-2) K_2(2)}, \quad q_n = \dfrac{I_n(-2) K_0(2) - I_0(-2)K_n(2)}{I_2(-2) K_1(2) - I_1(-2)K_2(2)}, \]

where I used (10.29.1) again to simplify the formula for $q_n$. In fact, we can use (10.28.2) and that $I_n(-z) = (-1)^n I_n(z)$ to get \[ p_n = 2 ((-1)^{n}I_n(2) K_1(2) + I_1 (2) K_n(2), \] and\[ q_n = 2((-1)^{n - 1}I_n(2) K_0(2) + I_0(2) K_n(2)). \]

The final step is to calculate \[ \lim_{n \to \infty} \dfrac{p_n}{q_n} = \lim_{n \to \infty} \dfrac{(-1)^n I_n(2) K_1(2) + I_1(2) K_n(2) }{(-1)^{n - 1} I_n(2) K_0(2) + I_0(2) K_n(2)},\] which can be done with the help of (10.41.1 - 10.41.2) to arrive at \[ \dfrac{1}{1 + \dfrac{1}{2 + \frac{1}{3 + \frac{1}{\ddots}}}} = \dfrac{I_1(2)}{I_0(2)} \approx 0.6977746579640081\]

Turns out, the numerators and denominators are on the OEIS (A001053 and A001040). There's even a nice Wolfram Mathworld page on special continued fractions where they link to this reference. This and other computations appear there.

Years later, getting to see this problem through makes me feel happy.

Years later, getting to see this problem through makes me feel happy.