# Distribution of partial quotients of $\sqrt{d}$ with $X < d \leq 2X$

Recall that for a real number $$\alpha$$, it has a continued fraction expansion usually written as

$$\displaystyle \alpha = [a_0; a_1, a_2, \cdots].$$

Moreover, $$\alpha$$ is rational if and only if its continued fraction expansion is finite, and is a quadratic irrational if and only if the continued fraction expansion is eventually periodic. The numbers $$a_0; a_1, a_2, \cdots$$ are called partial quotients of $$\alpha$$.

It is known that with respect to Lebesgue measure, almost all real numbers $$\alpha$$ have the property that the partial quotients of $$\alpha$$ follow a specific distribution: the frequency that $$k$$ appears in the sequence $$\{a_0; a_1, a_2, \cdots\}$$ is $$\frac{1}{\log 2} \log \left(\frac{(k+1)^2}{k(k+2)} \right)$$.

Consider the interval $$I_X = (X, 2X]$$ for some (large) positive number $$X$$. For each integer $$n \in I_X$$, consider the continued fraction expansion of $$\sqrt{n}$$, say $$\sqrt{n} = [a_0; a_1, a_2, \cdots]$$. We know that this sequence is eventually periodic, and in fact $$\sqrt{n} = [a_0; \overline{a_1, a_2, \cdots, a_2, a_1, 2a_0}]$$ where the bar denotes the periodic part and the string $$a_1, a_2, \cdots, a_2, a_1$$ denotes a palindrome.

My question is: as $$n$$ runs over $$I_X$$, how are the partial quotients of $$\sqrt{n}$$ distributed? In other words, for each positive integer $$k$$ what is the frequency of appearance of $$k$$ as partial quotients of $$\sqrt{n}$$ as $$n$$ runs over $$I_X$$?

Note that the frequency is 0 if $$k \gg X^{1/2}$$, since it is known that the partial quotients of $$\sqrt{n}$$ are at most $$2 \sqrt{n}$$ in size.

For a reduced quadratic irrational $$\omega$$ (which has a purely periodic representation in the form of a continued fraction) denote by $$\rho(\omega)$$ the length of $$\omega$$ which is the length of the corresponding closed geodesic on modular surface $$\mathbb{H}/PSL_2(\mathbb Z)$$, $$\mathbb{H}=\{(x,y):\ y>0\}$$ (the projection of the geodesic joining $$\omega$$ and $$\omega^*$$, where $$\omega^{*}$$ is the number conjugate to $$\omega$$). The answer is positive in the case when you average Gauss-Kuz'min statistics over all $$\omega$$ such that $$\rho(\omega)\le X$$. More precisely, let $$x, y \in [0, 1]$$ be real numbers and $$r(x,y;N)=\sum_{\substack{\omega\in\mathcal{R}\\ \varepsilon_0(\omega)\leqslant N}} [\omega\leqslant x,\ -1/\omega^{*}\leqslant y].$$ Here $$\mathcal{R}$$ is the set of reduced quadratic irrationals, $$\varepsilon_0(\omega)=\frac{1}{2}(x_0+\sqrt{\Delta}y_0)$$ is the fundamental solution of Pell’s equation $$X^2-\Delta Y^2=4,$$ $$\Delta=B^2-4AC$$, where $$AX^2+BX+C$$ is the minimal polynomial of $$\omega$$; moreover, $$[A]$$ stands for $$1$$ if the statement $$A$$ is true and for $$0$$ otherwise. The fundamental solution $$\varepsilon_0(\omega)$$ is clesely connected to the length: $$\rho(\omega)=2\log\varepsilon_0(\omega)$$. Then (see Theorem 3 from Spin chains and Arnold's problem on the Gauss-Kuz'min statistics for quadratic irrationals) $$r(x,y;N)=\frac{\log(1+xy)}{2\zeta(2)}N^2+{O}(N^{3/2}\log^4N).$$