###### Proof.

Limit laws of maximal Birkhoff sums for circle rotations via quantum modular
forms

Bence Borda

Graz University of Technology

Steyrergasse 30, 8010 Graz, Austria

Email<EMAIL_ADDRESS>
Keywords: continued fraction, Gauss map, Ostrowski expansion, Farey fraction,

quadratic irrational, Kashaev invariant, Sudler product

Mathematics Subject Classification (2020): 37A50, 37E10, 11F37, 11K60

###### Abstract

In this paper, we show how quantum modular forms naturally arise in the
ergodic theory of circle rotations. Working with the classical Birkhoff sum
$S_{N}(\alpha)=\sum_{n=1}^{N}(\\{n\alpha\\}-1/2)$, we prove that the maximum
and the minimum as well as certain exponential moments of $S_{N}(r)$ as
functions of $r\in\mathbb{Q}$ satisfy a direct analogue of Zagier’s continuity
conjecture, originally stated for a quantum invariant of the figure-eight
knot. As a corollary, we find the limit distribution of $\max_{0\leq
N<M}S_{N}(\alpha)$ and $\min_{0\leq N<M}S_{N}(\alpha)$ with a random
$\alpha\in[0,1]$.

##  1 Introduction

The main goal of this paper is to introduce methods originally developed in
connection with Zagier’s quantum modular forms [22] to the ergodic theory of
circle rotations. We demonstrate the power of these tools by considering the
classical Birkhoff sum $S_{N}(\alpha)=\sum_{n=1}^{N}(\\{n\alpha\\}-1/2)$,
where $\\{\cdot\\}$ denotes the fractional part function. The history of the
sum $S_{N}(\alpha)$ goes back a hundred years to Hardy and Littlewood [11,
12], Hecke [14] and Ostrowski [19], with the original motivation coming from
Diophantine approximation, lattice point counting in triangles and analytic
number theory. We have $S_{N}(\alpha)=o(N)$ for any irrational $\alpha$, but
the precise behavior is rather delicate and depends on the Diophantine
properties of $\alpha$. It is enough to consider $\alpha\in[0,1]$, and we
shall focus on the case of a randomly chosen $\alpha$.

Throughout, $X\sim\mu$ denotes the fact that a random variable $X$ has
distribution $\mu$, $\mu\otimes\nu$ denotes the product measure of $\mu$ and
$\nu$, and $\overset{d}{\to}$ denotes convergence in distribution. The
standard stable law of stability parameter $1$ and skewness parameter $\pm 1$,
denoted by $\mathrm{Stab}(1,\pm 1)$, is the law with characteristic function
$\exp(-|x|(1\pm i\frac{2}{\pi}\mathrm{sgn}(x)\log|x|))$. The standard stable
law of stability parameter $1$ and skewness parameter $0$ is in fact the
standard Cauchy distribution with characteristic function $\exp(-|x|)$ and
density function $1/(\pi(1+x^{2}))$, and will be denoted simply by “Cauchy”.

The first distributional result is due to Kesten [17], who proved that if
$(\alpha,\beta)\sim\mathrm{Unif}([0,1]^{2})$, then

$\frac{\sum_{n=1}^{N}\left(\\{n\alpha+\beta\\}-1/2\right)}{\sigma\log
N}\overset{d}{\to}\mathrm{Cauchy}$ (1)

as $N\to\infty$, with an explicit constant $\sigma>0$. Note that in addition
to $\alpha$, the starting point $\beta$ of the orbit is also chosen randomly,
independently of $\alpha$. Whether a similar limit law holds for a fixed value
of $\beta$ is still open. Dolgopyat and Sarig [9] showed, however, that for
any fixed $\beta\in\mathbb{R}$ and
$(\alpha,N)\sim\mathrm{Unif}([0,1]\times\\{1,2,\ldots,M\\})$, the limit law
(1) holds as $M\to\infty$ with the different constant
$\sigma=\frac{1}{3\pi\sqrt{3}}$. Let us also mention a theorem of Beck [4]
concerning $\beta=0$, a fixed quadratic irrational $\alpha$ and
$N\sim\mathrm{Unif}(\\{1,2,\ldots,M\\})$, in which case
$(S_{N}(\alpha)-c_{1}\log N)/(c_{2}\sqrt{\log N})$ converges in distribution
to the standard Gaussian with suitable constants $c_{1}\in\mathbb{R}$ and
$c_{2}>0$ depending on $\alpha$.

In this paper, we work with $S_{N}(\alpha)=\sum_{n=1}^{N}(\\{n\alpha\\}-1/2)$
with the fixed starting point $\beta=0$, and instead of choosing $N$ randomly,
we consider the extreme values $\max_{0\leq N<M}S_{N}(\alpha)$ and
$\min_{0\leq N<M}S_{N}(\alpha)$ as well as certain exponential moments of the
values $S_{N}(\alpha)$, $0\leq N<M$. Our main distributional result is a limit
law for the joint distribution of the maximum and the minimum.

######  Theorem 1.

Let $\alpha\sim\mu$ with a Borel probability measure $\mu$ on $[0,1]$ which is
absolutely continuous with respect to the Lebesgue measure. Then

$\left(\frac{\displaystyle{\max_{0\leq
N<M}S_{N}(\alpha)-E_{M}}}{\sigma_{M}},\frac{\displaystyle{\min_{0\leq
N<M}S_{N}(\alpha)+E_{M}}}{\sigma_{M}}\right)\overset{d}{\to}\mathrm{Stab}(1,1)\otimes\mathrm{Stab}(1,-1)\qquad\textrm{as
}M\to\infty,$

where $E_{M}=\frac{3}{4\pi^{2}}\log M\log\log M+D_{\infty}\log M$ with some
constant $D_{\infty}\in\mathbb{R}$, and $\sigma_{M}=\frac{3}{8\pi}\log M$.

In particular,

$\frac{\displaystyle{\max_{0\leq
N<M}S_{N}(\alpha)-E_{M}}}{\sigma_{M}}\overset{d}{\to}\mathrm{Stab}(1,1)\qquad\textrm{and}\qquad\frac{\displaystyle{\min_{0\leq
N<M}S_{N}(\alpha)+E_{M}}}{\sigma_{M}}\overset{d}{\to}\mathrm{Stab}(1,-1).$

The fact that the limit distribution in Theorem 1 is a product measure means
that the maximum and the minimum of $S_{N}(\alpha)$ are asymptotically
independent. The formulation as a joint limit law has the advantage that we
immediately obtain limit laws for quantities such as $\max-\min$ (the diameter
of the range of $S_{N}(\alpha)$, $0\leq N<M$), and for $(\max+\min)/2$ (the
center of the range) as well:

$\frac{\displaystyle{\max_{0\leq N<M}S_{N}(\alpha)-\min_{0\leq
N<M}S_{N}(\alpha)-B_{M}}}{2\sigma_{M}}\overset{d}{\to}\mathrm{Stab}(1,1),\quad\frac{\displaystyle{\max_{0\leq
N<M}S_{N}(\alpha)+\min_{0\leq
N<M}S_{N}(\alpha)}}{2\sigma_{M}}\overset{d}{\to}\mathrm{Cauchy}$

with $B_{M}=2E_{M}+\frac{4}{\pi}(\log 2)\sigma_{M}$. Indeed, if
$X,Y\sim\mathrm{Stab}(1,1)$ are independent random variables, then
$-X\sim\mathrm{Stab}(1,-1)$, $\frac{X+Y}{2}-\frac{2}{\pi}\log
2\sim\mathrm{Stab}(1,1)$ and $\frac{X-Y}{2}\sim\mathrm{Cauchy}$, as can be
easily seen from the characteristic functions. Theorem 1 similarly implies
that

$\frac{\displaystyle{\max_{0\leq
N<M}|S_{N}(\alpha)|-E_{M}}}{\sigma_{M}}\overset{d}{\to}\max\\{X,Y\\}\qquad\textrm{as
}M\to\infty.$

The cumulative distribution function of $\max\\{X,Y\\}$ is simply the square
of that of $\mathrm{Stab}(1,1)$.

Limit laws of Birkhoff sums for circle rotations
$\sum_{n=1}^{N}f(n\alpha+\beta)$ with some of the parameters $N,\alpha,\beta$
chosen randomly have also been established for other $1$-periodic functions
$f$, such as the indicator of a subinterval of $[0,1]$ extended with period
$1$, or smooth functions with a logarithmic or power singularity. We refer to
[8] for an exhaustive survey. In an upcoming paper we will prove similar limit
laws for the maximum and the minimum of $\sum_{n=1}^{N}f(n\alpha)$ with $f$
the indicator of a subinterval of $[0,1]$ extended with period $1$, using
methods unrelated to the present paper.

Our approach relies on continued fractions and Ostrowski’s explicit formula
for $S_{N}(\alpha)$, see Lemma 9 below. We will actually work with $S_{N}(r)$
with rational $r$ instead of an irrational $\alpha$, and eventually let $r$ be
a suitable best rational approximation to a random $\alpha$. As the main
ingredient in the proof of our limit laws, we will show that while
$\max_{0\leq N<q}S_{N}(r)$ and $\min_{0\leq N<q}S_{N}(r)$ are rather
complicated as functions of the variable $r\in(0,1)\cap\mathbb{Q}$, the
functions

$h_{\infty}(r)=\max_{0\leq N<q}S_{N}(r)-\max_{0\leq
N<q^{\prime}}S_{N}(T^{2}r)\qquad\textrm{and}\qquad h_{-\infty}(r)=\min_{0\leq
N<q}S_{N}(r)-\min_{0\leq N<q^{\prime}}S_{N}(T^{2}r)$

have better analytic properties in the sense that they can be extended to
almost everywhere continuous functions on $[0,1]$; see Figures 1 and 2 below.
Here $T^{2}$ is the second iterate of the Gauss map, and $q$ resp.
$q^{\prime}$ denotes the denominator of $r$ resp. $T^{2}r$ in their reduced
forms. This makes the functions $\max_{0\leq N<q}S_{N}(r)$ and $\min_{0\leq
N<q}S_{N}(r)$ close relatives of Zagier’s quantum modular forms, an
observation we believe to be of independent interest.

We argue that $S_{N}(\alpha)$ shows a close similarity to
$\tilde{S}_{N}(\alpha)=\sum_{n=1}^{N}\log|2\sin(\pi n\alpha)|$, the Birkhoff
sum with the $1$-periodic function $\log|2\sin(\pi x)|$ having logarithmic
singularities at integers. This similarity is not surprising considering that
$\tilde{S}_{N}(\alpha)$ and $\pi S_{N}(\alpha)$ are the real and the imaginary
part of the complex-valued Birkhoff sum $\sum_{n=1}^{N}\log(1-e^{2\pi
in\alpha})$, defined with the principal branch of the logarithm. Note that
$e^{\tilde{S}_{N}(\alpha)}=\prod_{n=1}^{N}|1-e^{2\pi in\alpha}|$ is the so-
called Sudler product, a classical object in its own right introduced by
Sudler [21] and Erdős and Szekeres [10]. Confirming a conjecture of Zagier, in
a recent paper Aistleitner and the author [1] proved that while $\max_{0\leq
N<q}\tilde{S}_{N}(r)$ and $\min_{0\leq N<q}\tilde{S}_{N}(r)$ exhibit
complicated behavior, the functions

$\tilde{h}_{\infty}(r)=\max_{0\leq N<q}\tilde{S}_{N}(r)-\max_{0\leq
N<q^{\prime}}\tilde{S}_{N}(Tr)\qquad\textrm{and}\qquad\tilde{h}_{-\infty}(r)=\min_{0\leq
N<q}\tilde{S}_{N}(r)-\min_{0\leq N<q^{\prime}}\tilde{S}_{N}(Tr)$

can be extended to almost everywhere continuous functions on $[0,1]$. The
results of the present paper suggest that such behavior is more prevalent than
the original scope of Zagier’s continuity conjecture.

It is rather surprising that the functions $h_{\pm\infty}$ and
$\tilde{h}_{\pm\infty}$ with such a pathological behavior hold the key to
limit laws such as Theorem 1. Improving our earlier result [7, Theorem 10], in
this paper we also prove that if $\alpha\sim\mu$ with an absolutely continuous
probability measure $\mu$ on $[0,1]$, then

$\frac{\displaystyle{\max_{0\leq
N<M}\tilde{S}_{N}(\alpha)-\tilde{E}_{M}}}{\tilde{\sigma}_{M}}\overset{d}{\to}\mathrm{Stab}(1,1)\qquad\textrm{as
}M\to\infty,$ (2)

where $\tilde{E}_{M}=\frac{3\mathrm{Vol}(4_{1})}{\pi^{3}}\log M\log\log
M+\tilde{D}_{\infty}\log M$ and
$\tilde{\sigma}_{M}=\frac{3\mathrm{Vol}(4_{1})}{2\pi^{2}}\log M$, with

$\mathrm{Vol}(4_{1})=4\pi\int_{0}^{5/6}\log|2\sin(\pi
x)|\,\mathrm{d}x=2.02988\ldots$

denoting the hyperbolic volume of the complement of the figure-eight knot (see
Section 2) and some constant $\tilde{D}_{\infty}\in\mathbb{R}$. The maximum
and the minimum now determine each other via the relation

$\max_{0\leq N<M}\tilde{S}_{N}(\alpha)+\min_{0\leq
N<M}\tilde{S}_{N}(\alpha)=\log M+o(\log M)\qquad\textrm{in $\mu$-measure},$

which easily follows from [2, Eq. (17)]. This immediately yields a limit law
for $\min_{0\leq N<M}\tilde{S}_{N}(\alpha)$ as well, and shows that in
contrast to Theorem 1, the joint distribution of

$\left(\frac{\displaystyle{\max_{0\leq
N<M}\tilde{S}_{N}(\alpha)-\tilde{E}_{M}}}{\tilde{\sigma}_{M}},\frac{\displaystyle{\min_{0\leq
N<M}\tilde{S}_{N}(\alpha)+\tilde{E}_{M}}}{\tilde{\sigma}_{M}}\right)$

converges to a probability measure supported on a straight line in
$\mathbb{R}^{2}$ instead of a product measure. The difference in the
definition of $h_{\pm\infty}$ and $\tilde{h}_{\pm\infty}$ (second vs. first
iterate of the Gauss map) and in the joint behavior of the maximum and the
minimum (asymptotically independent vs. asymptotically deterministic)
ultimately boils down to the fact that $S_{N}(\alpha)$ is odd, whereas
$\tilde{S}_{N}(\alpha)$ is even in the variable $\alpha$. See also [13, 18]
for the asymptotics of $\tilde{S}_{N}(\alpha)$ at a.e. $\alpha$.

In contrast to random reals, for a badly approximable irrational $\alpha$ we
have $S_{N}(\alpha)=O(\log N)$, and this is sharp since

$\limsup_{N\to\infty}\frac{S_{N}(\alpha)}{\log
N}>0\qquad\textrm{and}\qquad\liminf_{N\to\infty}\frac{S_{N}(\alpha)}{\log
N}<0,$ (3)

as shown by Ostrowski [19]. For a quadratic irrational $\alpha$, we can say
more: general results of Schoissengeier [20] on $S_{N}(\alpha)$ immediately
imply that

$\max_{0\leq N<M}S_{N}(\alpha)=C_{\infty}(\alpha)\log
M+O(1)\qquad\textrm{and}\qquad\min_{0\leq
N<M}S_{N}(\alpha)=C_{-\infty}(\alpha)\log M+O(1)$ (4)

with some explicitly computable constants $C_{\infty}(\alpha)>0$ and
$C_{-\infty}(\alpha)<0$, and implied constants depending only on $\alpha$.
Note that $C_{\infty}(\alpha)$ resp. $C_{-\infty}(\alpha)$ is the value of the
limsup resp. liminf in (3). For example, we have

$C_{\pm\infty}(\sqrt{2})=\pm\frac{1}{8\log(1+\sqrt{2})},\quad
C_{\infty}(\sqrt{3})=\frac{1}{4\log(2+\sqrt{3})},\quad
C_{-\infty}(\sqrt{3})=-\frac{1}{12\log(2+\sqrt{3})}.$

Similar results hold for $\tilde{S}_{N}(\alpha)$. For all badly approximable
irrational $\alpha$ we have $\tilde{S}_{N}(\alpha)=O(\log N)$, and this is
sharp since $\limsup_{N\to\infty}\tilde{S}_{N}(\alpha)/\log N\geq 1$ for all
(not necessarily badly approximable) irrationals [18]. For a quadratic
irrational $\alpha$, we similarly have [2]

$\max_{0\leq N<M}\tilde{S}_{N}(\alpha)=\tilde{C}_{\infty}(\alpha)\log
M+O(1)\qquad\textrm{and}\qquad\min_{0\leq
N<M}\tilde{S}_{N}(\alpha)=\tilde{C}_{-\infty}(\alpha)\log M+O(1).$

Here the constants $\tilde{C}_{\infty}(\alpha)\geq 1$ and
$\tilde{C}_{-\infty}(\alpha)\leq 0$ are related by
$\tilde{C}_{\infty}(\alpha)+\tilde{C}_{-\infty}(\alpha)=1$, but their explicit
value is known only for a few simple quadratic irrationals such as the golden
mean or $\sqrt{2}$ (in both cases $\tilde{C}_{\infty}=1$ and
$\tilde{C}_{-\infty}=0$). Thus, once again, the maximum and the minimum of
$\tilde{S}_{N}(\alpha)$ determine each other, unlike those of $S_{N}(\alpha)$
for which the constants $C_{\infty}(\alpha)$ and $C_{-\infty}(\alpha)$ do not
satisfy a simple relation. We refer to our earlier paper [7] for a central
limit theorem for the joint distribution of
$(S_{N}(\alpha),\tilde{S}_{N}(\alpha))$ with a fixed quadratic irrational
$\alpha$ and $N\sim\mathrm{Unif}(\\{1,2,\ldots,M\\})$.

We elaborate on the connection to quantum modular forms, and state our main
related results in Section 2. The main limit laws, including more general
forms of Theorem 1 and formula (2) together with analogue results for random
rationals are stated in Section 3. The proofs are given in Sections 4, 5 and
6.

##  2 Connections to quantum modular forms

A quantum modular form is a real- or complex-valued function $f$ defined on
$\mathbb{P}^{1}(\mathbb{Q})=\mathbb{Q}\cup\\{\infty\\}$ (except perhaps at
finitely many points) which satisfies a certain approximate modularity
relation under the action of $\mathrm{SL}(2,\mathbb{Z})$ with fractional
linear transformations on $\mathbb{P}^{1}(\mathbb{Q})$. Instead of stipulating
$f(\gamma r)=f(r)$ for any $\gamma\in\mathrm{SL}(2,\mathbb{Z})$ (true
modularity), the functions $h_{\gamma}(r)=f(\gamma r)-f(r)$ are required,
roughly speaking, to enjoy better continuity/analyticity properties than $f$
itself in the real topology on $\mathbb{P}^{1}(\mathbb{Q})$ (approximate
modularity). Most known examples of quantum modular forms come from algebraic
topology or analytic number theory.

Given a parameter $-\infty\leq p\leq\infty$, $p\neq 0$ and a rational number
$r$ whose denominator in its reduced form is $q$, define

$\tilde{J}_{p}(r)=\left(\sum_{N=1}^{q-1}\prod_{n=1}^{N}|1-e^{2\pi
inr}|^{p}\right)^{1/p}\qquad p\neq\pm\infty,0,$

and

$\tilde{J}_{\infty}(r)=\max_{0\leq N<q}\prod_{n=1}^{N}|1-e^{2\pi
inr}|,\qquad\tilde{J}_{-\infty}(r)=\min_{0\leq N<q}\prod_{n=1}^{N}|1-e^{2\pi
inr}|,$

where $\prod_{n=1}^{N}|1-e^{2\pi inr}|$ is the Sudler product. The function
$\tilde{J}_{p}(r)$ is $1$-periodic and even in the variable $r$, and by [2,
Proposition 2] it also satisfies the identity
$\tilde{J}_{-p}(r)=q/\tilde{J}_{p}(r)$.

The original motivation came from algebraic topology, as $\tilde{J}_{2}^{2}$
is (an extension of) the so-called Kashaev invariant of the figure-eight knot
$4_{1}$. The asymptotics along the sequence of rationals $r=1/q$,
$q\in\mathbb{N}$ is

$\log\tilde{J}_{2}(1/q)=\frac{\mathrm{Vol}(4_{1})}{4\pi}q+\frac{3}{4}\log
q-\frac{1}{8}\log 3+o(1)\qquad\textrm{as }q\to\infty,$ (5)

where $\mathrm{Vol}(4_{1})$ is the hyperbolic volume of the complement of the
figure-eight knot [3]. A similar asymptotic result for the Kashaev invariant
of general hyperbolic knots is known as the volume conjecture, with a full
asymptotic expansion in $q$ predicted by the arithmeticity conjecture. Both
conjectures have been solved for certain simple hyperbolic knots such as the
figure-eight knot, but are open in general.

Calling $\tilde{J}_{2}$ “the most mysterious and in many ways the most
interesting” example of a quantum modular form, Zagier [22] formulated several
conjectures about its behavior under the action of $\mathrm{SL}(2,\mathbb{Z})$
on its argument by fractional linear transformations, including a far-reaching
generalization of (5) known as the modularity conjecture. Zagier’s modularity
conjecture has a more general form which applies to all hyperbolic knots, but
it has only been solved for certain simple knots such as the figure-eight knot
[6], and remains open in general. We refer to [6] for further discussion on
the arithmetic properties of quantum invariants of hyperbolic knots.

Since the fractional linear maps $r\mapsto r+1$ and $r\mapsto-1/r$ generate
the full modular group, and the first of these transformations acts trivially
on the argument of $\tilde{J}_{p}(r)$, the function

$\tilde{h}_{p}(r)=\log\frac{\tilde{J}_{p}(r)}{\tilde{J}_{p}(-1/r)},\qquad
r\in\mathbb{Q}\backslash\\{0\\}$

is the key to understanding the action of $\mathrm{SL}(2,\mathbb{Z})$. Observe
that $\tilde{h}_{-p}(r)=-\tilde{h}_{p}(r)$, hence it is enough to consider
$p>0$. Numerical evidence presented by Zagier suggests that $\tilde{h}_{2}$ is
continuous but not differentiable at every irrational, and that it has a jump
discontinuity at every rational but is smooth as we approach a rational from
one side. The continuity of $\tilde{h}_{2}$ at all irrationals is now known as
Zagier’s continuity conjecture. Aistleitner and the author [1] proved that
$\tilde{h}_{p}$ can be extended to a function on $\mathbb{R}$ which is
continuous at every irrational $\alpha=[a_{0};a_{1},a_{2},\ldots]$ such that
$\sup_{k\in\mathbb{N}}a_{k}=\infty$, thereby confirming Zagier’s continuity
conjecture almost everywhere. In the same paper it was further shown that

$\tilde{h}_{p}(r)=\frac{\mathrm{Vol}(4_{1})}{4\pi
r}+O\left(1+\log\frac{1}{r}\right),\qquad r\in(0,1)\cap\mathbb{Q}$ (6)

with an implied constant depending only on $p$ (but it is uniform once $p$ is
bounded away from $0$). Numerical experiments suggest that in fact

$\tilde{h}_{p}(r)=\frac{\mathrm{Vol}(4_{1})}{4\pi
r}+\frac{p+1}{2p}\log\frac{1}{r}+O(1),\qquad r\in(0,1)\cap\mathbb{Q}.$

Note that in [1] these results were stated only for $p=2$, but the proof works
mutatis mutandis for all $0<p\leq\infty$.

In this paper, we interpret $\tilde{J}_{p}$ as a natural quantity related to
the Birkhoff sum $\tilde{S}_{N}(r)=\sum_{n=1}^{N}\log|2\sin(\pi nr)|$, and
$\tilde{h}_{p}$ as the key to understanding the action of the Gauss map $T$ on
the argument of $\tilde{J}_{p}$. Recall that $T:[0,1)\to[0,1)$ is defined as
$Tx=\\{1/x\\}$, $x\neq 0$ and $T0=0$, thus
$\tilde{h}_{p}(r)=\log(\tilde{J}_{p}(r)/\tilde{J}_{p}(Tr))$. We show that the
Birkhoff sum $S_{N}(r)=\sum_{n=1}^{N}(\\{nr\\}-1/2)$ yields a function
$J_{p}(r)$ which exhibits remarkable similarity to $\tilde{J}_{p}(r)$, thus
demonstrating that quantum modular behavior can also naturally arise in
ergodic theory. It would be very interesting to find further examples of
Birkhoff sums, either for circle rotations or more general dynamical systems,
with a similarly rich arithmetic structure.

Given a parameter $-\infty\leq p\leq\infty$, $p\neq 0$ and a rational number
$r$ whose denominator in its reduced form is $q$, we thus define

$J_{p}(r)=\left(\sum_{N=0}^{q-1}e^{pS_{N}(r)}\right)^{1/p},\qquad
p\neq\pm\infty,0,$

and

$J_{\infty}(r)=\max_{0\leq N<q}e^{S_{N}(r)},\qquad J_{-\infty}(r)=\min_{0\leq
N<q}e^{S_{N}(r)}.$

Note that these are perfect analogues of $\tilde{J}_{p}(r)$ with $S_{N}(r)$
playing the role of $\tilde{S}_{N}(r)$. Using the fact that $S_{N}(r)$ is
$1$-periodic and odd in the variable $r$, we immediately observe the
identities $J_{p}(r+1)=J_{p}(r)$ and $J_{-p}(r)=1/J_{p}(-r)$. In order to
reveal the arithmetic structure of $J_{p}$, we introduce the function

$h_{p}(r)=\log\frac{J_{p}(r)}{J_{p}(T^{2}r)},\qquad r\in[0,1)\cap\mathbb{Q},$

where $T^{2}$ is the second iterate of the Gauss map.

Figure 1: The function $\log J_{\infty}(r)=\max_{0\leq N<q}S_{N}(r)$ evaluated
at all reduced rationals in $[0,1]$ with denominator at most $150$. The graph
of $\log J_{p}(r)$ with $0<p<\infty$ looks very similar, whereas the graph of
$\log J_{-p}(r)=-\log J_{p}(-r)$ is obtained by reflections.

The analogue of (5) for $J_{p}$ is completely straightforward. Indeed, for
$r=1/q$, $q\in\mathbb{N}$, we have

$S_{N}(1/q)=\sum_{n=1}^{N}\left(\frac{n}{q}-\frac{1}{2}\right)=\frac{N(N+1-q)}{2q},\qquad
0\leq N<q,$

and it is an easy exercise to show that (cf. Lemma 15 below)

$h_{p}(1/q)=\log
J_{p}(1/q)=\left\\{\begin{array}[]{ll}\frac{1}{p}\log\frac{2}{1-e^{-p/2}}+o(1)&\textrm{if
}0<p<\infty,\\\ -\frac{q}{8}+\frac{1}{2p}\log\frac{2\pi
q}{|p|}+\frac{1}{4}+o(1)&\textrm{if
}-\infty<p<0\end{array}\right.\qquad\textrm{as }q\to\infty.$ (7)

Since $S_{N}(1/q)$, $0\leq N<q$ attains its maximum at $N=0,q-1$ and its
minimum at $N=\lfloor\frac{q-1}{2}\rfloor,\lceil\frac{q-1}{2}\rceil$, for
$p=\pm\infty$ we even have the explicit formulas

$h_{\infty}(1/q)=\log J_{\infty}(1/q)=0\qquad\textrm{and}\qquad
h_{-\infty}(1/q)=\log
J_{-\infty}(1/q)=-\frac{q}{8}+\frac{1}{4}-\frac{1}{8q}\mathds{1}_{\\{q\textrm{
odd}\\}}.$

As a direct analogue of (6), we establish a far-reaching generalization of the
asymptotics (7) to general rationals.

######  Theorem 2.

For any $-\infty\leq p\leq\infty$, $p\neq 0$ and any
$r\in(0,1)\cap\mathbb{Q}$,

$h_{p}(r)=\left\\{\begin{array}[]{ll}\mathds{1}_{\\{Tr\neq
0\\}}\left(\frac{1}{8Tr}+\frac{1}{2p}\log\frac{1}{Tr}\right)+O\left(\max\\{1,\frac{1}{p}\log\frac{1}{p}\\}\right)&\textrm{if
}p>0,\\\
-\frac{1}{8r}+\frac{1}{2p}\log\frac{1}{r}+O\left(\max\\{1,\frac{1}{|p|}\log\frac{1}{|p|}\\}\right)&\textrm{if
}p<0\end{array}\right.$

with a universal implied constant.

We can express Theorem 2 in terms of the continued fraction expansion
$r=[0;a_{1},a_{2},\ldots,a_{L}]$ of $r\in(0,1)\cap\mathbb{Q}$ as

$h_{p}(r)=\left\\{\begin{array}[]{ll}\frac{a_{2}}{8}+\frac{1}{2p}\log
a_{2}+O\left(\max\\{1,\frac{1}{p}\log\frac{1}{p}\\}\right)&\textrm{if }p>0,\\\
-\frac{a_{1}}{8}+\frac{1}{2p}\log
a_{1}+O\left(\max\\{1,\frac{1}{|p|}\log\frac{1}{|p|}\\}\right)&\textrm{if
}p<0.\end{array}\right.$

######  Remark.

In all our results, it does not matter which of the two possible continued
fraction expansions we choose for a rational number. In particular, to avoid
the tedious case distinction between the length of the continued fraction
being $L=1$ or $L\geq 2$, we consider the second partial quotient of
$r=1/q=[0;q]=[0;q-1,1]$ (when $Tr=0$) to be well defined as $a_{2}=1$.

(a) $h_{\infty}(r)$

(b) $h_{-\infty}(r)$

Figure 2: The functions $h_{\pm\infty}(r)$ evaluated at all reduced rationals
in $[0,1)$ with denominator at most $150$. The asymptotics $1/(8Tr)$ resp.
$-1/(8r)$ in Theorem 2 give a close fit to the graphs.

Our next result concerns the continuity of $h_{p}$ at irrationals, as an
analogue of Zagier’s continuity conjecture. For the sake of readability, from
now on we use the notation

$\varepsilon_{p}=\left\\{\begin{array}[]{ll}2&\textrm{if }p>0,\\\ 1&\textrm{if
}p<0.\end{array}\right.$ (8)

######  Theorem 3.

Let $-\infty\leq p\leq\infty$, $p\neq 0$, and let $\alpha\in(0,1)$ be an
irrational whose continued fraction expansion $\alpha=[0;a_{1},a_{2},\ldots]$
satisfies $\sup_{k\in\mathbb{N}}a_{2k+\varepsilon_{p}}=\infty$. Then
$\lim_{r\to\alpha}h_{p}(r)$ exists and is finite. In particular, $h_{p}$ can
be extended to a function on $[0,1]$ which is continuous at every irrational
$\alpha$ which satisfies $\sup_{k\in\mathbb{N}}a_{2k+\varepsilon_{p}}=\infty$.

Recall that Lebesgue-a.e. $\alpha$ satisfies
$\sup_{k\in\mathbb{N}}a_{2k}=\infty$ and
$\sup_{k\in\mathbb{N}}a_{2k+1}=\infty$. In particular, the extension of
$h_{p}$ is a.e. continuous. We conjecture that the condition
$\sup_{k\in\mathbb{N}}a_{2k+\varepsilon_{p}}=\infty$ can be removed, so that
Theorem 3 holds for all (including badly approximable) irrationals.

In contrast, $h_{p}$ has a different behavior at rational numbers. The left-
hand limit for $p>0$, and the right-hand limit for $p<0$ exist and are finite
at all rationals, and their values are explicitly computable.

######  Theorem 4.

Let $a/q\in(0,1)$ and $a^{\prime}/q^{\prime}=T^{2}(a/q)\in[0,1)$ be reduced
rationals, and set

$W_{p}(a/q)=\frac{1}{p}\log\frac{\sum_{N=0}^{q-1}e^{p(S_{N}(a/q)-\mathrm{sgn}(p)N/(2q))}}{\sum_{N=0}^{q^{\prime}-1}e^{p(S_{N}(a^{\prime}/q^{\prime})-\mathrm{sgn}(p)N/(2q^{\prime}))}}+\frac{\lfloor
q/a\rfloor(\mathrm{sgn}(p)2a-1)}{8qq^{\prime}},\qquad p\neq\pm\infty,0,$

and

$\begin{split}W_{\infty}(a/q)&=\max_{0\leq
N<q}\left(S_{N}(a/q)-\frac{N}{2q}\right)-\max_{0\leq
N<q^{\prime}}\left(S_{N}(a^{\prime}/q^{\prime})-\frac{N}{2q^{\prime}}\right)+\frac{\lfloor
q/a\rfloor(2a-1)}{8qq^{\prime}},\\\ W_{-\infty}(a/q)&=\min_{0\leq
N<q}\left(S_{N}(a/q)+\frac{N}{2q}\right)-\min_{0\leq
N<q^{\prime}}\left(S_{N}(a^{\prime}/q^{\prime})+\frac{N}{2q^{\prime}}\right)+\frac{\lfloor
q/a\rfloor(-2a-1)}{8qq^{\prime}}.\end{split}$

  1. (i)

If $-\infty\leq p<0$, then
$\displaystyle{\lim_{r\to(a/q)^{+}}h_{p}(r)=W_{p}(a/q)}$.

  2. (ii)

If $0<p\leq\infty$ and $a\neq 1$, then
$\displaystyle{\lim_{r\to(a/q)^{-}}h_{p}(r)=W_{p}(a/q)}$.

Note that we excluded the rationals $1/q$ for $p>0$. Since $Tr\to\infty$ as
$r\to(1/q)^{-}$, Theorem 2 implies that in this case
$\lim_{r\to(1/q)^{-}}h_{p}(r)=\infty$. As for approaching a rational point
from the opposite side, numerical experiments suggest that $h_{p}$ is right-
continuous for $0<p\leq\infty$, and left-continuous for $-\infty\leq p<0$ at
all rationals not of the form $1/q$.

(a) $h_{\infty}(r)$

(b) $h_{2}(r)$

Figure 3: The functions $h_{\infty}(r)$ and $h_{2}(r)$ evaluated at all
reduced rationals in the interval $[0.37,0.38]$ with denominator at most
$600$. At the point $3/8=0.375$ the values are $h_{\infty}(3/8)=1/8$ and
$h_{2}(3/8)=0.650008\ldots$. By Theorem 4, the left-hand limits at $3/8$ are
$W_{\infty}(3/8)=5/64=0.078125$ and $W_{2}(3/8)=0.640180\ldots$. The graphs
suggest right-continuity at $3/8$.

In addition to the pathological limit behavior (continuity at irrationals but
jumps at rationals), the functions $h_{p}$ also seem to have a clear self-
similar structure, which becomes visible after subtracting the asymptotics
established in Theorem 2. A self-similar structure of $\tilde{h}_{p}$ was
numerically observed in [1, 6]. It would be very interesting to actually prove
self-similarity, and to gain a deeper understanding of the functions $h_{p}$
and $\tilde{h}_{p}$.

(a) $h_{\infty}(r)-\mathds{1}_{\\{Tr\neq 0\\}}\frac{1}{8Tr}$

(b) $h_{-\infty}(r)+\frac{1}{8r}$

(c) $h_{2}(r)-\mathds{1}_{\\{Tr\neq
0\\}}\left(\frac{1}{8Tr}+\frac{1}{4}\log\frac{1}{Tr}\right)$

(d) $h_{-2}(r)+\frac{1}{8r}+\frac{1}{4}\log\frac{1}{r}$

Figure 4: Subtracting the asymptotics from $h_{p}(r)$ reveals an interesting
self-similar structure. Finite $p$ values yield very similar graphs, but the
cases $p=\pm\infty$ look markedly different. The four depicted functions are
evaluated at all reduced rationals in $[0,1)$ with denominator at most $150$.

Given $\alpha\in\mathbb{R}$ and $M\in\mathbb{N}$, as a generalization of
$J_{p}$ we define

$J_{p,M}(\alpha)=\left(\sum_{N=0}^{M-1}e^{pS_{N}(\alpha)}\right)^{1/p},\qquad
p\neq\pm\infty,0,$

and

$J_{\infty,M}(\alpha)=\max_{0\leq N<M}e^{S_{N}(\alpha)},\qquad
J_{-\infty,M}(\alpha)=\min_{0\leq N<M}e^{S_{N}(\alpha)}.$

Let $\tilde{J}_{p,M}(\alpha)$ be defined the same way, with
$\tilde{S}_{N}(\alpha)$ instead of $S_{N}(\alpha)$. Letting $p_{k}/q_{k}$
denote the convergents to $\alpha$, roughly speaking, for $M\approx q_{k}$ we
have $J_{p,M}(\alpha)\approx J_{p}(p_{k}/q_{k})$ and
$\tilde{J}_{p,M}(\alpha)\approx\tilde{J}_{p}(p_{k}/q_{k})$.

The asymptotics of $\tilde{J}_{p,M}(\alpha)$ as $M\to\infty$ at various
irrational $\alpha$ was studied in detail in [2, 6]. In particular, for a
quadratic irrational $\alpha$ it was shown that

$\log\tilde{J}_{p,M}(\alpha)=\tilde{C}_{p}(\alpha)\log M+O(\max\\{1,1/|p|\\})$

with some constant $\tilde{C}_{p}(\alpha)$ and an implied constant depending
only on $\alpha$. Moreover, the constants satisfy the relation
$\tilde{C}_{p}(\alpha)+\tilde{C}_{-p}(\alpha)=1$. In this paper, we establish
a similar result for $J_{p,M}(\alpha)$.

######  Theorem 5.

For any $-\infty\leq p\leq\infty$, $p\neq 0$ and any quadratic irrational
$\alpha$,

$\log J_{p,M}(\alpha)=C_{p}(\alpha)\log M+O(\max\\{1,1/|p|\\})$

with some constant $C_{p}(\alpha)$ and an implied constant depending only on
$\alpha$.

Relation (4) is a special case of Theorem 5 with $p=\pm\infty$. Note that
$0<C_{\infty}(\alpha)\leq C_{p}(\alpha)$ if $p>0$, and $C_{p}(\alpha)\leq
C_{-\infty}(\alpha)<0$ if $p<0$. Unlike $C_{\pm\infty}(\alpha)$, we do not
know how to compute $C_{p}(\alpha)$ for finite $p$, even for simple
irrationals such as the golden mean.

The constants $C_{p}(\alpha)$ and $\tilde{C}_{p}(\alpha)$ are closely related
to the limit of the functions $h_{p}$ and $\tilde{h}_{p}$ at quadratic
irrationals. As an illustration, consider $\sqrt{3}-1=[0;\overline{1,2}]$, and
let $p_{k}/q_{k}$ denote its convergents. Then
$T^{2}(p_{k}/q_{k})=p_{k-2}/q_{k-2}$, hence by the definition of $h_{p}$ and
the fact that $\log q_{k}\sim(k/2)\log(2+\sqrt{3})$,

$\sum_{0\leq j<k/2}h_{p}(p_{k-2j}/q_{k-2j})=\log J_{p}(p_{k}/q_{k})=\log
J_{p,q_{k}}(\sqrt{3})+O(1)=\frac{C_{p}(\sqrt{3})\log(2+\sqrt{3})}{2}k+O(1).$

Thus if $\lim_{r\to\sqrt{3}-1}h_{p}(r)$ exists, then its value must be
$C_{p}(\sqrt{3})\log(2+\sqrt{3})$. In particular, while we cannot establish
the continuous extension of $h_{\pm\infty}$ to $\sqrt{3}-1$, we know that in
case they can be continuously extended to that point, their values must be
$h_{\infty}(\sqrt{3}-1)=1/4$ and $h_{-\infty}(\sqrt{3}-1)=-1/12$; this is in
good accordance with the numerics. For a general quadratic irrational
$\alpha$, the constant $C_{p}(\alpha)$ can be similarly expressed in terms of
the limit of $h_{p}$ at the points of the finite orbit of $\alpha$ under
$T^{2}$, provided that these limits exist.

##  3 Limit laws

Confirming a conjecture of Bettin and Drappeau [6], Aistleitner and the author
[1] proved the following limit law for the value distribution of
$\tilde{J}_{p}(r)$ with a random rational $r$; more precisely, for a randomly
chosen element of $F_{Q}=\\{a/q\in[0,1]\,:\mathrm{gcd}(a,q)=1,\,\,1\leq q\leq
Q\\}$, the set of Farey fractions of order $Q$. If
$a/q\sim\mathrm{Unif}(F_{Q})$, then for any $0<p\leq\infty$,

$\frac{\log\tilde{J}_{p}(a/q)-\tilde{E}_{p,q}}{\tilde{\sigma}_{q}}\overset{d}{\to}\mathrm{Stab}(1,1)\qquad\textrm{as
}Q\to\infty,$

where $\tilde{E}_{p,q}=\frac{3\mathrm{Vol}(4_{1})}{\pi^{3}}\log q\log\log
q+\tilde{D}_{p}\log q$ and
$\tilde{\sigma}_{q}=\frac{3\mathrm{Vol}(4_{1})}{2\pi^{2}}\log q$, with the
constant

$\tilde{D}_{p}=\frac{3\mathrm{Vol}(4_{1})}{\pi^{3}}\left(\log\frac{6}{\pi}-\gamma\right)+\frac{12}{\pi^{2}}\int_{0}^{1}\frac{\tilde{h}_{p}(x)-\frac{\mathrm{Vol}(4_{1})}{4\pi}\lfloor
1/x\rfloor}{1+x}\,\mathrm{d}x.$ (9)

Here $\gamma$ denotes the Euler–Mascheroni constant. This was proved in [1]
for $p=2$, but the proof works mutatis mutandis for all $0<p\leq\infty$. The
identity $\tilde{J}_{-p}(r)=q/\tilde{J}_{p}(r)$ mentioned in Section 2 means
that $\log\tilde{J}_{p}(a/q)+\log\tilde{J}_{-p}(a/q)=\log q$, and a limit law
follows for $-\infty\leq p<0$ as well.

In this paper, we show a similar limit law for $J_{p}(r)$ with a random
rational $r$.

######  Theorem 6.

Let $a/q\sim\mathrm{Unif}(F_{Q})$. For any $0<p\leq\infty$ and $-\infty\leq
p^{\prime}<0$,

$\left(\frac{\log J_{p}(a/q)-E_{p,q}}{\sigma_{q}},\frac{\log
J_{p^{\prime}}(a/q)-E_{p^{\prime},q}}{\sigma_{q}}\right)\overset{d}{\to}\mathrm{Stab}(1,1)\otimes\mathrm{Stab}(1,-1)\qquad\textrm{as
}Q\to\infty,$

where, for any $p\neq 0$, $E_{p,q}=\mathrm{sgn}(p)\frac{3}{4\pi^{2}}\log
q\log\log q+D_{p}\log q$ and $\sigma_{q}=\frac{3}{8\pi}\log q$, with the
constant

$D_{p}=-\mathrm{sgn}(p)\frac{3}{4\pi^{2}}\left(\gamma+\log\frac{\pi}{3}\right)+\left\\{\begin{array}[]{ll}\frac{6}{\pi^{2}}\int_{0}^{1}\frac{h_{p}(x)-\frac{1}{8}\lfloor
1/Tx\rfloor}{1+x}\,\mathrm{d}x&\textrm{if }p>0,\\\
\frac{6}{\pi^{2}}\int_{0}^{1}\frac{h_{p}(x)+\frac{1}{8}\lfloor
1/x\rfloor}{1+x}\,\mathrm{d}x&\textrm{if }p<0.\end{array}\right.$ (10)

In particular,

$\frac{\log
J_{p}(a/q)-E_{p,q}}{\sigma_{q}}\overset{d}{\to}\mathrm{Stab}(1,\mathrm{sgn}(p))\qquad\textrm{as
}Q\to\infty.$

######  Remark.

The identity $J_{-p}(r)=1/J_{p}(1-r)$ and the fact that $a/q\mapsto 1-a/q$ is
a bijection of $F_{Q}$ show that $\log J_{-p}(a/q)$ and $-\log J_{p}(a/q)$ are
identically distributed. The previous limit law thus implies that
$E_{-p,q}=-E_{p,q}$, and consequently $D_{-p}=-D_{p}$, a relation which is not
immediate from the definition (10) of $D_{p}$.

The main idea is to consider the telescoping sum
$\log\tilde{J}_{p}(r)=\sum_{j\geq 0}\tilde{h}_{p}(T^{j}r)$; note that
$\tilde{h}_{p}(0)=0$. Using the asymptotics (6) and the solution to Zagier’s
continuity conjecture, for $0<p\leq\infty$ we can write
$\tilde{h}_{p}(r)=\frac{\mathrm{Vol}(4_{1})}{4\pi}a_{1}+\tilde{g}_{p}(r)$ with
an a.e. continuous Lebesgue integrable function $\tilde{g}_{p}(x)$. Letting
$a/q=[0;a_{1},a_{2},\ldots,a_{L}]$ be a random fraction, we thus have

$\log\tilde{J}_{p}(a/q)=\frac{\mathrm{Vol}(4_{1})}{4\pi}\sum_{j\geq
0}a_{j+1}+\sum_{j\geq 0}\tilde{g}_{p}(T^{j}(a/q)).$

The first sum, with suitable centering and scaling, converges in distribution
to $\mathrm{Stab}(1,1)$, whereas the second sum, scaled by $\log q$, converges
in distribution to a constant. This leads to the limit law for
$\log\tilde{J}_{p}$.

We follow a similar strategy for $J_{p}$. We consider the telescoping sum
$\log J_{p}(r)=\sum_{j\geq 0}h_{p}(T^{2j}r)$; note that $h_{p}(0)=0$. Using
Theorems 2 and 3, we can write
$h_{p}(r)=\mathrm{sgn}(p)a_{\varepsilon_{p}}/8+g_{p}(r)$ with an a.e.
continuous Lebesgue integrable function $g_{p}(x)$. Letting
$a/q=[0;a_{1},a_{2},\ldots,a_{L}]$ be a random fraction, we thus have

$\log J_{p}(a/q)=\left\\{\begin{array}[]{ll}\frac{1}{8}\sum_{j\geq
0}a_{2j+2}+\sum_{j\geq 0}g_{p}(T^{2j}(a/q))&\textrm{if }p>0,\\\
-\frac{1}{8}\sum_{j\geq 0}a_{2j+1}+\sum_{j\geq 0}g_{p}(T^{2j}(a/q))&\textrm{if
}p<0.\end{array}\right.$

The main difference is that the main term in $\log J_{p}(a/q)$ now depends
only on the partial quotients with even resp. odd indices if $p>0$ resp.
$p<0$. This explains the convergence of the joint distribution to a product
measure in Theorem 6.

Classical mixing properties of the sequence of partial quotients lead to
similar limit laws for random real numbers.

######  Theorem 7.

Let $\alpha\sim\mu$ with a Borel probability measure $\mu$ on $[0,1]$ which is
absolutely continuous with respect to the Lebesgue measure. For any
$0<p\leq\infty$,

$\frac{\log\tilde{J}_{p,M}(\alpha)-\tilde{E}_{p,M}}{\tilde{\sigma}_{M}}\overset{d}{\to}\mathrm{Stab}(1,1)\qquad\textrm{as
}M\to\infty,$

where $\tilde{E}_{p,M}=\frac{3\mathrm{Vol}(4_{1})}{\pi^{3}}\log M\log\log
M+\tilde{D}_{p}\log M$ and
$\tilde{\sigma}_{M}=\frac{3\mathrm{Vol}(4_{1})}{2\pi^{2}}\log M$, with the
constant $\tilde{D}_{p}$ defined in (9).

Formula (2) is a special case of Theorem 7 with $p=\infty$. Since

$\log\tilde{J}_{p,M}(\alpha)+\log\tilde{J}_{-p,M}(\alpha)=\log M+o(\log
M)\qquad\textrm{in $\mu$-measure},$

a similar limit law holds for $\log\tilde{J}_{p,M}(\alpha)$ with $-\infty\leq
p<0$.

######  Theorem 8.

Let $\alpha\sim\mu$ with a Borel probability measure $\mu$ on $[0,1]$ which is
absolutely continuous with respect to the Lebesgue measure. For any
$0<p\leq\infty$ and $-\infty\leq p^{\prime}<0$,

$\left(\frac{\log J_{p,M}(\alpha)-E_{p,M}}{\sigma_{M}},\frac{\log
J_{p^{\prime},M}(\alpha)-E_{p^{\prime},M}}{\sigma_{M}}\right)\overset{d}{\to}\mathrm{Stab}(1,1)\otimes\mathrm{Stab}(1,-1)\qquad\textrm{as
}M\to\infty,$

where, for any $p\neq 0$, $E_{p,M}=\mathrm{sgn}(p)\frac{3}{4\pi^{2}}\log
M\log\log M+D_{p}\log M$ and $\sigma_{M}=\frac{3}{8\pi}\log M$, with the
constant $D_{p}$ defined in (10).

Theorem 1 is a special case of Theorem 8 with $p=\infty$ and
$p^{\prime}=-\infty$.

##  4 The function $h_{p}$

Throughout this section, we fix a real number $\alpha$ and a parameter
$-\infty\leq p\leq\infty$, $p\neq 0$, and define $\varepsilon_{p}$ as in (8).
If $\alpha\in\mathbb{Q}$, we write its continued fraction expansion in the
form $\alpha=[a_{0};a_{1},a_{2},\ldots,a_{L}]$, and we let $q$ be the
denominator of $\alpha$ in its reduced form. If $\alpha\not\in\mathbb{Q}$, we
write its continued fraction expansion in the form
$\alpha=[a_{0};a_{1},a_{2},\ldots]$, and set $L=\infty$ and $q=\infty$.

The convergents to $\alpha$ are denoted by
$p_{\ell}/q_{\ell}=[a_{0};a_{1},a_{2},\ldots,a_{\ell}]$, $0\leq\ell<L+1$. Any
integer $0\leq N<q$ can be uniquely written in the form
$N=\sum_{\ell=0}^{L-1}b_{\ell}(N)q_{\ell}$, where $0\leq b_{0}(N)<a_{1}$ and
$0\leq b_{\ell}(N)\leq a_{\ell+1}$, $1\leq\ell<L$ are integers which further
satisfy the rule that $b_{\ell+1}(N)=a_{\ell+2}$ implies $b_{\ell}(N)=0$. This
is the so-called Ostrowski expansion of $N$ with respect to $\alpha$, a
special number system tailored to the circle rotation by $\alpha$; in fact, it
was first introduced in connection to $S_{N}(\alpha)$ [19]. The Ostrowski
expansion of course has finitely many terms; more precisely, if $0\leq
N<q_{K}$ with some integer $0\leq K\leq L$, then
$N=\sum_{\ell=0}^{K-1}b_{\ell}(N)q_{\ell}$.

The distance from the nearest integer function is denoted by $\|\cdot\|$. We
will often use the fact that

$\frac{1}{a_{\ell+1}+2}\leq
q_{\ell}\|q_{\ell}\alpha\|\leq\frac{1}{a_{\ell+1}},\qquad 0\leq\ell<L,$

except if $\ell=0$ and $a_{1}=1$; however, in the latter case $b_{0}(N)=0$ for
all $0\leq N<q$, and $\|q_{0}\alpha\|$ does not enter our formulas. Recall
also the recursion $q_{\ell+1}=a_{\ell+1}q_{\ell}+q_{\ell-1}$ with initial
conditions $q_{0}=1$, $q_{1}=a_{1}$.

One of our main tools is an explicit formula for $S_{N}(\alpha)$ due to
Ostrowski [19] (see [4, p. 23] for a more recent proof).

######  Lemma 9 (Ostrowski).

Let $0\leq N<q$ be an integer with Ostrowski expansion
$N=\sum_{\ell=0}^{L-1}b_{\ell}(N)q_{\ell}$. Then

$S_{N}(\alpha)=\sum_{\ell=0}^{L-1}(-1)^{\ell+1}b_{\ell}(N)\left(\frac{1-b_{\ell}(N)q_{\ell}\|q_{\ell}\alpha\|}{2}-\|q_{\ell}\alpha\|\sum_{j=0}^{\ell-1}b_{j}(N)q_{j}-\frac{\|q_{\ell}\alpha\|}{2}\right).$

######  Remark.

The alternating factor $(-1)^{\ell+1}$ in Ostrowski’s explicit formula is
related to the fact that $S_{N}(\alpha)$ is an odd function in the variable
$\alpha$. An application of the second iterate of the Gauss map corresponds to
shifting the partial quotients by two indices, leaving the factor
$(-1)^{\ell+1}$ unchanged.

###  4.1 Local optimum

In this section, we “locally optimize” $S_{N}(\alpha)$ by choosing a single
Ostrowski digit $b_{k}(N)$. Note that the $\ell=k$ term in Ostrowski’s
explicit formula in Lemma 9 is

$\frac{(-1)^{k+1}}{2}\cdot\frac{b_{k}(N)}{a_{k+1}}\left(1-\frac{b_{k}(N)}{a_{k+1}}\right)+O(1).$

Given an odd resp. even index $k$, we can thus expect a particularly large
resp. small value of $S_{N}(\alpha)$ when choosing $b_{k}(N)\approx
a_{k+1}/2$. Lemma 10 below quantifies how the value of $S_{N}(\alpha)$ changes
as we deviate from the optimal value $a_{k+1}/2$. In particular, in Lemma 11
below we show that in the sum $\sum_{N=0}^{q-1}e^{pS_{N}(\alpha)}$ with $p>0$
resp. $p<0$, the main contribution comes from the terms with $b_{k}(N)\approx
a_{k+1}/2$.

In the following lemma and in the sequel, we use the natural convention that
$b_{L}(N)<a_{L+1}$ automatically holds.

######  Lemma 10.

Let $0\leq N<q$ be an integer with Ostrowski expansion
$N=\sum_{\ell=0}^{L-1}b_{\ell}(N)q_{\ell}$, and let $0\leq k<L$. Define
$b_{k}^{*}=\lfloor a_{k+1}/2\rfloor$, and

$N^{*}=\left\\{\begin{array}[]{ll}N+(b_{k}^{*}-b_{k}(N))q_{k}&\textrm{if
}b_{k+1}(N)<a_{k+2},\\\ N+b_{k}^{*}q_{k}-q_{k+1}&\textrm{if
}b_{k+1}(N)=a_{k+2}.\end{array}\right.$

Then

$S_{N^{*}}(\alpha)-S_{N}(\alpha)=(-1)^{k+1}\frac{(b_{k}^{*}-b_{k}(N))^{2}}{2a_{k+1}}+O\left(\frac{|b_{k}^{*}-b_{k}(N)|}{a_{k+1}}\right)$

with a universal implied constant.

###### Proof.

Assume first, that $b_{k+1}(N)<a_{k+2}$. Then $N^{*}$ is obtained from $N$ by
changing the Ostrowski digit $b_{k}(N)$ to $b_{k}^{*}$, and leaving all other
Ostrowski digits intact. Applying Ostrowski’s explicit formula in Lemma 9 to
$N$ and $N^{*}$, we deduce

$\begin{split}S_{N^{*}}(\alpha)-S_{N}(\alpha)=&(-1)^{k+1}\left(b_{k}^{*}\frac{1-b_{k}^{*}q_{k}\|q_{k}\alpha\|}{2}-b_{k}(N)\frac{1-b_{k}(N)q_{k}\|q_{k}\alpha\|}{2}\right)\\\
&+(-1)^{k}(b_{k}^{*}-b_{k}(N))\left(\|q_{k}\alpha\|\sum_{j=0}^{k-1}b_{j}(N)q_{j}+\frac{\|q_{k}\alpha\|}{2}\right)\\\
&+\sum_{\ell=k+1}^{L-1}(-1)^{\ell}b_{\ell}(N)\|q_{\ell}\alpha\|(b_{k}^{*}-b_{k}(N))q_{k}.\end{split}$
(11)

By the rules of the Ostrowski expansion, here
$0\leq\sum_{j=0}^{k-1}b_{j}(N)q_{j}<q_{k}$. Therefore the second and the third
line in (11) are negligible:

$|b_{k}^{*}-b_{k}(N)|\left(\|q_{k}\alpha\|\sum_{j=0}^{k-1}b_{j}(N)q_{j}+\frac{\|q_{k}\alpha\|}{2}\right)\ll\frac{|b_{k}^{*}-b_{k}(N)|}{a_{k+1}},$

and

$\left|\sum_{\ell=k+1}^{L-1}(-1)^{\ell}b_{\ell}(N)\|q_{\ell}\alpha\|(b_{k}^{*}-b_{k}(N))q_{k}\right|\leq|b_{k}^{*}-b_{k}(N)|q_{k}\sum_{\ell=k+1}^{L-1}\frac{1}{q_{\ell}}\ll\frac{|b_{k}^{*}-b_{k}(N)|}{a_{k+1}}.$

Note that $b_{k}^{*}q_{k}\|q_{k}\alpha\|=1/2+O(1/a_{k+1})$ by the definition
of $b_{k}^{*}$. The polynomial $F(x)=x(1-x)$ satisfies the identity
$F(x)-F(y)=(x-y)^{2}+(x-y)(1-2x)$, hence

$F(b_{k}^{*}q_{k}\|q_{k}\alpha\|)-F(b_{k}(N)q_{k}\|q_{k}\alpha\|)=(b_{k}^{*}-b_{k}(N))^{2}q_{k}^{2}\|q_{k}\alpha\|^{2}+O\left(\frac{|b_{k}^{*}-b_{k}(N)|q_{k}\|q_{k}\alpha\|}{a_{k+1}}\right),$

and consequently in the first line in (11) we have

$\begin{split}b_{k}^{*}\frac{1-b_{k}^{*}q_{k}\|q_{k}\alpha\|}{2}-b_{k}(N)\frac{1-b_{k}(N)q_{k}\|q_{k}\alpha\|}{2}&=\frac{F(b_{k}^{*}q_{k}\|q_{k}\alpha\|)-F(b_{k}(N)q_{k}\|q_{k}\alpha\|)}{2q_{k}\|q_{k}\alpha\|}\\\
&=\frac{(b_{k}^{*}-b_{k}(N))^{2}q_{k}\|q_{k}\alpha\|}{2}+O\left(\frac{|b_{k}^{*}-b_{k}(N)|}{a_{k+1}}\right)\\\
&=\frac{(b_{k}^{*}-b_{k}(N))^{2}}{2a_{k+1}}+O\left(\frac{|b_{k}^{*}-b_{k}(N)|}{a_{k+1}}\right).\end{split}$

This finishes the proof in the case $b_{k+1}(N)<a_{k+2}$.

Assume next, that $b_{k+1}(N)=a_{k+2}$. By the rules of the Ostrowski
expansion, we necessarily have $b_{k}(N)=0$, thus $N^{*}$ is obtained from $N$
by decreasing the digit $b_{k+1}(N)=a_{k+2}$ by one, and changing $b_{k}(N)=0$
to $b_{k}^{*}$. We arrive at a legitimate Ostrowski expansion of $N^{*}$; in
particular, $b_{\ell}(N^{*})=b_{\ell}(N)$ for all $\ell\neq k,k+1$. Applying
Ostrowski’s explicit formula in Lemma 9 to $N$ and $N^{*}$, we deduce

$\begin{split}&S_{N^{*}}(\alpha)-S_{N}(\alpha)=\\\
&(-1)^{k+1}b_{k}^{*}\left(\frac{1-b_{k}^{*}q_{k}\|q_{k}\alpha\|}{2}-\|q_{k}\alpha\|\sum_{j=0}^{k-1}b_{j}(N)q_{j}-\frac{\|q_{k}\alpha\|}{2}\right)\\\
&+(-1)^{k+2}\left((a_{k+2}-1)\frac{1-(a_{k+2}-1)q_{k+1}\|q_{k+1}\alpha\|}{2}-a_{k+2}\frac{1-a_{k+2}q_{k+1}\|q_{k+1}\alpha\|}{2}\right)\\\
&+(-1)^{k+2}\left(-(a_{k+2}-1)\|q_{k+1}\alpha\|\left(\sum_{j=0}^{k-1}b_{j}(N)q_{j}+b_{k}^{*}q_{k}+\frac{1}{2}\right)+a_{k+2}\|q_{k+1}\alpha\|\left(\sum_{j=0}^{k-1}b_{j}(N)q_{j}+\frac{1}{2}\right)\right)\\\
&+\sum_{\ell=k+2}^{L-1}(-1)^{\ell}b_{\ell}(N)\|q_{\ell}\alpha\|(b_{k}^{*}q_{k}-q_{k+1}).\end{split}$

Straightforward computation shows that the first line in the previous formula
is $(-1)^{k+1}a_{k+1}/8+O(1)$, and all other lines are $O(1)$. ∎

######  Lemma 11.

Let $0\leq k<K\leq L$ be integers such that $a_{k+1}\geq A$ with a large
universal constant $A>1$. If $p\neq\pm\infty$ and
$k+1\equiv\varepsilon_{p}\pmod{2}$, then

$\sum_{\begin{subarray}{c}0\leq N<q_{K}\\\
|b_{k}(N)-a_{k+1}/2|>\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(\alpha)}\leq
a_{k+1}^{-48\max\\{|p|,1\\}}\sum_{0\leq N<q_{K}}e^{pS_{N}(\alpha)}.$

If $k$ is odd, then

$\max_{\begin{subarray}{c}0\leq N<q_{K}\\\
|b_{k}(N)-a_{k+1}/2|>10\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{S_{N}(\alpha)}\leq a_{k+1}^{-48}\max_{0\leq
N<q_{K}}e^{S_{N}(\alpha)}.$

If $k$ is even, then

$\min_{\begin{subarray}{c}0\leq N<q_{K}\\\
|b_{k}(N)-a_{k+1}/2|>10\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{S_{N}(\alpha)}\geq a_{k+1}^{48}\min_{0\leq
N<q_{K}}e^{S_{N}(\alpha)}.$

###### Proof.

We give a detailed proof in the case $0<p<\infty$. The proof for $-\infty<p<0$
is entirely analogous, whereas the claims on the maximum and the minimum
follow from letting $p\to\pm\infty$.

Assume thus that $0<p<\infty$, and that $k$ is odd. Set $Z=\sum_{0\leq
N<q_{K}}e^{pS_{N}(\alpha)}$, and consider the sets

$\begin{split}H_{k}(b)&=\\{0\leq N<q_{K}\,:\,b_{k}(N)=b\\},\\\
H_{k}^{*}(0)&=\\{0\leq N<q_{K}\,:\,b_{k}(N)=0,\,\,b_{k+1}(N)<a_{k+2}\\},\\\
H_{k}^{**}(0)&=\\{0\leq
N<q_{K}\,:\,b_{k}(N)=0,\,\,b_{k+1}(N)=a_{k+2}\\}.\end{split}$

Let $|b-a_{k+1}/2|>\max\\{10,10/\sqrt{p}\\}\sqrt{a_{k+1}\log a_{k+1}}$ and
$b\neq 0$. Then the map $H_{k}(b)\to H_{k}(\lfloor a_{k+1}/2\rfloor)$,
$N\mapsto N+(\lfloor a_{k+1}/2\rfloor-b)q_{k}$ is injective, and by Lemma 10,

$\sum_{N\in H_{k}(b)}e^{pS_{N}(\alpha)}\leq\sum_{N\in H_{k}(\lfloor
a_{k+1}/2\rfloor)}e^{p(S_{N}(\alpha)-(b-a_{k+1}/2)^{2}/(2.001a_{k+1}))}\leq
a_{k+1}^{-49.9\max\\{p,1\\}}Z.$

The map $H_{k}^{*}(0)\to H_{k}(\lfloor a_{k+1}/2\rfloor)$, $N\mapsto N+\lfloor
a_{k+1}/2\rfloor q_{k}$ is injective, and by Lemma 10,

$\sum_{N\in H_{k}^{*}(0)}e^{pS_{N}(\alpha)}\leq\sum_{N\in H_{k}(\lfloor
a_{k+1}/2\rfloor)}e^{p(S_{N}(\alpha)-(a_{k+1}/2)^{2}/(2.001a_{k+1}))}\leq
e^{-pa_{k+1}/8.004}Z.$

The map $H_{k}^{**}(0)\to H_{k}(\lfloor a_{k+1}/2\rfloor)$, $N\mapsto
N+\lfloor a_{k+1}/2\rfloor q_{k}-q_{k+1}$ is injective, and by Lemma 10,

$\sum_{N\in H_{k}^{**}(0)}e^{pS_{N}(\alpha)}\leq\sum_{N\in H_{k}(\lfloor
a_{k+1}/2\rfloor)}e^{p(S_{N}(\alpha)-(a_{k+1}/2)^{2}/(4a_{k+1}))}\leq
e^{-pa_{k+1}/8.004}Z.$

Note that $e^{-pa_{k+1}/8.004}\leq a_{k+1}^{-49.9\max\\{p,1\\}}$ provided that
$|0-a_{k+1}/2|>\max\\{10,10/\sqrt{p}\\}\sqrt{a_{k+1}\log a_{k+1}}$. As the
number of possible values of $b$ is at most $a_{k+1}-1$, the previous three
formulas lead to

$\sum_{\begin{subarray}{c}0\leq N<q_{K}\\\
|b_{k}(N)-a_{k+1}/2|>\max\\{10,10/\sqrt{p}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(\alpha)}\leq(a_{k+1}+1)a_{k+1}^{-49.9\max\\{p,1\\}}Z\leq
a_{k+1}^{-48\max\\{p,1\\}}Z.$

∎

###  4.2 Factorization of $J_{p}$

In this section, we establish a factorization of $\sum_{0\leq
N<q_{K}}e^{pS_{N}(\alpha)}$ into a product of two sums up to a small error.
The main point of Lemma 12 below is that the first main factor depends only on
the first $k$ partial quotients of $\alpha$. In the special case of a rational
$\alpha$ and $K=L$, we obtain a factorization of $J_{p}(\alpha)$.

######  Lemma 12.

Let $0\leq k<K\leq L$ be integers such that $a_{k+1}\geq
A\max\\{1,\frac{1}{|p|}\log\frac{1}{|p|}\\}$ with a large universal constant
$A>1$. If $p\neq\pm\infty$ and $k+1\equiv\varepsilon_{p}\pmod{2}$, then

$\begin{split}\Bigg{(}\sum_{0\leq
N<q_{K}}e^{pS_{N}(\alpha)}\Bigg{)}^{1/p}=&\left(1+O\left(\sqrt{\frac{\log
a_{k+1}}{\min\\{1,|p|\\}a_{k+1}}}\right)\right)\Bigg{(}\sum_{0\leq
N<q_{k}}e^{p(S_{N}(p_{k}/q_{k})+(-1)^{k}N/(2q_{k}))}\Bigg{)}^{1/p}\\\
&\times\Bigg{(}\sum_{\begin{subarray}{c}0\leq N<q_{K}\\\
b_{0}(N)=\cdots=b_{k-1}(N)=0\\\
|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(\alpha)}\Bigg{)}^{1/p}.\end{split}$

If $k$ is odd, then

$\begin{split}\max_{0\leq
N<q_{K}}e^{S_{N}(\alpha)}=&\left(1+O\left(\sqrt{\frac{\log
a_{k+1}}{a_{k+1}}}\right)\right)\max_{0\leq
N<q_{k}}e^{S_{N}(p_{k}/q_{k})-N/(2q_{k})}\\\
&\times\max_{\begin{subarray}{c}0\leq N<q_{K}\\\
b_{0}(N)=\cdots=b_{k-1}(N)=0\\\
|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{S_{N}(\alpha)}.\end{split}$

If $k$ is even, then

$\begin{split}\min_{0\leq
N<q_{K}}e^{S_{N}(\alpha)}=&\left(1+O\left(\sqrt{\frac{\log
a_{k+1}}{a_{k+1}}}\right)\right)\min_{0\leq
N<q_{k}}e^{S_{N}(p_{k}/q_{k})+N/(2q_{k})}\\\
&\times\min_{\begin{subarray}{c}0\leq N<q_{K}\\\
b_{0}(N)=\cdots=b_{k-1}(N)=0\\\
|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{S_{N}(\alpha)}.\end{split}$

All implied constants are universal.

We mention that the condition
$|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log a_{k+1}}$
in the summations could be removed using a straightforward modification of
Lemma 11, but we will not need this fact. We give the proof after a
preparatory lemma.

######  Lemma 13.

Let $0\leq N<q$ be an integer with Ostrowski expansion
$N=\sum_{\ell=0}^{L-1}b_{\ell}(N)q_{\ell}$. Let $0\leq k<L$, and set
$N_{1}=\sum_{\ell=0}^{k-1}b_{\ell}(N)q_{\ell}$ and
$N_{2}=\sum_{\ell=k}^{L-1}b_{\ell}(N)q_{\ell}$. Then

$S_{N}(\alpha)=S_{N_{1}}(\alpha)+S_{N_{2}}(\alpha)+(-1)^{k}b_{k}(N)\|q_{k}\alpha\|N_{1}+O\left(\frac{1}{a_{k+1}}\right)$

with a universal implied constant.

###### Proof.

Apply Ostrowski’s explicit formula in Lemma 9 to $N$, and consider the sum
over $0\leq\ell\leq k-1$ and $k\leq\ell<L$ separately. The sum over
$0\leq\ell\leq k-1$ is precisely $S_{N_{1}}(\alpha)$. For $k\leq\ell<L$ we
have

$\sum_{j=0}^{\ell-1}b_{j}(N)q_{j}=\sum_{j=0}^{k-1}b_{j}(N)q_{j}+\sum_{j=k}^{\ell-1}b_{j}(N)q_{j}=N_{1}+\sum_{j=0}^{\ell-1}b_{j}(N_{2})q_{j},$

hence

$S_{N}(\alpha)=S_{N_{1}}(\alpha)+S_{N_{2}}(\alpha)+\sum_{\ell=k}^{L-1}(-1)^{\ell}b_{\ell}(N)\|q_{\ell}\alpha\|N_{1}.$

Since $N_{1}<q_{k}$, the terms $k+1\leq\ell<L$ in the previous formula satisfy

$\left|\sum_{\ell=k+1}^{L-1}(-1)^{\ell}b_{\ell}(N)\|q_{\ell}\alpha\|N_{1}\right|\leq\sum_{\ell=k+1}^{L-1}\frac{q_{k}}{q_{\ell}}\ll\frac{1}{a_{k+1}},$

and the claim follows. ∎

###### Proof of Lemma 12.

It is enough prove the lemma for finite $p$. The claims on the maximum and the
minimum then follow from letting $p\to\pm\infty$.

Lemma 11 shows that

$\sum_{0\leq
N<q_{K}}e^{pS_{N}(\alpha)}=\left(1+O\left(a_{k+1}^{-48\max\\{|p|,1\\}}\right)\right)\sum_{\begin{subarray}{c}0\leq
N<q_{K}\\\ |b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(\alpha)}.$ (12)

Let $N_{1},N_{2}$ be as in Lemma 13. The map $N\mapsto(N_{1},N_{2})$ is a
bijection from

$\left\\{0\leq
N<q_{K}\,:\,|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\right\\}$

to the product set

$[0,q_{k})\times\left\\{0\leq
N<q_{K}:\begin{array}[]{c}b_{0}(N)=\cdots=b_{k-1}(N)=0,\\\
|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{array}\right\\}.$

For every such $N$,

$\begin{split}(-1)^{k}b_{k}(N)\|q_{k}\alpha\|N_{1}&=(-1)^{k}\frac{a_{k+1}}{2}\|q_{k}\alpha\|N_{1}+O\left(\max\\{1,1/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\|q_{k}\alpha\|q_{k}\right)\\\
&=(-1)^{k}\frac{N_{1}}{2q_{k}}+O\left(\max\\{1,1/\sqrt{|p|}\\}\sqrt{\frac{\log
a_{k+1}}{a_{k+1}}}\right).\end{split}$

Therefore by Lemma 13,

$S_{N}(\alpha)=S_{N_{1}}(\alpha)+S_{N_{2}}(\alpha)+(-1)^{k}\frac{N_{1}}{2q_{k}}+O\left(\sqrt{\frac{\log
a_{k+1}}{\min\\{1,|p|\\}a_{k+1}}}\right),$

and consequently

$\begin{split}\sum_{\begin{subarray}{c}0\leq N<q_{K}\\\
|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(\alpha)}=&\sum_{0\leq
N<q_{k}}e^{p(S_{N}(\alpha)+(-1)^{k}N/(2q_{k}))}\\\
&\times\sum_{\begin{subarray}{c}0\leq N<q_{K}\\\
b_{0}(N)=\cdots=b_{k-1}(N)=0\\\
|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(\alpha)}\\\
&\times\exp\left(O\left(|p|\sqrt{\frac{\log
a_{k+1}}{\min\\{1,|p|\\}a_{k+1}}}\right)\right).\end{split}$

Substituting this in (12) gives

$\begin{split}\Bigg{(}\sum_{0\leq
N<q_{K}}e^{pS_{N}(\alpha)}\Bigg{)}^{1/p}=&\left(1+O\left(\sqrt{\frac{\log
a_{k+1}}{\min\\{1,|p|\\}a_{k+1}}}\right)\right)\Bigg{(}\sum_{0\leq
N<q_{k}}e^{p(S_{N}(\alpha)+(-1)^{k}N/(2q_{k}))}\Bigg{)}^{1/p}\\\
&\times\Bigg{(}\sum_{\begin{subarray}{c}0\leq N<q_{K}\\\
b_{0}(N)=\cdots=b_{k-1}(N)=0\\\
|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(\alpha)}\Bigg{)}^{1/p}.\end{split}$

It remains to replace $\alpha$ by $p_{k}/q_{k}$ in the first main factor in
the previous formula. For any $1\leq n<q_{k}$, we have $|n\alpha-
np_{k}/q_{k}|=(n/q_{k})\|q_{k}\alpha\|<1/q_{k}$, and $np_{k}/q_{k}$ is not an
integer. In particular, there is no integer between $n\alpha$ and
$np_{k}/q_{k}$, so

$\\{n\alpha\\}-\left\\{\frac{np_{k}}{q_{k}}\right\\}=n\alpha-\frac{np_{k}}{q_{k}}=\frac{n}{q_{k}}(-1)^{k}\|q_{k}\alpha\|.$

Therefore for any $0\leq N<q_{k}$,

$S_{N}(\alpha)-S_{N}(p_{k}/q_{k})=\sum_{n=1}^{N}\frac{n}{q_{k}}(-1)^{k}\|q_{k}\alpha\|=O\left(\frac{1}{a_{k+1}}\right).$
(13)

Replacing $\alpha$ by $p_{k}/q_{k}$ thus introduces a negligible
multiplicative error $1+O(1/a_{k+1})$. ∎

###  4.3 The matching lemma

Assume now that $\alpha\in(0,1)$, and recall that we write its continued
fraction expansion in the form $\alpha=[0;a_{1},a_{2},\ldots,a_{L}]$ (if
$\alpha\in\mathbb{Q}$) or $\alpha=[0;a_{1},a_{2},\ldots]$ (if
$\alpha\not\in\mathbb{Q}$), with convergents
$p_{\ell}/q_{\ell}=[0;a_{1},a_{2},\ldots,a_{\ell}]$. Let
$\alpha^{\prime}=T^{2}\alpha$, where $T^{2}$ is the second iterate of the
Gauss map $T$. Then $\alpha^{\prime}=[0;a_{3},a_{4},\ldots,a_{L}]$ if
$\alpha\in\mathbb{Q}$, with the convention that $\alpha^{\prime}=0$ if $L\leq
2$, and $\alpha^{\prime}=[0;a_{3},a_{4},\ldots]$ if $\alpha\not\in\mathbb{Q}$.
Let $q^{\prime}$ denote the denominator of $\alpha^{\prime}$ in its reduced
form if $\alpha\in\mathbb{Q}$, and let $q^{\prime}=\infty$ if
$\alpha\not\in\mathbb{Q}$. Let
$p_{\ell}^{\prime}/q_{\ell}^{\prime}=[0;a_{3},a_{4},\ldots,a_{\ell}]$,
$3\leq\ell<L+1$ and $p_{2}^{\prime}=0$, $q_{2}^{\prime}=1$ denote the
convergents to $\alpha^{\prime}$. The Ostrowski expansion of integers $0\leq
N<q^{\prime}$ with respect to $\alpha^{\prime}$ will be written as
$N=\sum_{\ell=2}^{L-1}b_{\ell}^{\prime}(N)q_{\ell}^{\prime}$. Note that $0\leq
b_{2}^{\prime}(N)<a_{3}$ and $0\leq b_{\ell}^{\prime}(N)\leq a_{\ell+1}$,
$3\leq\ell<L$.

Given an integer $0\leq N<q$ with Ostrowski expansion
$N=\sum_{\ell=0}^{L-1}b_{\ell}(N)q_{\ell}$ with respect to $\alpha$ such that
$b_{2}(N)<a_{3}$, define
$N^{\prime}=\sum_{\ell=2}^{L-1}b_{\ell}(N)q_{\ell}^{\prime}$. Note that this
is a legitimate Ostrowski expansion with respect to $\alpha^{\prime}$, that
is, $b_{\ell}^{\prime}(N^{\prime})=b_{\ell}(N)$ for all $2\leq\ell<L$. The map
$N\mapsto N^{\prime}$, from $\\{0\leq N<q\,:\,b_{2}(N)<a_{3}\\}$ to
$[0,q^{\prime})$ is surjective but not injective (as it forgets the digits
$b_{0}(N)$ and $b_{1}(N)$), and provides a natural way to match certain terms
of the sum $\sum_{0\leq N<q}e^{pS_{N}(\alpha)}$ to terms of the sum
$\sum_{0\leq N<q^{\prime}}e^{pS_{N}(\alpha^{\prime})}$. By comparing
$S_{N}(\alpha)$ to $S_{N^{\prime}}(\alpha^{\prime})$, the following “matching
lemma” is a key ingredient in the study of the function $h_{p}$.

######  Lemma 14.

Let $0\leq N<q$ be an integer with Ostrowski expansion
$N=\sum_{\ell=0}^{L-1}b_{\ell}(N)q_{\ell}$ with respect to $\alpha$ such that
$b_{2}(N)<a_{3}$. Then

$S_{N}(\alpha)-S_{N^{\prime}}(\alpha^{\prime})=\sum_{\ell=0}^{1}(-1)^{\ell+1}b_{\ell}(N)\left(\frac{1-b_{\ell}(N)q_{\ell}\|q_{\ell}\alpha\|}{2}-\|q_{\ell}\alpha\|\sum_{j=0}^{\ell-1}b_{j}(N)q_{j}-\frac{\|q_{\ell}\alpha\|}{2}\right)+O(1).$

If in addition $b_{0}(N)=\cdots=b_{k-1}(N)=0$ with some $k\geq 2$, then

$S_{N}(\alpha)-S_{N^{\prime}}(\alpha^{\prime})=a_{1}\frac{(-1)^{k+1}p_{k}b_{k}(N)/a_{k+1}-(b_{k}(N)/a_{k+1})^{2}}{2q_{k}q_{k}^{\prime}}+O\left(\frac{1}{q_{k+1}^{\prime}}\right).$

The implied constants are universal.

###### Proof.

Since $p_{\ell}^{\prime},q_{\ell}^{\prime}$ satisfy the same second order
linear recursion of which $p_{\ell},q_{\ell}$ are linearly independent
solutions, they are linear combinations of $p_{\ell},q_{\ell}$. Indeed, one
readily checks that

$p_{\ell}^{\prime}=(a_{1}a_{2}+1)p_{\ell}-a_{2}q_{\ell}\quad\textrm{and}\quad
q_{\ell}^{\prime}=q_{\ell}-a_{1}p_{\ell}\quad\textrm{for all }2\leq\ell<L+1.$
(14)

Now let $2\leq j\leq\ell<L$ be integers. We claim that if either $\ell\geq 3$,
or $\ell=2$ and $a_{3}>1$, then

$\left|q_{j}\|q_{\ell}\alpha\|-q_{j}^{\prime}\|q_{\ell}^{\prime}\alpha^{\prime}\|\right|\leq\frac{2a_{1}}{q_{j+1}q_{\ell+1}^{\prime}}.$
(15)

Set $R=[a_{\ell+1};a_{\ell+2},\ldots,a_{L}]$ resp.
$R=[a_{\ell+1};a_{\ell+2},\ldots]$ if $\alpha\in\mathbb{Q}$ resp.
$\alpha\not\in\mathbb{Q}$. A classical identity of continued fractions states
that $\|q_{\ell}\alpha\|=1/(Rq_{\ell}+q_{\ell-1})$ and
$\|q_{\ell}^{\prime}\alpha^{\prime}\|=1/(Rq_{\ell}^{\prime}+q_{\ell-1}^{\prime})$.
Formula (14) thus leads to

$q_{j}\|q_{\ell}\alpha\|-q_{j}^{\prime}\|q_{\ell}^{\prime}\alpha^{\prime}\|=a_{1}\frac{Rq_{j}q_{\ell}\left(\frac{p_{j}}{q_{j}}-\frac{p_{\ell}}{q_{\ell}}\right)+q_{j}q_{\ell-1}\left(\frac{p_{j}}{q_{j}}-\frac{p_{\ell-1}}{q_{\ell-1}}\right)}{(Rq_{\ell}+q_{\ell-1})(Rq_{\ell}^{\prime}+q_{\ell-1}^{\prime})}.$

Observe that $R\geq a_{\ell+1}$, and recall the identity
$|q_{\ell}p_{\ell-1}-q_{\ell-1}p_{\ell}|=1$. If $j=\ell$, we thus have

$|q_{\ell}\|q_{\ell}\alpha\|-q_{\ell}^{\prime}\|q_{\ell}^{\prime}\alpha^{\prime}\||=a_{1}\frac{1}{(Rq_{\ell}+q_{\ell-1})(Rq_{\ell}^{\prime}+q_{\ell-1}^{\prime})}\leq\frac{a_{1}}{q_{\ell+1}q_{\ell+1}^{\prime}},$

as claimed. If $j=\ell-1$, then

$|q_{\ell-1}\|q_{\ell}\alpha\|-q_{\ell-1}^{\prime}\|q_{\ell}^{\prime}\alpha^{\prime}\||=a_{1}\frac{R}{(Rq_{\ell}+q_{\ell-1})(Rq_{\ell}^{\prime}+q_{\ell-1}^{\prime})}\leq\frac{a_{1}}{q_{\ell}q_{\ell+1}^{\prime}},$

as claimed. If $j\leq\ell-2$, we can use $|p_{j}/q_{j}-p_{\ell}/q_{\ell}|\leq
2|\alpha-p_{j}/q_{j}|$ and $|p_{j}/q_{j}-p_{\ell-1}/q_{\ell-1}|\leq 2|\alpha-
p_{j}/q_{j}|$ to deduce

$|q_{j}\|q_{\ell}\alpha\|-q_{j}^{\prime}\|q_{\ell}^{\prime}\alpha^{\prime}\||\leq
a_{1}\frac{(Rq_{j}q_{\ell}+q_{j}q_{\ell-1})2\left|\alpha-\frac{p_{j}}{q_{j}}\right|}{(Rq_{\ell}+q_{\ell-1})(Rq_{\ell}^{\prime}+q_{\ell-1}^{\prime})}=\frac{2a_{1}\|q_{j}\alpha\|}{Rq_{\ell}^{\prime}+q_{\ell-1}^{\prime}}\leq\frac{2a_{1}}{q_{j+1}q_{\ell+1}^{\prime}},$

as claimed. This finishes the proof of (15).

We now prove the lemma. Since $b_{\ell}^{\prime}(N^{\prime})=b_{\ell}(N)$ for
all $2\leq\ell<L$, Ostrowski’s explicit formula in Lemma 9 gives

$S_{N^{\prime}}(\alpha^{\prime})=\sum_{\ell=2}^{L-1}(-1)^{\ell+1}b_{\ell}(N)\left(\frac{1-b_{\ell}(N)q_{\ell}^{\prime}\|q_{\ell}^{\prime}\alpha^{\prime}\|}{2}-\|q_{\ell}^{\prime}\alpha^{\prime}\|\sum_{j=2}^{L-1}b_{j}(N)q_{j}^{\prime}-\frac{\|q_{\ell}^{\prime}\alpha^{\prime}\|}{2}\right).$

Consequently,

$\begin{split}S_{N}(\alpha)-S_{N^{\prime}}(\alpha^{\prime})=&\sum_{\ell=0}^{1}(-1)^{\ell+1}b_{\ell}(N)\left(\frac{1-b_{\ell}(N)q_{\ell}\|q_{\ell}\alpha\|}{2}-\|q_{\ell}\alpha\|\sum_{j=0}^{\ell-1}b_{j}(N)q_{j}-\frac{\|q_{\ell}\alpha\|}{2}\right)\\\
&+\sum_{\ell=2}^{L-1}(-1)^{\ell+1}b_{\ell}(N)\Bigg{(}\frac{b_{\ell}(N)(q_{\ell}^{\prime}\|q_{\ell}^{\prime}\alpha^{\prime}\|-q_{\ell}\|q_{\ell}\alpha\|)}{2}-\|q_{\ell}\alpha\|\sum_{j=0}^{1}b_{j}(N)q_{j}\\\
&\hskip
113.81102pt+\sum_{j=2}^{\ell-1}b_{j}(N)\left(q_{j}^{\prime}\|q_{\ell}^{\prime}\alpha^{\prime}\|-q_{j}\|q_{\ell}\alpha\|\right)+\frac{\|q_{\ell}^{\prime}\alpha^{\prime}\|-\|q_{\ell}\alpha\|}{2}\Bigg{)}.\end{split}$

By the estimate (15) and the fact that $q_{\ell+1}\geq
q_{2}q_{\ell+1}^{\prime}$ (which can be seen e.g. by induction), the absolute
value of the sum over $2\leq\ell<L$ in the previous formula is at most

$\sum_{\ell=2}^{L-1}a_{\ell+1}\left(\frac{a_{\ell+1}a_{1}}{q_{\ell+1}q_{\ell+1}^{\prime}}+\frac{q_{2}}{q_{\ell+1}}+\sum_{j=2}^{\ell-1}a_{j+1}\frac{2a_{1}}{q_{j+1}q_{\ell+1}^{\prime}}+\frac{1}{q_{\ell+1}^{\prime}}+\frac{1}{q_{\ell+1}}\right)\ll\sum_{\ell=2}^{L-1}\frac{1}{q_{\ell}^{\prime}}\ll
1.$

This finishes the proof of the first claim.

If $b_{0}(N)=\cdots=b_{k-1}(N)=0$ with some $k\geq 2$, then the terms
$\ell\leq k-1$ are all zero, and the contribution of the terms $k+1\leq\ell<L$
is similarly seen to be $\sum_{\ell=k+1}^{L-1}1/q_{\ell}^{\prime}\ll
1/q_{k+1}^{\prime}$. Finally, the $\ell=k$ term is

$(-1)^{k+1}b_{k}(N)\left(\frac{b_{k}(N)(q_{k}^{\prime}\|q_{k}^{\prime}\alpha^{\prime}\|-q_{k}\|q_{k}\alpha\|)}{2}+\frac{\|q_{k}^{\prime}\alpha^{\prime}\|-\|q_{k}\alpha\|}{2}\right).$

As we have seen, with $R=[a_{k+1};a_{k+2},\ldots,a_{L}]$ resp.
$R=[a_{k+1};a_{k+2},\ldots]$ here

$q_{k}^{\prime}\|q_{k}^{\prime}\alpha^{\prime}\|-q_{k}\|q_{k}\alpha\|=\frac{(-1)^{k}a_{1}}{(Rq_{k}+q_{k-1})(Rq_{k}^{\prime}+q_{k-1}^{\prime})}=\frac{(-1)^{k}a_{1}}{a_{k+1}^{2}q_{k}q_{k}^{\prime}}+O\left(\frac{a_{1}}{a_{k+1}^{3}q_{k}q_{k}^{\prime}}\right)$

and using (14),

$\|q_{k}^{\prime}\alpha^{\prime}\|-\|q_{k}\alpha\|=\frac{1}{Rq_{k}^{\prime}+q_{k-1}^{\prime}}-\frac{1}{Rq_{k}+q_{k-1}}=\frac{a_{1}p_{k}}{a_{k+1}q_{k}q_{k}^{\prime}}+O\left(\frac{a_{1}p_{k}}{a_{k+1}^{2}q_{k}q_{k}^{\prime}}\right),$

and the second claim follows. ∎

###  4.4 Asymptotics of $h_{p}$

We now prove Theorem 2 on the asymptotics of $h_{p}$ after a preparatory
lemma.

######  Lemma 15.

For any $0<p<\infty$ and any integer $a\geq 1$,

$\sum_{b=0}^{a-1}e^{\frac{pa}{2}\cdot\frac{b}{a}\left(1-\frac{b}{a}\right)}=\exp\left(\frac{pa}{8}+\frac{1}{2}\log
a+O\left(\max\left\\{p,\log\frac{1}{p}\right\\}\right)\right)$ (16)

and

$\sum_{b=0}^{a-1}e^{-\frac{pa}{2}\cdot\frac{b}{a}\left(1-\frac{b}{a}\right)}=\exp\bigg{(}O\left(\max\left\\{p,\log\frac{1}{p}\right\\}\right)\bigg{)}$
(17)

with universal implied constants.

###### Proof.

We start with (16). Each term in the sum is at most $e^{pa/8}$, thus comparing
the sum to the corresponding integral leads to the upper bound

$\sum_{b=0}^{a-1}e^{\frac{pa}{2}\cdot\frac{b}{a}\left(1-\frac{b}{a}\right)}\leq
a\int_{0}^{1}e^{\frac{pa}{2}x(1-x)}\,\mathrm{d}x+e^{\frac{pa}{8}}\leq
ae^{\frac{pa}{8}}\int_{-\infty}^{\infty}e^{-\frac{pa}{2}(x-1/2)^{2}}\,\mathrm{d}x+e^{\frac{pa}{8}}=\left(\sqrt{\frac{2\pi
a}{p}}+1\right)e^{\frac{pa}{8}}.$

Here

$\log\left(\sqrt{\frac{2\pi a}{p}}+1\right)\leq\frac{1}{2}\log
a+O\left(\max\left\\{p,\log\frac{1}{p}\right\\}\right),$

and the $\leq$ part of (16) follows. Since $e^{\frac{pa}{2}x(1-x)}$ is
increasing on $[0,1/2]$, comparing the sum to the corresponding integral leads
to the lower bound

$\sum_{b=1}^{\lfloor
a/2\rfloor}e^{\frac{pa}{2}\cdot\frac{b}{a}\left(1-\frac{b}{a}\right)}\geq
a\int_{0}^{\frac{\lfloor
a/2\rfloor}{a}}e^{\frac{pa}{2}x(1-x)}\,\mathrm{d}x\geq
ae^{\frac{pa}{8}}\int_{0}^{\frac{a-1}{2a}}e^{-\frac{pa}{2}(x-1/2)^{2}}\,\mathrm{d}x=\sqrt{\frac{a}{p}}e^{\frac{pa}{8}}\int_{-\frac{\sqrt{pa}}{2}}^{-\frac{\sqrt{p}}{2\sqrt{a}}}e^{-x^{2}/2}\,\mathrm{d}x.$

If $pa\geq 100$ and $p\leq 64a$, then $-\sqrt{pa}/2\leq-5$ and
$-\sqrt{p}/(2\sqrt{a})\geq-4$, thus the previous formula yields

$\sum_{b=0}^{a-1}e^{\frac{pa}{2}\cdot\frac{b}{a}\left(1-\frac{b}{a}\right)}\gg\sqrt{\frac{a}{p}}e^{\frac{pa}{8}},$

which suffices for the $\geq$ part of (16). If $pa<100$, then simply using the
fact that each term is at least 1 yields

$\sum_{b=0}^{a-1}e^{\frac{pa}{2}\cdot\frac{b}{a}\left(1-\frac{b}{a}\right)}\geq
a\geq\exp\left(\frac{pa}{8}+\frac{1}{2}\log a-\frac{100}{8}\right),$

which again suffices for the $\geq$ part of (16). If $p>64a$, then it is
enough to keep the $b=\lfloor a/2\rfloor$ term in the sum, yielding

$e^{\frac{pa}{2}\cdot\frac{\lfloor a/2\rfloor}{a}\left(1-\frac{\lfloor
a/2\rfloor}{a}\right)}\geq
e^{\frac{pa}{2}\cdot\frac{a-1}{2a}\left(1-\frac{a-1}{2a}\right)}=e^{\frac{pa}{8}-\frac{p}{8a}}\geq\exp\left(\frac{pa}{8}+\frac{1}{2}\log
a-\frac{1}{2}\log\frac{p}{64}-\frac{p}{8}\right),$

which also suffices for the $\geq$ part of (16). This finishes the proof of
(16).

We now prove (17). Keeping only the term $b=0$ gives the trivial lower bound
$1$. Since each term is at most $1$, comparing the sum to the corresponding
integral leads to the upper bound

$\begin{split}1\leq\sum_{b=0}^{a-1}e^{-\frac{pa}{2}\cdot\frac{b}{a}\left(1-\frac{b}{a}\right)}\leq
a\int_{0}^{1}e^{-\frac{pa}{2}x(1-x)}\,\mathrm{d}x+1&=ae^{-\frac{pa}{8}}\int_{-1/2}^{1/2}e^{\frac{pa}{2}x^{2}}\,\mathrm{d}x+1\\\
&=\frac{8}{p}\sqrt{\frac{pa}{8}}e^{-\frac{pa}{8}}\int_{0}^{\sqrt{\frac{pa}{8}}}e^{x^{2}}\,\mathrm{d}x+1\\\
&\ll\frac{1}{p}+1.\end{split}$

In the last step we used the fact that $\sup_{y\geq
0}ye^{-y^{2}}\int_{0}^{y}e^{x^{2}}\,\mathrm{d}x<\infty$. This establishes
(17). ∎

###### Proof of Theorem 2.

It will be enough to prove the theorem for finite $p$. The claim for
$p=\pm\infty$ then follows from taking the limit as $p\to\pm\infty$.

Let $r=[0;a_{1},a_{2},\ldots,a_{L}]$ be rational with denominator $q$ and
convergents $p_{\ell}/q_{\ell}=[0;a_{1},a_{2},\ldots,a_{\ell}]$. Let
$r^{\prime}=T^{2}r=[0;a_{3},a_{4},\ldots,a_{L}]$ with denominator $q^{\prime}$
and convergents
$p_{\ell}^{\prime}/q_{\ell}^{\prime}=[0;a_{3},a_{4},\ldots,a_{\ell}]$,
$3\leq\ell\leq L$, and $p_{2}^{\prime}=0$, $q_{2}^{\prime}=1$.

Fix integers $0\leq b_{0}<a_{1}$ and $0\leq b_{1}\leq a_{2}$ such that
$b_{1}=a_{2}$ implies $b_{0}=0$. Observe that the map $N\mapsto N-q_{2}$ is an
injection from

$\left\\{0\leq
N<q\,:\,b_{0}(N)=b_{0},\,\,b_{1}(N)=0,\,\,b_{2}(N)=a_{3}\right\\}$

to

$\left\\{0\leq
N<q\,:\,b_{0}(N)=b_{0},\,\,b_{1}(N)=0,\,\,b_{2}(N)=a_{3}-1\right\\}.$

Two applications of Lemma 10 (to $N$ and $N-q_{2}$, with $k=1$) shows that
$S_{N}(r)=S_{N-q_{2}}(r)+O(1)$, therefore

$\sum_{\begin{subarray}{c}0\leq N<q\\\
b_{0}(N)=b_{0},\,\,b_{1}(N)=0,\,\,b_{2}(N)=a_{3}\end{subarray}}e^{pS_{N}(r)}\leq\exp(O(|p|))\sum_{\begin{subarray}{c}0\leq
N<q\\\
b_{0}(N)=b_{0},\,\,b_{1}(N)=0,\,\,b_{2}(N)=a_{3}-1\end{subarray}}e^{pS_{N}(r)}.$

In particular,

$\sum_{\begin{subarray}{c}0\leq N<q\\\
b_{0}(N)=b_{0},\,\,b_{1}(N)=b_{1}\end{subarray}}e^{pS_{N}(r)}=\exp\left(O\left(\max\\{|p|,1\\}\right)\right)\sum_{\begin{subarray}{c}0\leq
N<q\\\
b_{0}(N)=b_{0},\,\,b_{1}(N)=b_{1},\,\,b_{2}(N)<a_{3}\end{subarray}}e^{pS_{N}(r)},$

the formula being trivial for $b_{1}\neq 0$, as in that case the two sums are
identical.

The “matching” map $N\to N^{\prime}$ introduced in Section 4.3 is a bijection

$\left\\{0\leq
N<q\,:\,b_{0}(N)=b_{0},\,\,b_{1}(N)=b_{1},\,\,b_{2}(N)<a_{3}\right\\}\to[0,q^{\prime}),$

and by Lemma 14,

$\begin{split}S_{N}(r)-S_{N^{\prime}}(r^{\prime})=&-b_{0}\left(\frac{1-b_{0}q_{0}\|q_{0}r\|}{2}-\frac{\|q_{0}r\|}{2}\right)+b_{1}\left(\frac{1-b_{1}q_{1}\|q_{1}r\|}{2}-\|q_{1}r\|b_{0}q_{0}-\frac{\|q_{1}r\|}{2}\right)+O(1)\\\
=&-b_{0}\frac{1-b_{0}/a_{1}}{2}+b_{1}\frac{1-b_{1}/a_{2}}{2}+O(1).\end{split}$

Consequently,

$\sum_{\begin{subarray}{c}0\leq N<q\\\
b_{0}(N)=b_{0},\,\,b_{1}(N)=b_{1}\end{subarray}}e^{pS_{N}(r)}=\exp\left(-pb_{0}\frac{1-b_{0}/a_{1}}{2}+pb_{1}\frac{1-b_{1}/a_{2}}{2}+O(\max\\{|p|,1\\})\right)\sum_{0\leq
N<q^{\prime}}e^{pS_{N}(r^{\prime})}.$

We now sum over all possible values of $b_{0},b_{1}$, and apply Lemma 15 to
deduce

$\begin{split}\sum_{0\leq
N<q}e^{pS_{N}(r)}&=\left(1+\sum_{b_{0}=0}^{a_{1}-1}e^{-pb_{0}\frac{1-b_{0}/a_{1}}{2}}\sum_{b_{1}=0}^{a_{2}-1}e^{pb_{1}\frac{1-b_{1}/a_{2}}{2}}\right)\exp(O(\max\\{|p|,1\\}))\sum_{0\leq
N<q^{\prime}}e^{pS_{N}(r^{\prime})}\\\
&=\exp\left(\frac{|p|a_{\varepsilon_{p}}}{8}+\frac{1}{2}\log
a_{\varepsilon_{p}}+O\left(\max\left\\{|p|,\log\frac{1}{|p|}\right\\}\right)\right)\sum_{0\leq
N<q^{\prime}}e^{pS_{N}(r^{\prime})}.\end{split}$

By the definition of $h_{p}$, this means that

$h_{p}(r)=\mathrm{sgn}(p)\frac{a_{\varepsilon_{p}}}{8}+\frac{1}{2p}\log
a_{\varepsilon_{p}}+O\left(\max\left\\{1,\frac{1}{|p|}\log\frac{1}{|p|}\right\\}\right),$

which is an equivalent form of the claim. ∎

###  4.5 Continuity of $h_{p}$ at irrationals

We now prove Theorem 3 in a quantitative form, establishing an estimate for
the modulus of continuity as well. Fix an irrational $\alpha\in(0,1)$ with
continued fraction expansion $\alpha=[0;a_{1},a_{2},\ldots]$ and convergents
$p_{k}/q_{k}=[0;a_{1},a_{2},\ldots,a_{k}]$. Let

$I_{k+1}=\left\\{[0;c_{1},c_{2},\ldots]\,:\,c_{j}=a_{j}\textrm{ for all }1\leq
j\leq k+1\right\\}$

denote the set of real numbers in $(0,1)$ whose first $k+1$ partial quotients
are identical to those of $\alpha$. Recall that $I_{k+1}\subset(0,1)$ is an
interval with rational endpoints; in particular,
$\alpha\in\mathrm{int}\,I_{k+1}$.

######  Theorem 16.

Let $-\infty\leq p\leq\infty$, $p\neq 0$, and let $k\geq 2$ be an integer such
that $a_{k+1}\geq A\max\\{1,\frac{1}{|p|}\log\frac{1}{|p|}\\}$ with a large
universal constant $A>1$, and $k+1\equiv\varepsilon_{p}\pmod{2}$. Then

$\sup_{r\in I_{k+1}\cap\mathbb{Q}}h_{p}(r)-\inf_{r\in
I_{k+1}\cap\mathbb{Q}}h_{p}(r)\ll\frac{a_{1}a_{2}}{q_{k}}+\sqrt{\frac{\log
a_{k+1}}{\min\\{1,|p|\\}a_{k+1}}}$

with a universal implied constant.

In particular, if $\sup_{k\in\mathbb{N}}a_{2k+\varepsilon_{p}}=\infty$, then

$\liminf_{\begin{subarray}{c}k\to\infty\\\
k+1\equiv\varepsilon_{p}\pmod{2}\end{subarray}}\left(\frac{a_{1}a_{2}}{q_{k}}+\sqrt{\frac{\log
a_{k+1}}{\min\\{1,|p|\\}a_{k+1}}}\right)=0,$

and consequently $\lim_{r\to\alpha}h_{p}(r)$ exists and is finite by the
Cauchy criterion. This proves Theorem 3.

###### Proof of Theorem 16.

We only give a detailed proof for finite $p$, as the proof for $p=\pm\infty$
is entirely analogous. Let
$\alpha^{\prime}=T^{2}\alpha=[0;a_{3},a_{4},\ldots]$, and let
$p_{\ell}^{\prime}/q_{\ell}^{\prime}=[0;a_{3},a_{4},\ldots]$, $\ell\geq 3$ and
$p_{2}^{\prime}=0$, $q_{2}^{\prime}=1$ denote its convergents.

Let $r\in I_{k+1}\cap\mathbb{Q}$ be arbitrary with denominator $q$, continued
fraction expansion $r=[0;c_{1},c_{2},\ldots,c_{L}]$ and convergents
$\bar{p}_{\ell}/\bar{q}_{\ell}=[0;c_{1},c_{2},\ldots,c_{\ell}]$. Let
$r^{\prime}=T^{2}r=[0;c_{3},c_{4},\ldots,c_{L}]$ with denominator
$q^{\prime}$, and convergents
$\bar{p}_{\ell}^{\prime}/\bar{q}_{\ell}^{\prime}=[0;c_{3},c_{4},\ldots,c_{\ell}]$,
$3\leq\ell\leq L$ and $\bar{p}_{2}^{\prime}=0$, $\bar{q}_{2}^{\prime}=1$. By
construction, we have $\bar{p}_{\ell}/\bar{q}_{\ell}=p_{\ell}/q_{\ell}$ for
all $0\leq\ell\leq k+1$, and
$\bar{p}_{\ell}^{\prime}/\bar{q}_{\ell}^{\prime}=p_{\ell}^{\prime}/q_{\ell}^{\prime}$
for all $2\leq\ell\leq k+1$.

An application of Lemma 12 to $r$ resp. $r^{\prime}$ with $K=L$ yields

$\begin{split}\Bigg{(}\sum_{0\leq
N<q}e^{pS_{N}(r)}\Bigg{)}^{1/p}=&\left(1+O\left(\sqrt{\frac{\log
a_{k+1}}{\min\\{1,|p|\\}a_{k+1}}}\right)\right)\Bigg{(}\sum_{0\leq
N<q_{k}}e^{p(S_{N}(p_{k}/q_{k})+(-1)^{k}N/(2q_{k}))}\Bigg{)}^{1/p}\\\
&\times\Bigg{(}\sum_{\begin{subarray}{c}0\leq N<q\\\
b_{0}(N)=\cdots=b_{k-1}(N)=0\\\
|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(r)}\Bigg{)}^{1/p}\end{split}$

resp.

$\begin{split}\Bigg{(}\sum_{0\leq
N<q^{\prime}}e^{pS_{N}(r^{\prime})}\Bigg{)}^{1/p}=&\left(1+O\left(\sqrt{\frac{\log
a_{k+1}}{\min\\{1,|p|\\}a_{k+1}}}\right)\right)\Bigg{(}\sum_{0\leq
N<q_{k}^{\prime}}e^{p(S_{N}(p_{k}^{\prime}/q_{k}^{\prime})+(-1)^{k}N/(2q_{k}^{\prime}))}\Bigg{)}^{1/p}\\\
&\times\Bigg{(}\sum_{\begin{subarray}{c}0\leq N<q^{\prime}\\\
b_{2}^{\prime}(N)=\cdots=b_{k-1}^{\prime}(N)=0\\\
|b_{k}^{\prime}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(r^{\prime})}\Bigg{)}^{1/p}.\end{split}$

Here $b_{\ell}(N)$ resp. $b_{\ell}^{\prime}(N)$ denote the digits in the
Ostrowski expansion with respect to $r$ resp. $r^{\prime}$. Consequently,

$\begin{split}h_{p}(r)=\log\frac{J_{p}(r)}{J_{p}(r^{\prime})}=&Z_{p,k}(\alpha)+\frac{1}{p}\log\frac{\displaystyle{\sum_{\begin{subarray}{c}0\leq
N<q\\\ b_{0}(N)=\cdots=b_{k-1}(N)=0\\\
|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(r)}}}{\displaystyle{\sum_{\begin{subarray}{c}0\leq
N<q^{\prime}\\\ b_{2}^{\prime}(N)=\cdots=b_{k-1}^{\prime}(N)=0\\\
|b_{k}^{\prime}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(r^{\prime})}}}\\\ &+O\left(\sqrt{\frac{\log
a_{k+1}}{\min\\{1,|p|\\}a_{k+1}}}\right),\end{split}$ (18)

with the crucial observation that

$Z_{p,k}(\alpha):=\frac{1}{p}\log\frac{\displaystyle{\sum_{0\leq
N<q_{k}}e^{p(S_{N}(p_{k}/q_{k})+(-1)^{k}N/(2q_{k}))}}}{\displaystyle{\sum_{0\leq
N<q_{k}^{\prime}}e^{p(S_{N}(p_{k}^{\prime}/q_{k}^{\prime})+(-1)^{k}N/(2q_{k}^{\prime}))}}}$

depends only on $\alpha$, but not on $r$.

The “matching” map $N\mapsto N^{\prime}$ introduced in Section 4.3 is a
bijection from the set

$\left\\{0\leq N<q\,:\,\begin{array}[]{c}b_{0}(N)=\cdots=b_{k-1}(N)=0,\\\
|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{array}\right\\}$

to the set

$\left\\{0\leq
N<q^{\prime}\,:\,\begin{array}[]{c}b_{2}^{\prime}(N)=\cdots=b_{k-1}^{\prime}(N)=0,\\\
|b_{k}^{\prime}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{array}\right\\},$

and by Lemma 14, $|S_{N}(r)-S_{N^{\prime}}(r^{\prime})|\ll 1/q_{k}^{\prime}\ll
a_{1}a_{2}/q_{k}$. Hence

$\frac{\displaystyle{\sum_{\begin{subarray}{c}0\leq N<q\\\
b_{0}(N)=\cdots=b_{k-1}(N)=0\\\
|b_{k}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(r)}}}{\displaystyle{\sum_{\begin{subarray}{c}0\leq
N<q^{\prime}\\\ b_{2}^{\prime}(N)=\cdots=b_{k-1}^{\prime}(N)=0\\\
|b_{k}^{\prime}(N)-a_{k+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{k+1}\log
a_{k+1}}\end{subarray}}e^{pS_{N}(r^{\prime})}}}=\exp\left(O\left(|p|\frac{a_{1}a_{2}}{q_{k}}\right)\right),$

and (18) leads to

$h_{p}(r)=Z_{p,k}(\alpha)+O\left(\frac{a_{1}a_{2}}{q_{k}}+\sqrt{\frac{\log
a_{k+1}}{\min\\{1,|p|\\}a_{k+1}}}\right)\qquad\textrm{uniformly in }r\in
I_{k+1}\cap\mathbb{Q}.$

This establishes the desired upper bound to the oscillation of $h_{p}$ on the
set $I_{k+1}\cap\mathbb{Q}$. ∎

###  4.6 One-sided limit of $h_{p}$ at rationals

###### Proof of Theorem 4.

We only give a detailed proof for finite $p$, as the proof for $p=\pm\infty$
is entirely analogous.

Fix a reduced rational $a/q\in(0,1)$. It has exactly two continued fraction
expansions, one of even length and one of odd length. Consider thus the
expansion $a/q=[0;a_{1},a_{2},\ldots,a_{s}]$ with odd $s\geq 3$ if $p>0$, and
even $s\geq 2$ if $p<0$, and let $p_{k}/q_{k}=[0;a_{1},a_{2},\ldots,a_{k}]$
denote its convergents. In particular, $s+1\equiv\varepsilon_{p}\pmod{2}$. Let
$I(n)$ be the set of all reals of the form
$[0;a_{1},a_{2},\ldots,a_{s},m,\ldots]$ with $m\geq n$. Note that $I(n)$ is an
interval with endpoints $(p_{s}n+p_{s-1})/(q_{s}n+q_{s-1})$ and
$p_{s}/q_{s}=a/q$. The choice of the parity of $s$ implies that
$I(n)=[a/q-\kappa_{n},a/q)$ is a left-hand neighborhood if $p>0$, whereas
$I(n)=(a/q,a/q+\kappa_{n}]$ is a right-hand neighborhood if $p<0$, of length
$\kappa_{n}=1/(q_{s}^{2}n+q_{s-1}q_{s})$. It will thus be enough to prove that
$\sup_{r\in I(n)\cap\mathbb{Q}}|h_{p}(r)-W_{p}(a/q)|\to 0$ as $n\to\infty$.

Now let $n>A\max\\{1,\frac{1}{|p|}\log\frac{1}{|p|}\\}$ with a large universal
constant $A>1$, and let $r\in I(n)\cap\mathbb{Q}$ be arbitrary. The continued
fraction of $r$ is thus of the form $r=[0;a_{1},a_{2},\ldots,a_{L}]$ with
$L\geq s+1\geq 3$ and $a_{s+1}\geq n$. In particular, the convergents
$p_{k}/q_{k}$, $0\leq k\leq L$ to $r$ coincide with those to $a/q$ for $0\leq
k\leq s$. Let $r^{\prime}=T^{2}r=[0;a_{3},\ldots,a_{L}]$ with convergents
$p_{k}^{\prime}/q_{k}^{\prime}=[0;a_{3},\ldots,a_{k}]$, $3\leq k\leq L$ and
$p_{2}^{\prime}=0$, $q_{2}^{\prime}=1$. Then
$a^{\prime}/q^{\prime}=T^{2}(a/q)=[0;a_{3},\ldots,a_{s}]$ has the same
convergents for $2\leq k\leq s$.

Following the steps in the proof of Theorem 16 leading up to (18) (with
$k=s$), we deduce

$\begin{split}h_{p}(r)=&\frac{1}{p}\log\frac{\displaystyle{\sum_{0\leq
N<q}e^{p(S_{N}(a/q)-\mathrm{sgn}(p)N/(2q))}}}{\displaystyle{\sum_{0\leq
N<q^{\prime}}e^{p(S_{N}(a^{\prime}/q^{\prime})-\mathrm{sgn}(p)N/(2q^{\prime}))}}}\\\
&+\frac{1}{p}\log\frac{\displaystyle{\sum_{\begin{subarray}{c}0\leq N<q_{L}\\\
b_{0}(N)=\cdots=b_{s-1}(N)=0\\\
|b_{s}(N)-a_{s+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{s+1}\log
a_{s+1}}\end{subarray}}e^{pS_{N}(r)}}}{\displaystyle{\sum_{\begin{subarray}{c}0\leq
N<q_{L}^{\prime}\\\ b_{2}^{\prime}(N)=\cdots=b_{s-1}^{\prime}(N)=0\\\
|b_{s}^{\prime}(N)-a_{s+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{s+1}\log
a_{s+1}}\end{subarray}}e^{pS_{N}(r^{\prime})}}}+O\left(\sqrt{\frac{\log
n}{\min\\{1,|p|\\}n}}\right).\end{split}$

Here $b_{\ell}(N)$ resp. $b_{\ell}^{\prime}(N)$ denote the digits in the
Ostrowski expansion with respect to $r$ resp. $r^{\prime}$. The first term in
the previous formula depends only on $a/q$ but not on $r$.

It remains to estimate the second term. The “matching” map $N\mapsto
N^{\prime}$ introduced in Section 4.3 is a bijection from the set

$\left\\{0\leq N<q_{L}\,:\,\begin{array}[]{c}b_{0}(N)=\cdots=b_{s-1}(N)=0,\\\
|b_{s}(N)-a_{s+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{s+1}\log
a_{s+1}}\end{array}\right\\}$

to the set

$\left\\{0\leq
N<q_{L}^{\prime}\,:\,\begin{array}[]{c}b_{2}^{\prime}(N)=\cdots=b_{s-1}^{\prime}(N)=0,\\\
|b_{s}^{\prime}(N)-a_{s+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{s+1}\log
a_{s+1}}\end{array}\right\\}.$

By Lemma 14, for all such $N$,

$\begin{split}S_{N}(r)-S_{N^{\prime}}(r^{\prime})&=a_{1}\frac{\mathrm{sgn}(p)p_{s}b_{s}(N)/a_{s+1}-(b_{s}(N)/a_{s+1})^{2}}{2q_{s}q_{s}^{\prime}}+O\left(\frac{1}{q_{s+1}^{\prime}}\right)\\\
&=\lfloor
q/a\rfloor\frac{\mathrm{sgn}(p)a/2-1/4}{2qq^{\prime}}+O\left(\sqrt{\frac{\log
n}{\min\\{1,|p|\\}n}}\right),\end{split}$

consequently

$\begin{split}\frac{1}{p}\log\frac{\displaystyle{\sum_{\begin{subarray}{c}0\leq
N<q_{L}\\\ b_{0}(N)=\cdots=b_{s-1}(N)=0\\\
|b_{s}(N)-a_{s+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{s+1}\log
a_{s+1}}\end{subarray}}e^{pS_{N}(r)}}}{\displaystyle{\sum_{\begin{subarray}{c}0\leq
N<q_{L}^{\prime}\\\ b_{2}^{\prime}(N)=\cdots=b_{s-1}^{\prime}(N)=0\\\
|b_{s}^{\prime}(N)-a_{s+1}/2|\leq\max\\{10,10/\sqrt{|p|}\\}\sqrt{a_{s+1}\log
a_{s+1}}\end{subarray}}e^{pS_{N}(r^{\prime})}}}=&\lfloor
q/a\rfloor\frac{\mathrm{sgn}(p)a/2-1/4}{2qq^{\prime}}\\\
&+O\left(\sqrt{\frac{\log n}{\min\\{1,|p|\\}n}}\right).\end{split}$

Hence

$h_{p}(r)=W_{p}(a/q)+O\left(\sqrt{\frac{\log
n}{\min\\{1,|p|\\}n}}\right)\qquad\textrm{uniformly in }r\in I(n),$

and the desired limit relation follows. ∎

##  5 Quadratic irrationals

Fix a quadratic irrational $\alpha$ and a parameter $-\infty\leq p\leq\infty$,
$p\neq 0$. Throughout this section, constants and implied constants may depend
on $\alpha$.

Let us write the continued fraction expansion in the form
$\alpha=[a_{0};a_{1},\ldots,a_{s},\overline{a_{s+1},\ldots,a_{s+m}}]$, where
the overline denotes the period. We can always choose the period length $m$ to
be even, although it might not be the shortest possible period. This choice is
convenient because $S_{N}(\alpha)$ is odd in the variable $\alpha$, cf. the
alternating factor $(-1)^{\ell+1}$ in Ostrowski’s explicit formula in Lemma 9.
Solving the recursions with periodic coefficients gives that for any $k\geq 0$
and $1\leq r\leq m$,

$q_{s+km+r}=E_{r}\eta^{k}+F_{r}\eta^{-k}\qquad\textrm{and}\qquad\|q_{s+km+r}\alpha\|=G_{r}\eta^{-k}$
(19)

with some explicitly computable constants $\eta>1$, $E_{r},G_{r}>0$ and
$F_{r}\in\mathbb{R}$, $1\leq r\leq m$ [2, Eq. (28)].

The following lemma states that shifting the digits in the Ostrowski expansion
by full periods has a negligible effect.

######  Lemma 17.

Let $0\leq N<q_{s+km}$ be an integer with Ostrowski expansion
$N=\sum_{\ell=s}^{s+km-1}b_{\ell}(N)q_{\ell}$. Let $i\geq 1$ be an integer,
and set $N^{(i)}=\sum_{\ell=s+im}^{s+(i+k)m-1}b_{\ell-im}(N)q_{\ell}$. Then
$|S_{N}(\alpha)-S_{N^{(i)}}(\alpha)|\ll 1$.

###### Proof.

Note that the shift results in a legitimate Ostrowski expansion for $N^{(i)}$,
that is, $b_{\ell}(N^{(i)})=b_{\ell-im}(N)$ for all $s+im\leq\ell\leq
s+(i+k)m-1$. Applying Ostrowski’s explicit formula in Lemma 9 to $N$ and
$N^{(i)}$ thus yields

$\begin{split}S_{N}(\alpha)-S_{N^{(i)}}(\alpha)=\sum_{\ell=s}^{s+km-1}(-1)^{\ell+1}b_{\ell}(N)\bigg{(}&\frac{b_{\ell}(N)(q_{\ell+im}\|q_{\ell+im}\alpha\|-q_{\ell}\|q_{\ell}\alpha\|)}{2}\\\
&+\sum_{j=s}^{\ell-1}b_{j}(N)(q_{j+im}\|q_{\ell+im}\alpha\|-q_{j}\|q_{\ell}\alpha\|)\\\
&+\frac{\|q_{\ell+im}\alpha\|-\|q_{\ell}\alpha\|}{2}\bigg{)}.\end{split}$

Formula (19) shows that here
$q_{j+im}\|q_{\ell+im}\alpha\|-q_{j}\|q_{\ell}\alpha\|=O(\eta^{-(j+\ell)/m})$
for all $s\leq j\leq\ell$, and the claim follows. ∎

We now show that $\log J_{p,M}(\alpha)$ with $M=q_{s+km}$ is approximately
additive in $k$.

######  Lemma 18.

For any integers $i,k\geq 1$,

$\log J_{p,q_{s+(i+k)m}}(\alpha)=\log J_{p,q_{s+im}}(\alpha)+\log
J_{p,q_{s+km}}(\alpha)+O(\max\\{1,1/|p|\\}).$

###### Proof.

It will be enough to prove the lemma for finite $p$. The claim for
$p=\pm\infty$ then follows from taking the limit as $p\to\pm\infty$.

Note that each individual term in Ostrowski’s explicit formula in Lemma 9 is
$O(1)$. In particular, $S_{N}(\alpha)=O(1)$ whenever $N$ has $O(1)$ nonzero
digits in its Ostrowski expansion. More generally, changing a single Ostrowski
digit of $N$ changes the value of $S_{N}(\alpha)$ by $O(1)$.

Let $c_{k}=\sum_{0\leq N<q_{s+km}}e^{pS_{N}(\alpha)}$, $k\geq 1$. Observe that
the map $[0,q_{s+(k+1)m})\to[0,q_{s+km})$,
$N=\sum_{\ell=0}^{s+(k+1)m-1}b_{\ell}(N)q_{\ell}\mapsto
N^{-}=\sum_{\ell=0}^{s+km-1}b_{\ell}(N)q_{\ell}$ has the property that each
value is attained $O(1)$ times. Since $N^{-}$ is obtained from $N$ by deleting
a single Ostrowski digit, we have $S_{N^{-}}(\alpha)=S_{N}(\alpha)+O(1)$.
Hence for all $k\geq 1$,

$c_{k+1}\leq e^{O(|p|)}\sum_{0\leq N<q_{s+(k+1)m}}e^{pS_{N^{-}}(\alpha)}\leq
e^{O(\max\\{|p|,1\\})}c_{k}.$ (20)

Now fix $i,k\geq 1$. Let $0\leq N^{\prime}<q_{s+im}$ and $0\leq
N^{\prime\prime}<q_{s+km}$ be integers with Ostrowski expansions
$N^{\prime}=\sum_{\ell=0}^{s+im-1}b_{\ell}(N^{\prime})q_{\ell}$ and
$N^{\prime\prime}=\sum_{\ell=0}^{s+km-1}b_{\ell}(N^{\prime\prime})q_{\ell}$.
Define $0\leq N<q_{s+(i+k)m}$,
$N=\sum_{\ell=0}^{s+(i+k)m-1}b_{\ell}(N)q_{\ell}$ as

$b_{\ell}(N)=\left\\{\begin{array}[]{ll}b_{\ell}(N^{\prime})&\textrm{if
}0\leq\ell\leq s+im-1,\\\ 0&\textrm{if }s+im\leq\ell\leq s+(i+1)m-1,\\\
b_{\ell-(i+1)m}(N^{\prime\prime})&\textrm{if }s+(i+1)m\leq\ell\leq
s+(i+k+1)m-1.\end{array}\right.$

Note that the block of zeroes in the middle ensures that the extra rule of
Ostrowski expansions ($b_{\ell+1}(N)=a_{\ell+2}$ implies $b_{\ell}(N)=0$) is
satisfied. The map $[0,q_{s+km})\times[0,q_{s+im})\to[0,q_{s+(i+k+1)m})$,
$(N^{\prime},N^{\prime\prime})\mapsto N$ is injective. Deleting the first $s$
Ostrowski digits of $N^{\prime\prime}$, and then applying Lemmas 17 and 13
shows that
$S_{N}(\alpha)=S_{N^{\prime}}(\alpha)+S_{N^{\prime\prime}}(\alpha)+O(1)$.
Using (20) as well thus leads to

$c_{i}c_{k}=\sum_{\begin{subarray}{c}0\leq N^{\prime}<q_{s+im}\\\ 0\leq
N^{\prime\prime}<q_{s+km}\end{subarray}}e^{p(S_{N^{\prime}}(\alpha)+S_{N^{\prime\prime}}(\alpha))}\leq
e^{O(|p|)}c_{i+k+1}\leq e^{O(\max\\{|p|,1\\})}c_{i+k}.$ (21)

Next, for any integer $0\leq N<q_{s+(i+k)m}$ with Ostrowski expansion
$N=\sum_{\ell=0}^{s+(i+k)m-1}b_{\ell}(N)q_{\ell}$ define
$N_{1}=\sum_{\ell=0}^{s+im-1}b_{\ell}(N)q_{\ell}$ and
$N_{2}=\sum_{\ell=s}^{s+km-1}b_{\ell+im}(N)q_{\ell}$. Note that, with the
notation of Lemma 17, $N=N_{1}+N_{2}^{(i)}$, hence Lemmas 13 and 17 give
$S_{N}(\alpha)=S_{N_{1}}(\alpha)+S_{N_{2}}(\alpha)+O(1)$. Observe that the map
$[0,q_{s+(i+k)m})\to[0,q_{s+im})\times[0,q_{s+km})$, $N\mapsto(N_{1},N_{2})$
is injective, thus

$c_{i+k}\leq e^{O(|p|)}\sum_{\begin{subarray}{c}0\leq N_{1}<q_{s+im}\\\ 0\leq
N_{2}<q_{s+km}\end{subarray}}e^{p(S_{N_{1}}(\alpha)+S_{N_{2}}(\alpha))}=e^{O(|p|)}c_{i}c_{k}.$

The previous formula together with (21) show that
$c_{i+k}=e^{O(\max\\{|p|,1\\})}c_{i}c_{k}$, and the claim follows. ∎

###### Proof of Theorem 5.

By Lemma 18, there exists a constant $K=O(\max\\{1,1/|p|\\})$ such that the
sequence $\log J_{p,q_{s+km}}(\alpha)+K$ resp. $\log J_{p,q_{s+km}}(\alpha)-K$
is subadditive resp. superadditive in $k$. An application of the subadditive
lemma of Fekete then shows that the sequence $k^{-1}\log
J_{p,q_{s+km}}(\alpha)$ is convergent, and denoting its limit by
$C^{\prime}_{p}(\alpha)$,

$C^{\prime}_{p}(\alpha)=\inf_{k\geq 1}\frac{\log
J_{p,q_{s+km}}(\alpha)+K}{k}=\sup_{k\geq 1}\frac{\log
J_{p,q_{s+km}}(\alpha)-K}{k}.$

In particular, $\log
J_{p,q_{s+km}}(\alpha)=C^{\prime}_{p}(\alpha)k+O(\max\\{1,1/|p|\\})$.

Given an arbitrary integer $q_{s+km}\leq M<q_{s+(k+1)m}$, we have

$\log J_{p,q_{s+km}}(\alpha)\leq\log J_{p,M}(\alpha)\leq\log
J_{p,q_{s+(k+1)m}}(\alpha)$

if $p>0$, and the reverse inequalities hold if $p<0$. Formula (19) shows that
$\log q_{s+km}=(\log\eta)k+O(1)$, hence

$\log
J_{p,M}(\alpha)=C^{\prime}_{p}(\alpha)k+O(\max\\{1,1/|p|\\})=\frac{C^{\prime}_{p}(\alpha)}{\log\eta}\log
M+O(\max\\{1,1/|p|\\}).$

Thus $C_{p}(\alpha)=C^{\prime}_{p}(\alpha)/\log\eta$ satisfies the claim of
the theorem. ∎

##  6 Proof of the limit laws

For any $r\in(0,1)\cap\mathbb{Q}$, define

$g_{p}(r)=h_{p}(r)-\left\\{\begin{array}[]{ll}\mathds{1}_{\\{Tr\neq
0\\}}\frac{1}{8}\lfloor\frac{1}{Tr}\rfloor&\textrm{if }p>0,\\\
-\frac{1}{8}\lfloor\frac{1}{r}\rfloor&\textrm{if }p<0.\end{array}\right.$ (22)

By Theorem 3, $g_{p}$ can be extended to an a.e. continuous function on
$[0,1]$, which we simply denote by $g_{p}$ as well. By Theorem 2, we have
$|g_{p}(x)|\leq c(1+\log(1/Tx))$ if $p>0$, and $|g_{p}(x)|\leq c(1+\log(1/x))$
if $p<0$ with a large constant $c>0$ depending only on $p$.

######  Lemma 19.

For any $\varepsilon>0$, there exist a constant $\delta_{p}>0$ and functions
$g_{p}^{\pm}$ on $[0,1]$ with the following properties.

  1. (i)

$g_{p}^{-}\leq g_{p}\leq g_{p}^{+}$ on $[0,1]$, and
$\int_{0}^{1}(g_{p}^{+}(x)-g_{p}^{-}(x))\,\mathrm{d}x<\varepsilon$.

  2. (ii)

If $p>0$, then for all $n\in\mathbb{N}$, the functions $g_{p}^{\pm}$ are
smooth on $(\frac{1}{n+1},\frac{1}{n})$, and $g_{p}^{\pm}(x)=\pm 2c\log(1/Tx)$
for all
$x\in(\frac{1}{n+1},\frac{1}{n})\cap(\frac{1}{n}-\delta_{p},\frac{1}{n})$.

  3. (iii)

If $p<0$, then the functions $g_{p}^{\pm}$ are smooth on $(0,1)$, and
$g_{p}^{\pm}(x)=\pm 2c\log(1/x)$ for all $x\in(0,\delta_{p})$.

###### Proof.

Fix $\varepsilon>0$. Assume first, that $p>0$, and let $\delta_{p}>0$ be a
small constant to be chosen. If $n$ is large enough so that
$\frac{1}{n}-\delta_{p}\leq\frac{1}{n+1}$, then we are forced to define
$g_{p}^{\pm}(x)=\pm 2c\log(1/Tx)$ for $x\in(\frac{1}{n+1},\frac{1}{n})$. Now
let $n$ be such that $\frac{1}{n}-\delta_{p}>\frac{1}{n+1}$. Since $g_{p}$ is
bounded and a.e. continuous, and consequently Riemann integrable on
$[\frac{1}{n+1},\frac{1}{n}-\delta_{p}]$, we can approximate $g_{p}$ pointwise
from above and from below by step functions, and extend them to
$(\frac{1}{n}-\delta_{p},\frac{1}{n})$ as $\pm 2c\log(1/Tx)$. By choosing
$\delta_{p}$ small enough, we can ensure that these piecewise defined upper
and lower approximating functions are $\varepsilon$-close to each other in
$L^{1}$. Next, we approximate the piecewise defined functions from above and
from below by smooth functions which are still $\varepsilon$-close to each
other in $L^{1}$.

The construction for $p<0$ is similar. We first approximate $g_{p}$ from above
and from below by step functions on $[\delta_{p},1]$, and extend them as $\pm
2c\log(1/x)$ on $(0,\delta_{p})$. Then we approximate these piecewise defined
functions from above and from below by smooth functions. ∎

The following lemma will play a role in the proof of the limit laws for both
random rationals and random reals.

######  Lemma 20.

For any $t_{1},t_{2}\in(-1/2,1/2)$,

$\begin{split}\int_{0}^{1}\frac{e^{i(t_{1}\lfloor 1/Tx\rfloor+t_{2}\lfloor
1/x\rfloor)}-1}{1+x}\,\mathrm{d}x=&-\frac{\pi}{2}|t_{1}|-i\gamma
t_{1}-it_{1}\log|t_{1}|-\frac{\pi}{2}|t_{2}|-i\gamma
t_{2}-it_{2}\log|t_{2}|\\\
&+O\left(t_{1}^{2}\log\frac{1}{|t_{1}|}+t_{2}^{2}\log\frac{1}{|t_{2}|}+|t_{1}t_{2}|\log\frac{1}{|t_{1}|}\log\frac{1}{|t_{2}|}\right)\end{split}$

with a universal implied constant.

###### Proof.

Let $I(t_{1},t_{2})$ denote the integral in the claim. Applying the
substitution $x\mapsto 1/x$ twice leads to

$\begin{split}I(t_{1},t_{2})&=\int_{1}^{\infty}\frac{e^{i(t_{1}\lfloor
1/\\{x\\}\rfloor+t_{2}\lfloor
x\rfloor)}-1}{x(x+1)}\,\mathrm{d}x=\sum_{n=1}^{\infty}\int_{0}^{1}\frac{e^{i(t_{1}\lfloor
1/x\rfloor+t_{2}n)}-1}{(x+n)(x+n+1)}\,\mathrm{d}x\\\
&=\sum_{n=1}^{\infty}\int_{1}^{\infty}\frac{e^{i(t_{1}\lfloor
x\rfloor+t_{2}n)}-1}{(nx+1)((n+1)x+1)}\,\mathrm{d}x=\sum_{n,m=1}^{\infty}\int_{0}^{1}\frac{e^{i(t_{1}m+t_{2}n)}-1}{(n(x+m)+1)((n+1)(x+m)+1)}\,\mathrm{d}x\\\
&=\sum_{n,m=1}^{\infty}\left(e^{i(t_{1}m+t_{2}n)}-1\right)\log\frac{((n+1)(m+1)+1)(nm+1)}{((n+1)m+1)((m+1)n+1)}.\end{split}$

Here

$\begin{split}\log\frac{((n+1)(m+1)+1)(nm+1)}{((n+1)m+1)((m+1)n+1)}&=\log\left(1+\frac{1}{n^{2}m^{2}+n^{2}m+nm^{2}+3nm+n+m+1}\right)\\\
&=\frac{1}{n^{2}m^{2}+n^{2}m+nm^{2}+3nm+n+m+1}+O\left(\frac{1}{n^{4}m^{4}}\right)\\\
&=\frac{1}{n(n+1)m(m+1)}+O\left(\frac{1}{n^{3}m^{3}}\right).\end{split}$

Letting

$R_{n,m}=\log\frac{((n+1)(m+1)+1)(nm+1)}{((n+1)m+1)((m+1)n+1)}-\frac{1}{n(n+1)m(m+1)},$

we thus have $R_{n,m}=O(n^{-3}m^{-3})$, and we can write

$I(t_{1},t_{2})=\sum_{n,m=1}^{\infty}\frac{e^{i(t_{1}m+t_{2}n)}-1}{n(n+1)m(m+1)}+\sum_{n,m=1}^{\infty}\left(e^{i(t_{1}m+t_{2}n)}-1\right)R_{n,m}.$
(23)

The second term is estimated as

$\begin{split}\sum_{n,m=1}^{\infty}\left(e^{i(t_{1}m+t_{2}n)}-1\right)R_{n,m}&=\sum_{m=1}^{1/|t_{1}|}\sum_{n=1}^{1/|t_{2}|}\left(it_{1}m+it_{2}n+O\left(|t_{1}m+t_{2}n|^{2}\right)\right)R_{n,m}+O\left(t_{1}^{2}+t_{2}^{2}\right)\\\
&=it_{1}\sum_{n,m=1}^{\infty}mR_{n,m}+it_{2}\sum_{n,m=1}^{\infty}nR_{n,m}+O\left(t_{1}^{2}\log\frac{1}{|t_{1}|}+t_{2}^{2}\log\frac{1}{|t_{2}|}\right).\end{split}$

The infinite series is easily computed using telescoping sums:

$\begin{split}\sum_{n,m=1}^{\infty}nR_{n,m}&=\sum_{n=1}^{\infty}\left(n\log\frac{(n+1)^{2}}{n(n+2)}-\frac{1}{n+1}\right)\\\
&=\lim_{N\to\infty}\left(\log(N+1)+N\log\frac{N+1}{N+2}-\sum_{n=1}^{N}\frac{1}{n+1}\right)=-\gamma.\end{split}$

By symmetry, we also have $\sum_{n,m=1}^{\infty}mR_{n,m}=-\gamma$, thus the
second term in (23) is

$\sum_{n,m=1}^{\infty}\left(e^{i(t_{1}m+t_{2}n)}-1\right)R_{n,m}=-i\gamma
t_{1}-i\gamma
t_{2}+O\left(t_{1}^{2}\log\frac{1}{|t_{1}|}+t_{2}^{2}\log\frac{1}{|t_{2}|}\right).$
(24)

We can rewrite the first term in (23) as

$\sum_{n,m=1}^{\infty}\frac{e^{i(t_{1}m+t_{2}n)}-1}{n(n+1)m(m+1)}=\left(\sum_{m=1}^{\infty}\frac{e^{it_{1}m}}{m(m+1)}\right)\left(\sum_{n=1}^{\infty}\frac{e^{it_{2}n}}{n(n+1)}\right)-1.$

Observe that

$\sum_{n=1}^{\infty}\frac{z^{n}}{n(n+1)}=1+\frac{1-z}{z}\log(1-z),\qquad|z|\leq
1$

with the principal branch of the logarithm. For $j=1,2$,

$\log(1-e^{it_{j}})=\log|2\sin(t_{j}/2)|+i\left(\frac{t_{j}}{2}-\mathrm{sgn}(t_{j})\frac{\pi}{2}\right)=\log|t_{j}|-i\mathrm{sgn}(t_{j})\frac{\pi}{2}+O\left(|t_{j}|\right),$

hence

$\sum_{n=1}^{\infty}\frac{e^{it_{j}n}}{n(n+1)}=1+(e^{-it_{j}}-1)\log(1-e^{it_{j}})=1-it_{j}\log|t_{j}|-\frac{\pi}{2}|t_{j}|+O\left(t_{j}^{2}\log\frac{1}{|t_{j}|}\right).$

Therefore the first term in (23) is

$\begin{split}\sum_{n,m=1}^{\infty}\frac{e^{i(t_{1}m+t_{2}n)}-1}{n(n+1)m(m+1)}=&-it_{1}\log|t_{1}|-\frac{\pi}{2}|t_{1}|-it_{2}\log|t_{2}|-\frac{\pi}{2}|t_{2}|\\\
&+O\left(t_{1}^{2}\log\frac{1}{|t_{1}|}+t_{2}^{2}\log\frac{1}{|t_{2}|}+|t_{1}t_{2}|\log\frac{1}{|t_{1}|}\log\frac{1}{|t_{2}|}\right).\end{split}$

The previous formula together with (23) and (24) lead to the claim of the
lemma. ∎

###  6.1 Random rationals

###### Proof of Theorem 6.

Let $a/q\sim\mathrm{Unif}(F_{Q})$, and consider its continued fraction
expansion $a/q=[0;a_{1},a_{2},\ldots,a_{L}]$. Then
$T^{2j}(a/q)=[0;a_{2j+1},a_{2j+2},\ldots,a_{L}]$. Given $0<p\leq\infty$ and
$-\infty\leq p^{\prime}<0$, by the definition (22) of $g_{p}$ we can write

$\begin{split}\left(\log J_{p}(a/q),\log
J_{p^{\prime}}(a/q)\right)=&\sum_{j\geq
0}\left(h_{p}(T^{2j}(a/q)),h_{p^{\prime}}(T^{2j}(a/q))\right)\\\ =&\sum_{j\geq
0}\left(\frac{a_{2j+2}}{8},-\frac{a_{2j+1}}{8}\right)+\sum_{j\geq
0}\left(g_{p}(T^{2j}(a/q)),g_{p^{\prime}}(T^{2j}(a/q))\right).\end{split}$
(25)

The main term in (25) is the first sum. We find its limit distribution by
applying [5, Theorem 3.1] with, in the notation of that paper, $m=2$ and the
$\mathbb{R}^{2}$-valued functions $\phi_{1}(x)=(0,-\frac{1}{8}\lfloor
1/x\rfloor)$ and $\phi_{2}(x)=(\frac{1}{8}\lfloor 1/x\rfloor,0)$ to obtain an
estimate for the characteristic function of

$\sum_{j\geq 1}\phi_{j\textrm{ mod }2}(T^{j-1}(a/q))=\sum_{j\geq
0}\left(\frac{a_{2j+2}}{8},-\frac{a_{2j+1}}{8}\right).$

In particular, the theorem states that for any $\varepsilon>0$ there exist
small constants $\tau=\tau(\varepsilon)>0$ and $\delta=\delta(\varepsilon)>0$
such that for all $t=(t_{1},t_{2})$ with $|t|<\tau$,

$\mathbb{E}\exp\left(i\left(t_{1}\sum_{j\geq
0}\frac{a_{2j+2}}{8}-t_{2}\sum_{j\geq
0}\frac{a_{2j+1}}{8}\right)\right)=\exp\left(U(t_{1},t_{2})\log
Q+O\left(|t|^{2-\varepsilon}\log
Q+|t|^{1-\varepsilon}+Q^{-\delta}\right)\right)$

with

$U(t_{1},t_{2})=\frac{6}{\pi^{2}}\int_{0}^{1}\frac{e^{i(\frac{t_{1}}{8}\lfloor
1/Tx\rfloor-\frac{t_{2}}{8}\lfloor 1/x\rfloor)}-1}{1+x}\,\mathrm{d}x$

and an implied constant depending only on $\varepsilon$. Fix constants
$x_{1},x_{2}\in\mathbb{R}$, and choose $t_{1}=x_{1}/(\frac{3}{8\pi}\log Q)$
and $t_{2}=x_{2}/(\frac{3}{8\pi}\log Q)$. Lemma 20 shows that

$\begin{split}U\left(\frac{x_{1}}{\frac{3}{8\pi}\log
Q},\frac{x_{2}}{\frac{3}{8\pi}\log Q}\right)\log
Q=&-|x_{1}|-i\frac{2\gamma}{\pi}x_{1}-i\frac{2}{\pi}x_{1}\log\frac{\pi|x_{1}|}{3\log
Q}\\\
&-|x_{2}|+i\frac{2\gamma}{\pi}x_{2}+i\frac{2}{\pi}x_{2}\log\frac{\pi|x_{2}|}{3\log
Q}+O\left(\frac{(\log\log Q)^{2}}{\log Q}\right).\end{split}$

After subtracting the appropriate centering term, we thus obtain that the
characteristic function

$\mathbb{E}\exp\left(i\left(x_{1}\frac{\sum_{j\geq
0}\frac{a_{2j+2}}{8}-B_{Q}}{\frac{3}{8\pi}\log Q}+x_{2}\frac{-\sum_{j\geq
0}\frac{a_{2j+1}}{8}+B_{Q}}{\frac{3}{8\pi}\log Q}\right)\right)$

with

$B_{Q}=\frac{3}{4\pi^{2}}\log Q\log\log
Q-\frac{3}{4\pi^{2}}\left(\gamma+\log\frac{\pi}{3}\right)\log Q$

converges pointwise to
$\exp(-|x_{1}|(1+i\frac{2}{\pi}\mathrm{sgn}(x_{1})\log|x_{1}|))\exp(-|x_{2}|(1-i\frac{2}{\pi}\mathrm{sgn}(x_{2})\log|x_{2}|))$,
which is the characteristic funcion of
$\mathrm{Stab}(1,1)\otimes\mathrm{Stab}(1,-1)$. In particular, the first sum
in (25) satisfies

$\left(\frac{\sum_{j\geq 0}\frac{a_{2j+2}}{8}-B_{Q}}{\frac{3}{8\pi}\log
Q},\frac{-\sum_{j\geq 0}\frac{a_{2j+1}}{8}+B_{Q}}{\frac{3}{8\pi}\log
Q}\right)\overset{d}{\to}\mathrm{Stab}(1,1)\otimes\mathrm{Stab}(1,-1)\qquad\textrm{as
}Q\to\infty.$ (26)

Consider the second sum in (25). Instead of Lemma 20, we can now use the fact
that for any $f\in L^{1}([0,1])$,

$\int_{0}^{1}\frac{e^{itf(x)}-1}{1+x}\,\mathrm{d}x=it\int_{0}^{1}\frac{f(x)}{1+x}\,\mathrm{d}x+o(|t|)\qquad\textrm{as
}t\to 0.$

Fix $\varepsilon>0$, and let $g_{p}^{\pm}$ be as in Lemma 19. By another
application of [5, Theorem 3.1] with $m=2$, $\phi_{1}(x)=g_{p}^{\pm}(x)\mp
2c\log(1/Tx)$ and $\phi_{2}(x)=\pm 2c\log(1/x)$, we deduce

$\frac{\sum_{j\geq 0}g_{p}^{\pm}(T^{2j}(a/q))}{\log
Q}\overset{d}{\to}\frac{6}{\pi^{2}}\int_{0}^{1}\frac{g_{p}^{\pm}(x)}{1+x}\,\mathrm{d}x\qquad\textrm{as
}Q\to\infty,$

and letting $\varepsilon\to 0$ leads to

$\frac{\sum_{j\geq 0}g_{p}(T^{2j}(a/q))}{\log
Q}\overset{d}{\to}\frac{6}{\pi^{2}}\int_{0}^{1}\frac{h_{p}(x)-\frac{1}{8}\lfloor
1/Tx\rfloor}{1+x}\,\mathrm{d}x\qquad\textrm{as }Q\to\infty.$

From [5, Theorem 3.1] with $m=2$, $\phi_{1}(x)=g_{p^{\prime}}^{\pm}(x)$ and
$\phi_{2}(x)=0$, we similarly deduce

$\frac{\sum_{j\geq 0}g_{p^{\prime}}(T^{2j}(a/q))}{\log
Q}\overset{d}{\to}\frac{6}{\pi^{2}}\int_{0}^{1}\frac{h_{p^{\prime}}(x)+\frac{1}{8}\lfloor
1/x\rfloor}{1+x}\,\mathrm{d}x\qquad\textrm{as }Q\to\infty.$

These formulas combined with (25) and (26) immediately yield the joint limit
law

$\left(\frac{\log J_{p}(a/q)-E_{p,Q}}{\sigma_{Q}},\frac{\log
J_{p^{\prime}}(a/q)-E_{p^{\prime},Q}}{\sigma_{Q}}\right)\overset{d}{\to}\mathrm{Stab}(1,1)\otimes\mathrm{Stab}(1,-1)\qquad\textrm{as
}Q\to\infty.$

Since $\log q/\log Q\overset{d}{\to}1$, we can replace $E_{p,Q}$ by $E_{p,q}$
and $\sigma_{Q}$ by $\sigma_{q}$. ∎

###  6.2 Random reals

Throughout, $\alpha\in[0,1]$ is an irrational number with continued fraction
expansion $\alpha=[0;a_{1},a_{2},\ldots]$ and convergents
$p_{k}/q_{k}=[0;a_{1},a_{2},\ldots,a_{k}]$. Let $\nu(B)=\frac{1}{\log
2}\int_{B}\frac{1}{1+x}\,\mathrm{d}x$ ($B\subseteq[0,1]$ Borel) denote the
Gauss measure on $[0,1]$. The following lemma relies on the classical fact of
metric number theory that if $\alpha\sim\nu$, then the sequence of random
variables $a_{1},a_{2},\ldots$ is strictly stationary and $\psi$-mixing with
exponential rate. We refer to the monograph [16] for more context.

######  Lemma 21.

Let $\alpha\sim\nu$. For any $0<p\leq\infty$ and $-\infty\leq p^{\prime}<0$,

$\left(\frac{\log
J_{p}(p_{k}/q_{k})-A_{p,k}}{\frac{3}{8\pi}\cdot\frac{\pi^{2}}{12\log
2}k},\frac{\log
J_{p^{\prime}}(p_{k}/q_{k})-A_{p^{\prime},k}}{\frac{3}{8\pi}\cdot\frac{\pi^{2}}{12\log
2}k}\right)\overset{d}{\to}\mathrm{Stab}(1,1)\otimes\mathrm{Stab}(1,-1)\qquad\textrm{as
}k\to\infty,$

where, for all $p\neq 0$,
$A_{p,k}=\mathrm{sgn}(p)\frac{3}{4\pi^{2}}\cdot\frac{\pi^{2}}{12\log
2}k\log\left(\frac{\pi^{2}}{12\log 2}k\right)+D_{p}\frac{\pi^{2}}{12\log 2}k$,
with $D_{p}$ defined in (10).

###### Proof.

For the sake of simplicity, we assume that $k$ is even, in which case

$\left(\log J_{p}(p_{k}/q_{k}),\log
J_{p^{\prime}}(p_{k}/q_{k})\right)=\sum_{0\leq
j<k/2}\left(\frac{a_{2j+2}}{8},-\frac{a_{2j+1}}{8}\right)+\sum_{0\leq
j<k/2}\left(g_{p}(T^{2j}(p_{k}/q_{k})),g_{p^{\prime}}(T^{2j}(p_{k}/q_{k}))\right).$
(27)

A similar formula holds for odd $k$, the only difference being that the last
term in the first sum is $(0,-a_{k}/8)$, which is negligible in measure.

The main term in (27) is the first sum, whose limit distribution is easily
found using the theory of $\psi$-mixing random variables. Fix real constants
$x_{1},x_{2}$ such that $(x_{1},x_{2})\neq(0,0)$; in what follows, implied
constants are allowed to depend on $x_{1},x_{2}$. The random variables

$X_{j}:=x_{1}\frac{a_{2j+2}/8}{\frac{3}{8\pi}\cdot\frac{\pi^{2}}{12\log
2}k}+x_{2}\frac{-a_{2j+1}/8}{\frac{3}{8\pi}\cdot\frac{\pi^{2}}{12\log
2}k},\qquad 0\leq j<k/2$

are identically distributed and $\psi$-mixing with exponential rate. Using the
facts that $|e^{iX_{j}}-1|\leq\min\\{|X_{j}|,2\\}$ and

$1-\cos
X_{j}=2\sin^{2}(X_{j}/2)\geq\frac{2}{\pi^{2}}X_{j}^{2}\mathds{1}_{\\{|X_{j}|\leq\pi\\}},$

one readily checks that $\mathbb{E}|e^{iX_{j}}-1|\ll(\log k)/k$ and
$\mathbb{E}(1-\cos X_{j})\gg 1/k$. Applying [15, Lemma 1] with, in the
notation of that paper, $P\approx\sqrt{k/\log k}$ and $m\approx\sqrt{k/\log
k}$ yields

$\mathbb{E}\exp\left(i\sum_{0\leq j<k/2}X_{j}\right)=\exp\left(\sum_{0\leq
j<k/2}\mathbb{E}\left(e^{iX_{j}}-1\right)\right)+O\left(\frac{(\log
k)^{2}}{k}\right).$

Lemma 20 with $t_{1}=x_{1}\frac{4\log 2}{\pi k}$ and $t_{2}=-x_{2}\frac{4\log
2}{\pi k}$ gives that here

$\begin{split}\sum_{0\leq
j<k/2}\mathbb{E}\left(e^{iX_{j}}-1\right)=&\frac{k}{2\log
2}\int_{0}^{1}\frac{e^{i(t_{1}\lfloor 1/Tx\rfloor+t_{2}\lfloor
1/x\rfloor)}-1}{1+x}\,\mathrm{d}x\\\
=&-|x_{1}|-i\frac{2\gamma}{\pi}x_{1}-i\frac{2}{\pi}x_{1}\log\frac{4(\log
2)|x_{1}|}{\pi k}\\\
&-|x_{2}|+i\frac{2\gamma}{\pi}x_{2}+i\frac{2}{\pi}x_{2}\log\frac{4(\log
2)|x_{2}|}{\pi k}+O\left(\frac{(\log k)^{2}}{k}\right).\end{split}$

After subtracting the appropriate centering term, we thus obtain that the
characteristic function

$\mathbb{E}\exp\left(i\left(x_{1}\frac{\sum_{0\leq
j<k/2}a_{2j+2}/8-B_{k}}{\frac{3}{8\pi}\cdot\frac{\pi^{2}}{12\log
2}k}+x_{2}\frac{-\sum_{0\leq
j<k/2}a_{2j+1}/8+B_{k}}{\frac{3}{8\pi}\cdot\frac{\pi^{2}}{12\log
2}k}\right)\right)$

with

$B_{k}=\frac{3}{4\pi^{2}}\cdot\frac{\pi^{2}}{12\log
2}k\log\left(\frac{\pi^{2}}{12\log
2}k\right)-\frac{3}{4\pi^{2}}\left(\gamma+\log\frac{\pi}{3}\right)\frac{\pi^{2}}{12\log
2}k$

converges pointwise to
$\exp(-|x_{1}|(1+i\frac{2}{\pi}\mathrm{sgn}(x_{1})\log|x_{1}|))\exp(-|x_{2}|(1-i\frac{2}{\pi}\mathrm{sgn}(x_{2})\log|x_{2}|))$,
which is the characteristic funcion of
$\mathrm{Stab}(1,1)\otimes\mathrm{Stab}(1,-1)$. In particular, the first sum
in (27) satisfies

$\left(\frac{\sum_{0\leq
j<k/2}a_{2j+2}/8-B_{k}}{\frac{3}{8\pi}\cdot\frac{\pi^{2}}{12\log
2}k},\frac{-\sum_{0\leq
j<k/2}a_{2j+1}/8+B_{k}}{\frac{3}{8\pi}\cdot\frac{\pi^{2}}{12\log
2}k}\right)\overset{d}{\to}\mathrm{Stab}(1,1)\otimes\mathrm{Stab}(1,-1)\qquad\textrm{as
}k\to\infty.$ (28)

Consider now the second sum in (27). Recall that the Gauss map $T$ is mixing
in the sense of ergodic theory, therefore $T^{2}$ is ergodic. Fix
$\varepsilon>0$, and let $g_{p}^{\pm}$ be as in Lemma 19. Since
$T^{2j}(p_{k}/q_{k})=[0;a_{2j+1},a_{2j+2},\ldots,a_{k}]$ and
$T^{2j}\alpha=[0;a_{2j+1},a_{2j+2},\ldots]$, by construction we have

$|g_{p}^{\pm}(T^{2j}(p_{k}/q_{k}))-g_{p}^{\pm}(T^{2j}\alpha)|\ll|\log[0;a_{2j+2},a_{2j+3},\ldots,a_{k}]-\log[0;a_{2j+2},a_{2j+3},\ldots]|.$

This decays exponentially fast in $k-2j$, hence $\sum_{0\leq
j<k/2}g_{p}^{\pm}(T^{2j}(p_{k}/q_{k}))=\sum_{0\leq
j<k/2}g_{p}^{\pm}(T^{2j}\alpha)+O(1)$. Applying Birkhoff’s pointwise ergodic
theorem to $T^{2}$ thus yields

$\frac{1}{k/2}\sum_{0\leq
j<k/2}g_{p}^{\pm}(T^{2j}(p_{k}/q_{k}))\to\frac{1}{\log
2}\int_{0}^{1}\frac{g_{p}^{\pm}(x)}{1+x}\,\mathrm{d}x\qquad\textrm{for a.e.
}\alpha,$

and after letting $\varepsilon\to 0$,

$\frac{\sum_{0\leq
j<k/2}g_{p}(T^{2j}(p_{k}/q_{k}))}{\frac{3}{8\pi}\cdot\frac{\pi^{2}}{12\log
2}k}\to\frac{1}{\frac{3}{8\pi}}\cdot\frac{6}{\pi^{2}}\int_{0}^{1}\frac{h_{p}(x)-\frac{1}{8}\lfloor
1/Tx\rfloor}{1+x}\,\mathrm{d}x\qquad\textrm{for a.e. }\alpha.$ (29)

We similarly obtain

$\frac{\sum_{0\leq
j<k/2}g_{p^{\prime}}(T^{2j}(p_{k}/q_{k}))}{\frac{3}{8\pi}\cdot\frac{\pi^{2}}{12\log
2}k}\to\frac{1}{\frac{3}{8\pi}}\cdot\frac{6}{\pi^{2}}\int_{0}^{1}\frac{h_{p^{\prime}}(x)+\frac{1}{8}\lfloor
1/x\rfloor}{1+x}\,\mathrm{d}x\qquad\textrm{for a.e. }\alpha.$

The previous two relations imply convergence in distribution, and the desired
limit law follows from (27) and (28). ∎

###### Proof of Theorem 8.

First, let $\alpha\in[0,1]$ be fixed. Recall from (13) that
$|S_{N}(\alpha)-S_{N}(p_{k}/q_{k})|\ll 1$ for all $0\leq N<q_{k}$ with a
universal implied constant. Therefore if $q_{k}\leq M\leq q_{K}$, then
$J_{p,q_{k}}(\alpha)\leq J_{p,M}(\alpha)\leq J_{p,q_{K}}(\alpha)$, and
consequently

$\log J_{p}(p_{k}/q_{k})-O(1)\leq\log J_{p,M}(\alpha)\leq\log
J_{p}(p_{K}/q_{K})+O(1)$ (30)

with universal implied constants. The reverse inequalities hold with
$p^{\prime}$ instead of $p$.

Now let $\alpha\sim\mu$ with a Borel probability measure $\mu$ on $[0,1]$
which is absolutely continuous with respect to the Lebesgue measure. Let
$k_{M}^{*}=k_{M}^{*}(\alpha)$ be the positive integer for which
$q_{k_{M}^{*}}\leq M<q_{k_{M}^{*}+1}$. The convergent denominators of
Lebesgue-a.e. $\alpha$ (and consequently, $\mu$-a.e. $\alpha$) satisfy the law
of the iterated logarithm

$\limsup_{k\to\infty}\frac{\left|\log q_{k}-\frac{\pi^{2}}{12\log
2}k\right|}{\sqrt{k\log\log k}}=c$

with a universal constant $c>0$; in fact, the central limit theorem also holds
for $\alpha\sim\mu$ [16, Section 3.2.3]. Therefore

$\log q_{k_{M}^{*}}-O\left(\sqrt{\log M\log\log\log M}\right)\leq\log
q_{\lfloor\frac{12\log 2}{\pi^{2}}\log M\rfloor}\leq\log
q_{k_{M}^{*}+1}+O\left(\sqrt{\log M\log\log\log M}\right),$

and by the general fact $q_{k+2}/q_{k}\geq 2$ for all $k\geq 1$,

$k_{M}^{*}=\frac{12\log 2}{\pi^{2}}\log M+O\left(\sqrt{\log M\log\log\log
M}\right)\qquad\textrm{for $\mu$-a.e. }\alpha.$

Letting $k_{M}$ be the even integer closest to, say, $\frac{12\log
2}{\pi^{2}}\log M-(\log M)^{3/4}$ and $K_{M}$ be the even integer closest to,
say, $\frac{12\log 2}{\pi^{2}}\log M+(\log M)^{3/4}$, we thus have
$\mu(\\{\alpha\in[0,1]\,:\,k_{M}\leq k_{M}^{*}\leq K_{M}\\})=1-o(1)$ as
$M\to\infty$. By (30), we can write $\log J_{p,M}(\alpha)=\log
J_{p}(p_{k_{M}}/q_{k_{M}})+\xi_{p,M}(\alpha)$, with an error term
$\xi_{p,M}(\alpha)$ which outside a set of $\mu$-measure $o(1)$ satisfies

$|\xi_{p,M}(\alpha)|\ll 1+\left|\log J_{p}(p_{K_{M}}/q_{K_{M}})-\log
J_{p}(p_{k_{M}}/q_{k_{M}})\right|$

with a universal implied constant. The same holds with $p^{\prime}$ instead of
$p$.

Recall the decomposition formula (27) for $(\log
J_{p}(p_{k_{M}}/q_{k_{M}}),\log J_{p^{\prime}}(p_{k_{M}}/q_{k_{M}}))$.
According to Lemma 21, if $\alpha\sim\nu$, then

$\left(\frac{\log J_{p}(p_{k_{M}}/q_{k_{M}})-E_{p,M}}{\sigma_{M}},\frac{\log
J_{p^{\prime}}(p_{k_{M}}/q_{k_{M}})-E_{p^{\prime},M}}{\sigma_{M}}\right)\overset{d}{\to}\mathrm{Stab}(1,1)\otimes\mathrm{Stab}(1,-1)\qquad\textrm{as
}M\to\infty.$

In fact, the same holds if $\alpha\sim\mu$. Indeed, this easily follows from a
mixing property of the Gauss map [16, p. 166]

$\lim_{n\to\infty}\sup_{A\in\mathcal{F}_{n}^{\infty}}\left|\mu(A)-\nu(A)\right|=0,$

where $\mathcal{F}_{n}^{\infty}$ denotes the $\sigma$-algebra generated by the
partial quotients $a_{m}$, $m\geq n$. Note that the terms $j\geq n/2$ in (27)
are $\mathcal{F}_{n}^{\infty}$-measurable.

It remains to show that $\xi_{p,M}(\alpha)=o(\log M)$ and
$\xi_{p^{\prime},M}(\alpha)=o(\log M)$ in $\mu$-measure. By the decomposition
formula (27),

$\begin{split}|\log J_{p}(p_{K_{M}}/&q_{K_{M}})-\log
J_{p}(p_{k_{M}}/q_{k_{M}})|\leq\\\ &\sum_{k_{M}/2\leq
j<K_{M}/2}\frac{a_{2j+2}}{8}+\left|\sum_{0\leq
j<K_{M}/2}g_{p}(T^{2j}p_{K_{M}}/q_{K_{M}})-\sum_{0\leq
j<k_{M}/2}g_{p}(T^{2j}p_{k_{M}}/q_{k_{M}})\right|.\end{split}$

Recall that for any $j\geq 1$ and any real $t\geq 1$,

$\nu\left(\left\\{\alpha\in[0,1]\,:\,a_{j}\geq t\right\\}\right)=\frac{1}{\log
2}\sum_{n\geq t}\log\left(1+\frac{1}{n(n+2)}\right)\ll\frac{1}{t}.$

Since $K_{M}-k_{M}\ll(\log M)^{3/4}$, the union bound thus yields

$\nu\bigg{(}\bigg{\\{}\alpha\in[0,1]\,:\,\sum_{k_{M}/2\leq
j<K_{M}/2}a_{2j+2}\geq\varepsilon\log
M\bigg{\\}}\bigg{)}\ll\frac{1}{\varepsilon(\log M)^{1/4}}.$

In particular, $\sum_{k_{M}/2\leq j<K_{M}/2}a_{2j+2}=o(\log M)$ in
$\nu$-measure, and consequently also in $\mu$-measure. Formula (29) shows that

$\sum_{0\leq j<K_{M}/2}g_{p}(T^{2j}p_{K_{M}}/q_{K_{M}})-\sum_{0\leq
j<k_{M}/2}g_{p}(T^{2j}p_{k_{M}}/q_{k_{M}})=o(\log M)$

holds for Lebesgue-a.e. $\alpha$, and consequently also in $\mu$-measure. This
finishes the proof of $\xi_{p,M}(\alpha)=o(\log M)$ in $\mu$-measure, and the
same arguments show that this holds with $p^{\prime}$ instead of $p$ as well.
∎

###### Proof of Theorem 7.

This is entirely analogous to the proof of Theorem 8. The only difference is
that instead of $|S_{N}(\alpha)-S_{N}(p_{k}/q_{k})|\ll 1$, we use
$|\tilde{S}_{N}(\alpha)-\tilde{S}_{N}(p_{k}/q_{k})|\ll\max_{1\leq j\leq
k}\log(a_{j}+1)$, see [2, Proposition 3]. In particular,
$|\tilde{S}_{N}(\alpha)-\tilde{S}_{N}(p_{k}/q_{k})|\ll\log(k+1)$ for
Lebesgue-a.e. $\alpha$, which suffices for our purposes. ∎

## Acknowledgments

The author is supported by the Austrian Science Fund (FWF) project M 3260-N.

## References

  * [1] C. Aistleitner and B. Borda: A conjecture of Zagier and the value distribution of quantum modular forms. arXiv:2110.07407.
  * [2] C. Aistleitner and B. Borda: Quantum invariants of hyperbolic knots and extreme values of trigonometric products. Math. Z. 302 (2022), 759–782.
  * [3] J. Andersen and S. Hansen: Asymptotics of the quantum invariants for surgeries on the figure 8 knot. J. Knot Theory Ramifications 15 (2006), 479–548.
  * [4] J. Beck: Probabilistic Diophantine Approximation. Randomness in Lattice Point Counting. Springer Monographs in Mathematics. Springer, Cham, 2014.
  * [5] S. Bettin and S. Drappeau: Limit laws for rational continued fractions and value distribution of quantum modular forms. Proc. Lond. Math. Soc. 125 (2022), 1377–1425.
  * [6] S. Bettin and S. Drappeau: Modularity and value distribution of quantum invariants of hyperbolic knots. Math. Ann. 382 (2022), 1631–1679.
  * [7] B. Borda: On the distribution of Sudler products and Birkhoff sums for the irrational rotation. arXiv:2104.06716.
  * [8] D. Dolgopyat and B. Fayad: Limit theorems for toral translations. Hyperbolic Dynamics, Fluctuations and Large Deviations 227–277. Proc. Sympos. Pure Math. 89. Amer. Math. Soc., Providence, RI, 2015.
  * [9] D. Dolgopyat and O. Sarig: Quenched and annealed temporal limit theorems for circle rotations. Astérisque 415 (2020), 57–83.
  * [10] P. Erdős and G. Szekeres: On the product $\prod_{k=1}^{n}(1-z^{a_{k}})$. Acad. Serbe Sci. Publ. Inst. Math. 13 (1959), 29–34.
  * [11] G. Hardy and J. Littlewood: Some problems of Diophantine approximation: the lattice points of a right-angled triangle. Proc. London Math. Soc. 20 (1921), 15–36.
  * [12] G. Hardy and J. Littlewood: Some problems of Diophantine approximation: the lattice points of a right-angled triangle. (Second memoir.) Abh. Math. Sem. Univ. Hamburg 1 (1922), 211–248.
  * [13] M. Hauke: Metric density results for the value distribution of Sudler products. To appear in Proc. Amer. Math. Soc. arXiv:2203.03517.
  * [14] E. Hecke: Über analytische Funktionen und die Verteilung von Zahlen mod. eins. Abh. Math. Sem. Univ. Hamburg 1 (1922), 54–76.
  * [15] L. Heinrich: Rates of convergence in stable limit theorems for sums of exponentially $\psi$-mixing random variables with an application to metric theory of continued fractions. Math. Nachr. 131 (1987), 149–165.
  * [16] M. Iosifescu and C. Kraaikamp: Metrical Theory of Continued Fractions. Mathematics and its Applications, 547. Kluwer Academic Publishers, Dordrecht, 2002.
  * [17] H. Kesten: Uniform distribution mod 1. Ann. of Math. 71 (1960), 445–471.
  * [18] D. Lubinsky: The size of $(q;q)_{n}$ for $q$ on the unit circle. J. Number Theory 76 (1999), 217–247.
  * [19] A. Ostrowski: Bemerkungen zur Theorie der Diophantischen Approximationen. Abh. Math. Sem. Univ. Hamburg 1 (1922), 77–98.
  * [20] J. Schoißengeier: Abschätzungen für $\sum_{n\leq N}B_{1}(n\alpha)$. Monatsh. Math. 102 (1986), 59–77.
  * [21] C. Sudler Jr.: An estimate for a restricted partition function. Quart. J. Math. Oxford Ser. 15 (1964), 1–10.
  * [22] D. Zagier: Quantum modular forms. Quanta of maths, Clay Math. Proc. pp. 659–675. Amer. Math. Soc. Providence, RI, 2010.