We show in this post that an elegant continued fraction for can be found using derangement numbers. Recall from last week’s post that we call any permutation of the elements of a set an *arrangement*. A *derangement* is an arrangement for which every element is moved from its original position.

The number of arrangements of a set of elements is the factorial and the number of derangements is the subfactorial . The connection between and is established using the inclusion-exclusion principle, and we have

In fact, is the nearest whole number to [see previous post].

**Continued Fractions and Convergents**

The continued fraction expansion of an irrational number is written, in expanded form and concise form, as

where are integers. If is positive for this is called a *simple* continued fraction.

The *generalized* continued fraction expansion is written

where and are integers. Truncating the expansion at various points, we obtain the *convergents*

where the numerators and denominators, and , are integers.

We define the starting values

Then, and for are given by recurrence relations:

which may be proved by induction.

This process can be inverted: given a sequence of numerators and denominators (or just their ratios, the convergents ), we can solve (1) for and :

together with the starting values , and .

**Continued Fractions for **

Euler’s number is usually defined as the limit . This is the limit of the sequence

The terms may be regarded as the convergents of a continued fraction,

We can generate a continued fraction by using (2). It begins as

The error of this expansion () as a function of truncation is shown in the figure below (dashed black line). It is clear that the convergence is very slow.

Euler made extensive studies of continued fractions. For example, his 50-page paper, *Observations on continued fractions* (Euler, 1750), contains numerous original results. One of his best-known expansions is

The error of Euler’s expansion is shown in the figure (dotted red line). It converges much faster than (3). There is a clear signal of period 3, consistent with the recurring pattern in (4).

**Continued fraction from derangement numbers**

A beautiful continued fraction emerges from the relationship between arrangements and derangements. We saw above that

If we define the numerators and denominators of convergents to be

we can solve for the factors and . The starting values yield . Then (2) may be solved to yield for . Thus we get the expansion

A small adjustment enables us to write this in the elegant form

The error of (5) is shown in the figure above (solid blue line). Convergence is more rapid than for the other two expansions.

For a more detailed discussion, and connection with *The Ramanujan Machine*, see Lynch (2020).

**References**

Euler, L., 1750: De fractionibus continuis observationes. *Commentarii academiae scientiarum Petropolitanae*, **11**, 32–81. Reprinted in *Opera Omnia*, Series 1, **14**, 291–349. Translation by Alexander Aycock: *Observations on continued fractions*. PDF .

Lynch, Peter 2020: Derangements and Continued Fractions for *e*. eprint on arXiv .

* * * * *

**That’s Maths II: A Ton of Wonders**

by Peter Lynch has just appeared.

Full details and links to suppliers at

http://logicpress.ie/2020-3/

* * * * *