# Closed form for a pair of continued fractions

What is $1+\cfrac{1}{2+\cfrac{1}{3+\cfrac{1}{4+\cdots}}}$ ?

What is $1+\cfrac{2}{1+\cfrac{3}{1+\cdots}}$ ?

It does bear some resemblance to the continued fraction for $e$, which is $2+\cfrac{2}{2+\cfrac{3}{3+\cfrac{4}{4+\cdots}}}$.

Another thing I was wondering: can all transcendental numbers be expressed as infinite continued fractions containing only rational numbers? Of course for almost all transcendental numbers there does not exist any method to determine all the numerators and denominators.

-
The first continued fraction can be written as a ratio $I_0(2)/I_1(2)$ of values of the modified Bessel functions of the first kind. The proof I know of is too long to fit here. I don't know about the second. – Jyrki Lahtonen Oct 3 '11 at 11:33
The proof @Jyrki is alluding to involves the solution of the difference equation $$a_n=(n-1)a_{n-1}+a_{n-2},$$ matching the recurrence with the recurrence for the modified Bessel functions, and considering the asymptotics of the two modified Bessel functions appearing in the solution of the recurrence. – J. M. Oct 3 '11 at 11:55
"can all transcendental numbers be expressed as infinite continued fractions containing only rational numbers" - certainly, you can derive a simple continued fraction for any given number through the cycle of "subtract, reciprocate, truncate (to the greatest integer less than the result of reciprocating)"... – J. M. Oct 3 '11 at 12:02
@J.M. Thanks! The proof I had in mind is a modification of Euler's (or was it Hurwitz ?) result giving the CF expansion of $(e^{2x}+1)/(e^{2x}-1)$ as $[1/x,3/x,5/x,\ldots]$. I was studying that proof from Joe Roberts's NT book (ENT - A Problem Oriented Approach) when I was in school, and gave $[1/x,2/x,3/x,\ldots]$ as an exercise to myself.... I had to look it up now. Looks like it is the same approach that you describe, because one of the steps is a recurrence relation, but the accumulated rust ... – Jyrki Lahtonen Oct 3 '11 at 13:30

The first one is expressible in terms of the modified Bessel function of the first kind:

$$1+\cfrac1{2+\cfrac1{3+\cfrac1{4+\cdots}}}=\frac{I_0(2)}{I_1(2)}=1.433127426722\dots$$

The second one, through an equivalence transformation, can be converted into the following form:

$$1+\cfrac1{\frac12+\cfrac1{\frac23+\cfrac1{\frac38+\cfrac1{b_4+\cdots}}}}$$

where $b_k=\dfrac{k!!}{(k+1)!!}$ and $k!!$ is a double factorial. By Van Vleck, since

$$\sum_{k=1}^\infty \frac{k!!}{(k+1)!!}$$

diverges, the second continued fraction converges. This CF can be shown to be equal to

$$\frac1{\tfrac1{\sqrt{\tfrac{e\pi}{2}}\mathrm{erfc}\left(\tfrac1{\sqrt 2}\right)}-1}=1.904271233329\dots$$

where $\mathrm{erfc}(z)$ is the complementary error function.

Establishing the value of the "continued fraction constant" (a short sketch)

From the modified Bessel differential equation, we can derive the difference equation

$$Z_{n+1}(x)=-\frac{2n}{x}Z_n(x)+Z_{n-1}(x)$$

where $Z_n(x)$ is any of the two solutions $I_n(x)$ or $K_n(x)$. Letting $x=2$, we obtain

$$Z_{n+1}(2)=-n\,Z_n(2)+Z_{n-1}(2)$$

We can divide both sides of the recursion relation with $Z_n(2)$ and rearrange a bit, yielding

$$\frac{Z_n(2)}{Z_{n-1}(2)}=\cfrac1{n+\cfrac{Z_{n+1}(2)}{Z_n(2)}}$$

A similar manipulation can be done in turn for $\dfrac{Z_{n+1}(2)}{Z_n(2)}$; iterating that transformation yields

$$\frac{Z_n(2)}{Z_{n-1}(2)}=\cfrac1{n+\cfrac1{n+1+\cfrac1{n+2+\cdots}}}$$

Now, we don't know if $Z$ is $I$ or $K$; the applicable theorem at this stage is Pincherle's theorem. This states that $Z$ is necessarily the minimal solution of the associated difference equation if and only if the continued fraction converges (which it does, by Śleszyński–Pringsheim). Roughly speaking, the minimal solution of a difference equation is the unique solution that "decays" as the index $n$ increases (all the other solutions, meanwhile, are termed dominant solutions). From the asymptotics of $I$ and $K$, we find that $I$ is the minimal solution of the difference equation ($K$ and any other linear combination of $I$ and $K$ constitute the dominant solutions). By Pincherle, then, the continued fraction has the value $\dfrac{I_n(2)}{I_{n-1}(2)}$. Taking $n=1$ and reciprocating gives the first CF in the OP.

Here's a short Mathematica script for evaluating the "continued fraction constant", which uses the Lentz-Thompson-Barnett method for the evaluation:

prec = 50;
y = N[1, prec]; c = y; d = 0; k = 2;
While[True,
c = k + 1/c; d = 1/(k + d);
h = c*d; y *= h;
If[Abs[h - 1] <= 10^(-prec), Break[]];
k++];
y
1.4331274267223117583171834557759918204315127679060


We can check the agreement with the closed form:

y - BesselI[0, 2]/BesselI[1, 2] // InputForm
049.70728038020511


Alternative expressions for the second continued fraction

Just to thoroughly beat the stuffing out of this question, I'll talk about a few other expressions that are equivalent to the OP's second CF.

One can build the Euler-Minding series of the continued fraction:

$$1+\sum_{k=0}^\infty \frac{(-1)^k (k+2)!}{B_k B_{k+1}}$$

where $B_k$ is the denominator of the $k$-th convergent of the continued fraction, which satisfies the difference equation $B_k=B_{k-1}+(k+1)B_{k-2}$, with initial conditions $B_{-1}=0$, $B_0=1$. OEIS has a record of this sequence, but there is no mention of a closed form.

One can also split the original continued fraction into odd and even parts, yielding the following contractions:

$$3-\cfrac{6}{8-\cfrac{20}{12-\cfrac{42}{16-\cdots}}}\qquad \text{(odd part)}$$

$$\cfrac1{1-\cfrac{2}{6-\cfrac{12}{10-\cfrac{30}{14-\cdots}}}}\qquad \text{(even part)}$$

The utility of these two contractions is that they converge twice as fast as the original continued fraction, as well as providing "brackets" for the value of the continued fraction.

Much, much later:

Prompted by GEdgar's question, I have found that the second CF does have a nice closed form. Here is a derivation:

The iterated integrals of the complementary error function, $\mathrm{i}^n\mathrm{erfc}(z)$ (see e.g. Abramowitz and Stegun) satisfy the difference equation

$$\mathrm{i}^{n+1}\mathrm{erfc}(z)=-\frac{z}{n+1}\mathrm{i}^n\mathrm{erfc}(z)+\frac1{2(n+1)}\mathrm{i}^{n-1}\mathrm{erfc}(z)$$

with initial conditions $\mathrm{i}^0\mathrm{erfc}(z)=\mathrm{erfc}(z)$ and $\mathrm{i}^{-1}\mathrm{erfc}(z)=\dfrac2{\sqrt\pi}\exp(-z^2)$.

This recurrence can be rearranged:

$$\frac{\mathrm{i}^n\mathrm{erfc}(z)}{\mathrm{i}^{n-1}\mathrm{erfc}(z)}=\frac1{2z+2(n+1)\tfrac{\mathrm{i}^{n+1}\mathrm{erfc}(z)}{\mathrm{i}^n\mathrm{erfc}(z)}}$$

Iterating this transformation yields the continued fraction

$$\frac{\mathrm{i}^n\mathrm{erfc}(z)}{\mathrm{i}^{n-1}\mathrm{erfc}(z)}=\cfrac1{2z+\cfrac{2(n+1)}{2z+\cfrac{2(n+2)}{2z+\dots}}}$$

(As a note, $\mathrm{i}^n\mathrm{erfc}(z)$ can be shown to be the minimal solution of its difference equation; thus, by Pincherle, the CF given above is correct.)

In particular, the case $n=0$ gives

$$\frac{\sqrt\pi}{2}\exp(z^2)\mathrm{erfc}(z)=\cfrac1{2z+\cfrac2{2z+\cfrac4{2z+\cfrac6{2z+\dots}}}}$$

If $z=\dfrac1{\sqrt 2}$, then

$$\frac{\sqrt{e\pi}}{2}\mathrm{erfc}\left(\frac1{\sqrt 2}\right)=\cfrac1{\sqrt 2+\cfrac2{\sqrt 2+\cfrac4{\sqrt 2+\cfrac6{\sqrt 2+\dots}}}}$$

We now perform an equivalence transformation. Recall that a general equivalence transformation of a CF

$$b_0+\cfrac{a_1}{b_1+\cfrac{a_2}{b_2+\cfrac{a_3}{b_3+\cdots}}}$$

with some sequence $\mu_k, k>0$ looks like this:

$$b_0+\cfrac{\mu_1 a_1}{\mu_1 b_1+\cfrac{\mu_1 \mu_2 a_2}{\mu_2 b_2+\cfrac{\mu_2 \mu_3 a_3}{\mu_3 b_3+\cdots}}}$$

If we apply this to the CF earlier with $\mu_k=\dfrac1{\sqrt 2}$, then

$$\sqrt{\frac{e\pi}{2}}\mathrm{erfc}\left(\frac1{\sqrt 2}\right)=\cfrac1{1+\cfrac1{1+\cfrac2{1+\cfrac3{1+\dots}}}}$$

Thus,

$$\frac1{\tfrac1{\sqrt{\tfrac{e\pi}{2}}\mathrm{erfc}\left(\tfrac1{\sqrt 2}\right)}-1}=1+\cfrac2{1+\cfrac3{1+\cfrac4{1+\dots}}}$$

-
Nice research there. – robjohn Oct 3 '11 at 12:08
@rob: Not really. :D One of the first things I did in my foray on CFs was prove the SP theorem... and the Bessel thing, I already had in the back of my mind. What took me long to write the answer was copy-pasting links. ;) – J. M. Oct 3 '11 at 12:11
The version of Śleszyński–Pringsheim you cite only seems to talk about convergence. Is there one that talks about divergence? – robjohn Oct 3 '11 at 14:52
@J.M. You can do simpler in Mathematica: {1 + ContinuedFractionK[1, k + 1, {k, 1, 500}], BesselI[0, 2]/ BesselI[1, 2]} // N. Regarding the other CF, please look at Table[1 + ContinuedFractionK[k + 1, 1, {k, 1, n}], {n, 1, 500}] //N // ListPlot, it seems to suggest it converges, what am I doing wrong ? – Sasha Oct 3 '11 at 14:57
Funny. When I saw a double factorial over a double factorial it seemed like you were yelling math at me... – anon Oct 4 '11 at 10:53

I don't know if either of the continued fractions can be expressed in terms of common functions and constants. However, all real numbers can be expressed as a continued fractions containing only integers. The continued fractions terminate for rational numbers, repeat for a quadratic algebraic numbers, and neither terminate nor repeat for other reals.

Shameless plug: There are many references out there for continued fractions. I wrote a short paper that is kind of dry and covers only the basics (nothing close to the results that J. M. cites), but it goes over the results that I mentioned.

-
@Angela: Evidently J. M. knows at least one of your continued fractions. – robjohn Oct 3 '11 at 11:32

I know how to do these. Here is the second question.

First, a more natural one: $$1+\cfrac{1}{1+\cfrac{2}{1+\cfrac{3}{1+\ddots}}}= \frac{1}{\displaystyle e^{1/2}\sqrt{\frac{\pi}{2}}\;\mathrm{erfc}\left(\frac{1}{\sqrt{2}}\right)} \approx 1.525135276\cdots$$ So the original one is $$1+\cfrac{2}{1+\cfrac{3}{1+\ddots}} = \frac{1}{\displaystyle \frac{1}{ e^{1/2}\sqrt{\frac{\pi}{2}}\;\mathrm{erfc}\left(\frac{1}{\sqrt{2}}\right)}-1} \approx 1.9042712\cdots$$

[erfc is here ]

-