In the book **Neverending fractions** from Borwein, van der Poorten, Shallit and Zudilin, there is the so called **distance formula** (Theorem 2.45, p. 43) stated:
$$\alpha\_1\alpha\_2\cdot...\cdot\alpha\_n=\frac{(-1)^n}{p\_{n-1}-q\_{n-1}\alpha}$$


for $n\geq 0$ with $p\_{-1}=1$ and $q\_{-1}=0$, where $$\alpha=[a\_0;a\_1,...,a\_{j-1},\alpha\_j]$$ ($\alpha\_j$ being the tail of the continued fraction development of $\alpha$) and, as usual, $$\frac{p\_n}{q\_n}=[a\_0;a\_1,...,a\_{n}]$$


In the book, the authors explain the name with



> 
> It turns out that one may usefully think of $\left|\log(\left|p\_{n-1}-q\_{n-1}\alpha\right|)\right|$ as measuring the weighted distance that the continued fraction has traversed in moving from $\alpha$ to $\alpha\_n$
> 
> 
> 


My questions are:


1. Does this distance formula only hold for *quadratic* irrationals?
2. Where can I find additional literature / information on this formula? (I couldn't find any other references for it so far)



Distance formula for continued fractions
1. This formula is valid for any continued fraction. But for quadratic irrationals it is especially useful because it allows to express fundamental unit of corresponding field in terms of continued fraction expansion of $\sqrt{n}$. For a reduced quadratic irrational $\omega=[0;\overline{a\_1,\ldots,a\_n}]$ with period $n=\mathrm{per}(\omega)$ we write
$$
 {\mathrm{per}}\_e(\omega)=\begin{cases}
 n, &\text{if $n={\mathrm{per}}(\omega)$ is even;} \\
 2n,&\text{if $n={\mathrm{per}}(\omega)$ is odd.}
 \end{cases}
$$
In this case, the fundamental unit can be found using Smith’s formula
$$
 \varepsilon\_0^{-1}(\omega)=\omega T(\omega)T^2(\omega)\ldots
 T^{\mathrm{per}\_e(\omega)-1}(\omega),
$$
where $T(\alpha)$ stands for the Gauss map:
$T(\alpha)=\left\{{1}/{\alpha}\right\}$.
2. The Smiths article (*Smith H. J. S. Note on the Theory of the Pellian
Equation and of Binary Quadratic Forms of a Positive
Determinant. Proc. London Math. Soc., 1875, s1-7,
196-208.*) is [here.](http://londmathsoc.onlinelibrary.wiley.com/doi/abs/10.1112/plms/s1-7.1.196)


A good book about this topic is *B. A. Venkov, Elementary number theory, ONTI, Moscow 1931; English transl.,
Wolters-Noordhoff Publ., Groningen 1970.* (see [zbmath](https://zbmath.org/?q=an:0204.37101) for review, and chapter 2 for continued fractions).


Applications to quadratic irrationals (Gauss-Kuz'min statistica and distribution of lengths) can be found in [Spin chains and Arnold's problem on the Gauss-Kuz'min statistics for quadratic irrationals.](http://iam.khv.ru/articles/Ustinov/nth34_eng.pdf)


