# Infinite Continued Fractions

In 1913, a parcel arrived in Cambridge for GH Hardy, the English mathematician. It contained a mathematical manuscript from Srinivasa Ramanujan, a poor clerk in India, with a covering letter asking for financial support. The manuscript contained wild and fantastic theorems without a single proof. Initially, Hardy discarded the manuscript as coming from a crank, but the strange formulae that it contained bothered him, and on reflection he decided to go through the document with Littlewood, his colleague. Their conclusion was that they had found a genius. Hardy obtained funding for Ramanujan to come to Cambridge, and they collaborated until Ramanujans death from tuberculosis in 1920.

When I first came across a photo of Ramanujan, beneath it was one of his continued fraction formulae:

$$

\cfrac{1}{1+\cfrac{e^{-2\pi\sqrt{5}}}{1+\cfrac{e^{-4\pi\sqrt{5}}}{1+\cfrac{e^{-6\pi\sqrt{5}}}{1 + \dotsb}}}} = \left( \frac{\sqrt{5}}{1+\left[5^{3/4}\left(\frac{\sqrt{5}-1}{2}\right)^{5/2}-1\right]^{1/5}} - \frac{\sqrt{5}+1}{2}\right)e^{2\pi/\sqrt{5}}

$$

I have been fascinated by them ever since. Firstly, they are so visually elegant. Secondly, their elegance belies the difficulty of proving them. How would you even begin to attack the one above?

In this article we are going to look at infinite continued fractions - continued fractions that do not terminate. As background, it would be useful to look at previous NRICH continued fraction articles (which you can find here (Continued Fractions I) and here (Continued Fractions II) ). In order to understand this one it would also help if you were familiar with Taylor series expansions of functions. I should confess that nowhere in this article is there any mention of convergence of these series. The series below do converge and the proof is rather interesting but unfortunately it would double the size of this article so I have had to leave it out.

With a handheld calculator (or spreadsheet), it is easy to check that we have an approximation $\tan(1)=1.5574$. Now the integer part of this is $1$ and the fractional part is $0.5574$. The reciprocal of the fractional part is $1/0.5574=1.7940$. Therefore we can write

$$ \tan(1)=1 + {1 \over 1.7940} $$

(1)

Repeating the same exercise with $1.7940$, we see an integer part of 1 and the reciprocal of the fractional part is $1.2594$. So we can amend (1) to:

$$ \tan(1)=1 + {1 \over {1 + {1 \over 1.2594}}} $$

(2)

Repeating the exercise over and over again, we get

$$ 1+ { 1 \over \displaystyle 1\;+\;{ 1 \over \displaystyle 1\;+\;{ 1 \over \displaystyle 3\;+\;{ 1 \over \displaystyle 1\;+\;{ 1 \over \displaystyle 5\;+\;{ 1 \over \displaystyle 1\;+\;{ \displaystyle ... }}}}}}} $$

(3)

Can you see the pattern?

In fact, if you do this either on a calculator or spreadsheet, the pattern eventually breaks down. Can you guess why?

^{th}term of the continued fraction will be likely to be incorrect.

We will do it one more time. The hyperbolic tangent of a number, $x$, is given by

$$ {\tanh(x)} = {{e^x - e^{-x}} \over{e^x + e^{-x}}} $$

(4)

Given this, we find the approximation $\tanh(1)=0.7615$. From this, we compute the continued fraction:

$$ {\tanh(1)} = {0+ {1 \over \displaystyle 1\;+\;{ 1 \over \displaystyle 3\;+\;{ 1 \over \displaystyle 5\;+\;{ 1 \over \displaystyle 7\;+\;{ 1 \over \displaystyle 9\;+\;{ \displaystyle ... }}}}}} } $$

(5)

This continued fraction exhibits a very obvious pattern! In fact, it is also the easiest to prove. As much as I would love to prove them all, space means that we are going have to be content with focussing on (5).

Firstly, we need to revise Taylor's theorem. This states that a function, $f(x)$, can be expressed as an ascending power series in terms of the derivatives of the function. In particular:

$$ {f(x)} = {{f(0)} + {f'(0) {x \over{1!}}} + {f''(0) {x^2 \over{2!}}} + ...} $$

(6)

Next, we need to know the definitions of the hyperbolic sine and cosine:

$$ {\sinh(x)} = {e^x - e^{-x} \over{2} } ; \quad {\cosh(x)} ={e^x + e^{-x} \over{2} } $$

(7)

Using these definitions, you need to calculate

- $$\sinh(0),\quad \cosh(0)$$
- $$\frac{d\sinh(x)}{dx},\quad \frac{d\cosh(x)}{dx}$$

and use these results to compute the power series expansion for $\sinh(x)$ and $\cosh(x)$. Reveal the hidden text if you need help.

\cosh(0) = \frac{1}{2}\left(e^0 + e^{-0}\right) = 1$$

$$

\frac{d\sinh(x)}{dx} = \frac{d}{dx}\left[\frac{1}{2}\left(e^x - e^{-x}\right)\right] = \frac{1}{2}{\left(e^x + e^{-x}\right)} = \cosh(x)

\\

\frac{d\cosh(x)}{dx} = \frac{d}{dx}\left[\frac{1}{2}\left(e^x + e^{-x}\right)\right] = \frac{1}{2}{\left(e^x - e^{-x}\right)} = \sinh(x)

$$

Therefore,

$$

\frac{d^n \sinh(x)}{dx^n} = \begin{cases}

\sinh{x} & n \text{ even} \\

\cosh{x} & n \text{ odd}

\end{cases}

$$

substituting in (6) we get:

$$

\sinh(x) = {x \over{1!}} + {{x^3} \over{3!}} + {{x^5} \over{5!}} + {{x^7} \over{7!}} + \dotsb

$$

Similarly,

$$

\frac{d^n \cosh(x)}{dx^n} = \begin{cases}

\cosh{x} & n \text{ even} \\

\sinh{x} & n \text{ odd}

\end{cases}

$$

and

$$

\cosh(x) = 1 + {{x^2} \over{2!}} + {{x^4} \over{4!}} + {{x^6} \over{6!}} + \dotsb

$$

Next we need to talk about "hypergeometric functions". There are actually a whole family of them but we'll just look at one. Don't worry if you haven't come across them before, we'll derive any properties we need.

We define the hypergeometric function in terms of it's power series expansion:

$$ {F(a,x)} = {1 + {1 \over{a}}{x \over{1!}} + {{1 \over{a(a+1)}}{x^2 \over{2!}}} + {{1 \over{a(a+1)(a+2)}}{x^3 \over{3!}}}+ ... } $$

(8)

Surprisingly, by careful choice of the parameters of $F$, we can use this function to represent $\sinh(x)$ and $\cosh(x)$:

$$ \sinh(x) = xF\left(\frac{3}{2} , \frac{x^2}{4}\right) $$

(9)

$$ \cosh(x) = F\left(a , \frac{x^2}{4}\right) $$

(10)

Can you prove it for the first and work out what the 'a' is for the second?

\begin{align*}

F\left(\frac{3}{2} , \frac{x^2}{4}\right) &= 1 + \frac{1}{(3/2)}\frac{(x^2/4)}{1!} + \frac{1}{(3/2)(5/2)}\frac{(x^2/4)^2}{2!} + \frac{1}{(3/2)(5/2)(7/2)}\frac{(x^2/4)^3}{3!} + \dotsb \\

&= 1 + \frac{1}{3}\frac{(x^2/2)}{1!} + \frac{1}{3.5}\frac{(x^2/2)^2}{2!} + \frac{1}{3.5.7}\frac{(x^2/2)^3}{3!} + \dotsb \\

&= 1 + \frac{1}{3}\frac{x^2}{2} + \frac{1}{3.5}\frac{x^4}{2.4} + \frac{1}{3.5.7}\frac{x^6}{2.4.6} + \dotsb

\end{align*}

So

$$

xF\left(\frac{3}{2} , \frac{x^2}{4}\right) = 1 + \frac{x^3}{3!} + \frac{x^5}{5!} + \frac{x^7}{7!} + \dotsb

$$

which is the expansion of $\sinh(x)$.

For $\cosh(x)$, we have already shown that:

$$

\cosh(x) = 1 + {{x^2} \over{2!}} + {{x^4} \over{4!}} + {{x^6} \over{6!}} + \dotsb

$$

so

\begin{align*}

\cosh(x) &= {1 + {{1 \over{1}}{{x^2} \over{2}}}+ {{1 \over{1.3}}{{(x^2)^2} \over{2.4}}} + {{1 \over{1.3.5}}{{(x^2)^3} \over{2.4.6}} + \dotsb }} \\

&= {1 + {{1 \over{1}}{{(x^2/2)} \over{1}}}+ {{1 \over{1.3}}{{(x^2/2)^2} \over{1.2}}} + {{1 \over{1.3.5}}{{(x^2/2)^3} \over{1.2.3}} + \dotsb }} \\

&= {1 + {{1 \over{2}}{{(x^2/4)} \over{1!}}}+ {{1 \over{(1/2)(3/2)}}{{(x^2/4)^2} \over{2!}}} + {{1 \over{(1/2)(3/2)(5/2)}}{{(x^2/4)^3} \over{3!}} + \dotsb }} \\

&= F\left(\frac{1}{2}, \frac{x^2}{4}\right)

\end{align*}

It might seem that we are going nowhere, but that is not true. We need just one more piece of information about F and we are done - we need a recurrence relationship. What follows is simplified result of Gauss:

$$ {F(a - 1 , x)} = { F(a , x) + {{x \over{(a - 1)a}}F(a + 1,x)}} $$

(11)

This is proven by demonstrating that the power series are identical (term by term) on both sides of the equation.

We divide both sides of (11) by ${F(a , x)}$ and take the reciprocal of both sides to get:

$$ {F(a , x) \over{F(a - 1 , x)}} = {1 \over {1 + { {x \over{(a - 1)a}}{F(a + 1 , x) \over{F(a , x)}}}}} $$

(13)

Now 'a' could be anything we want in (13). In particular, we can replace it by a+1 to get a new relationship:

$$ {F(a + 1 , x) \over{F(a , x)}} = {1 \over {1 + { {x \over{a (a + 1)}}{F(a + 2 , x) \over{F(a + 1 , x)}}}}} $$

(14)

But the left hand side of (14) is the term in the denominator of the right hand side of (13), so we can substitute:

$$ \frac{F(a,x)}{F(a - 1 , x)} = \cfrac{1}{1+\cfrac{x}{(a-1)a}\left[\cfrac{1}{1+\frac{x}{a(a+1)}\frac{F(a+2,x)}{F(a+1 , x)}}\right]} $$

(15)

We can repeat exactly the same process indefinitely to get:

(16)

It is now time to put everything together. We know the relationship between $\tanh(x)$, $\sinh(x)$ and $\cosh(x)$; we can express the latter two in terms of hypergeometric functions, and it is then apparent that this is just (16) with $a=3/2$:

$$ \tanh(x) = \frac{\sinh(x)}{\cosh(x)} = \frac{xF\left(\frac{3}{2}, \frac{x^2}{4}\right)}{F\left(\frac{1}{2}, \frac{x^2}{4}\right)} = \cfrac{x}{1+\cfrac{\frac{x^2/4}{(1/2)(3/2)}}{1+\cfrac{\frac{x^2/4}{(3/2)(5/2)}}{1+\cfrac{\frac{x^2/4}{(5/2)(7/2)}}{1+\dotsb}}}} $$

(17)

So, with just a little more multiplying numerators and denominators we get:

$$ \tanh(x) = \cfrac{x}{1+\cfrac{x^2}{3+\cfrac{x^2}{5+\cfrac{x^2}{7+\dotsb}}}} $$

We have proved what we set out to and more - we have a continued fraction for $\tanh(x)$ for arbitrary $x$. It may not quite match the complexity of Ramanujan's sum, but it is a start!