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

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 \le N<M} S_N(\alpha)$ and $\min_{0 \le N<M} S_N(\alpha)$ with a random $\alpha \in [0,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 (α) = N n=1 ({nα} − 1/2), where {•} denotes the fractional part function.The history of the sum S N (α) 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 (α) = o(N ) for any irrational α, but the precise behavior is rather delicate and depends on the Diophantine properties of α.It is enough to consider α ∈ [0, 1], and we shall focus on the case of a randomly chosen α.
Throughout, X ∼ µ denotes the fact that a random variable X has distribution µ, µ ⊗ ν denotes the product measure of µ and ν, and d → denotes convergence in distribution.The standard stable law of stability parameter 1 and skewness parameter ±1, denoted by Stab(1, ±1), is the law with characteristic function exp(−|x|(1±i 2 π 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/(π(1 + x 2 )), and will be denoted simply by "Cauchy".
In this paper, we work with S N (α) = N n=1 ({nα} − 1/2) with the fixed starting point β = 0, and instead of choosing N randomly, we consider the extreme values max 0≤N <M S N (α) and min 0≤N <M S N (α) as well as certain exponential moments of the values S N (α), 0 ≤ N < M .Our main distributional result is a limit law for the joint distribution of the maximum and the minimum.The fact that the limit distribution in Theorem 1 is a product measure means that the maximum and the minimum of S N (α) 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 (α), 0 ≤ N < M ), and for (max + min)/2 (the center of the range) as well: ∼ Cauchy, as can be easily seen from the characteristic functions.Theorem 1 similarly implies that max The cumulative distribution function of max{X, Y } is simply the square of that of Stab (1,1).Limit laws of Birkhoff sums for circle rotations N n=1 f (nα + β) with some of the parameters N, α, β 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 N n=1 f (nα) 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 (α), see Lemma 9 below.We will actually work with S N (r) with rational r instead of an irrational α, and eventually let r be a suitable best rational approximation to a random α.As the main ingredient in the proof of our limit laws, we will show that while max 0≤N <q S N (r) and min 0≤N <q S N (r) are rather complicated as functions of the variable r ∈ (0, 1) ∩ Q, the functions h ∞ (r) = max 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 denotes the denominator of r resp.T 2 r in their reduced forms.This makes the functions max 0≤N <q S N (r) and min 0≤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 (α) shows a close similarity to SN (α) = N n=1 log |2 sin(πnα)|, the Birkhoff sum with the 1-periodic function log |2 sin(πx)| having logarithmic singularities at integers.This similarity is not surprising considering that SN (α) and πS N (α) are the real and the imaginary part of the complex-valued Birkhoff sum N n=1 log(1 − e 2πinα ), defined with the principal branch of the logarithm.Note that e SN (α) = N n=1 |1 − e 2πinα | 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≤N <q SN (r) and min 0≤N <q SN (r) exhibit complicated behavior, the functions 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 ±∞ and h±∞ 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 α ∼ µ with an absolutely continuous probability measure µ on [0, 1], then max where ẼM = 3Vol(4 1 )

SN (α) + min
which easily follows from [2, Eq. ( 17)].This immediately yields a limit law for min 0≤N <M SN (α) as well, and shows that in contrast to Theorem 1, the joint distribution of converges to a probability measure supported on a straight line in R 2 instead of a product measure.The difference in the definition of h ±∞ and h±∞ (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 (α) is odd, whereas SN (α) is even in the variable α.See also [13,18] for the asymptotics of SN (α) at a.e.α.
In contrast to random reals, for a badly approximable irrational α we have S N (α) = O(log N ), and this is sharp since lim sup as shown by Ostrowski [19].For a quadratic irrational α, we can say more: general results of Schoissengeier [20] on S N (α) immediately imply that max and min with some explicitly computable constants C ∞ (α) > 0 and C −∞ (α) < 0, and implied constants depending only on α.Note that C ∞ (α) resp.C −∞ (α) is the value of the limsup resp.liminf in (3).
For example, we have Similar results hold for SN (α).For all badly approximable irrational α we have SN (α) = O(log N ), and this is sharp since lim sup N →∞ SN (α)/ log N ≥ 1 for all (not necessarily badly approximable) irrationals [18].For a quadratic irrational α, we similarly have [2] max and min Here the constants C∞ (α) ≥ 1 and C−∞ (α) ≤ 0 are related by C∞ (α) + C−∞ (α) = 1, but their explicit value is known only for a few simple quadratic irrationals such as the golden mean or √ 2 (in both cases C∞ = 1 and C−∞ = 0).Thus, once again, the maximum and the minimum of SN (α) determine each other, unlike those of S N (α) for which the constants C ∞ (α) and C −∞ (α) 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 (α), SN (α)) with a fixed quadratic irrational α and N ∼ Unif({1, 2, . . ., 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.

Connections to quantum modular forms
A quantum modular form is a real-or complex-valued function f defined on P 1 (Q) = Q ∪ {∞} (except perhaps at finitely many points) which satisfies a certain approximate modularity relation under the action of SL(2, Z) with fractional linear transformations on P 1 (Q).Instead of stipulating f (γr) = f (r) for any γ ∈ SL(2, Z) (true modularity), the functions h γ (r) = f (γr)−f (r) are required, roughly speaking, to enjoy better continuity/analyticity properties than f itself in the real topology on P 1 (Q) (approximate modularity).Most known examples of quantum modular forms come from algebraic topology or analytic number theory.
Given a parameter −∞ ≤ p ≤ ∞, p = 0 and a rational number r whose denominator in its reduced form is q, define Jp where N n=1 |1 − e 2πinr | is the Sudler product.The function Jp (r) is 1-periodic and even in the variable r, and by [2,Proposition 2] it also satisfies the identity J−p (r) = q/ Jp (r).

The original motivation came from algebraic topology, as J2
2 is (an extension of) the so-called Kashaev invariant of the figure-eight knot 4 1 .The asymptotics along the sequence of rationals where 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 J2 "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 SL(2, 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 → r + 1 and r → −1/r generate the full modular group, and the first of these transformations acts trivially on the argument of Jp (r), the function is the key to understanding the action of SL(2, Z).Observe that h−p (r) = − hp (r), hence it is enough to consider p > 0. Numerical evidence presented by Zagier suggests that h2 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 h2 at all irrationals is now known as Zagier's continuity conjecture.Aistleitner and the author [1] proved that hp can be extended to a function on R which is continuous at every irrational α = [a 0 ; a 1 , a 2 , . ..] such that sup k∈N a k = ∞, thereby confirming Zagier's continuity conjecture almost everywhere.In the same paper it was further shown that 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 Note that in [1] these results were stated only for p = 2, but the proof works mutatis mutandis for all 0 < p ≤ ∞.
In this paper, we interpret Jp as a natural quantity related to the Birkhoff sum SN (r) = N n=1 log |2 sin(πnr)|, and hp as the key to understanding the action of the Gauss map T on the argument of Jp .Recall that T : [0, 1) → [0, 1) is defined as T x = {1/x}, x = 0 and T 0 = 0, thus hp (r) = log( Jp (r)/ Jp (T r)).We show that the Birkhoff sum S N (r) = N n=1 ({nr} − 1/2) yields a function J p (r) which exhibits remarkable similarity to Jp (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 −∞ ≤ p ≤ ∞, p = 0 and a rational number r whose denominator in its reduced form is q, we thus define and r) .
Note that these are perfect analogues of Jp (r) with S N (r) playing the role of SN (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 where T 2 is the second iterate of the Gauss map.The function log J ∞ (r) = max 0≤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 < ∞ 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 ∈ N, we have and it is an easy exercise to show that (cf.Lemma 15 below) Since S N (1/q), 0 ≤ N < q attains its maximum at N = 0, q − 1 and its minimum at N = q−1 2 , q−1 2 , for p = ±∞ we even have the explicit formulas As a direct analogue of (6), we establish a far-reaching generalization of the asymptotics (7) to general rationals.Theorem 2. For any −∞ ≤ p ≤ ∞, p = 0 and any r ∈ (0, 1) ∩ Q, with a universal implied constant.
We can express Theorem 2 in terms of the continued fraction expansion r = [0; a 1 , a 2 , . . ., a L ] of r ∈ (0, 1) ∩ Q as 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 ≥ 2, we consider the second partial quotient of r = 1/q = [0; q] = [0; q − 1, 1] (when T r = 0) to be well defined as a 2 = 1.
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 Theorem 3. Let −∞ ≤ p ≤ ∞, p = 0, and let α ∈ (0, 1) be an irrational whose continued fraction expansion α = [0; a 1 , a 2 , . ..] satisfies sup k∈N a 2k+εp = ∞.Then lim r→α 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 α which satisfies sup k∈N a 2k+εp = ∞.
Recall that Lebesgue-a.e. α satisfies sup k∈N a 2k = ∞ and sup k∈N a 2k+1 = ∞.In particular, the extension of h p is a.e.continuous.We conjecture that the condition sup k∈N a 2k+εp = ∞ 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 ∈ (0, 1) and a /q = T 2 (a/q) ∈ [0, 1) be reduced rationals, and set and Note that we excluded the rationals 1/q for p > 0. Since T r → ∞ as r → (1/q) − , Theorem 2 implies that in this case lim r→(1/q) − h p (r) = ∞.As for approaching a rational point from the opposite side, numerical experiments suggest that h p is right-continuous for 0 < p ≤ ∞, and left-continuous for −∞ ≤ p < 0 at all rationals not of the form 1/q.  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 hp 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 hp .
Given α ∈ R and M ∈ N, as a generalization of J p we define  and Let Jp,M (α) be defined the same way, with SN (α) instead of S N (α).Letting p k /q k denote the convergents to α, roughly speaking, for M ≈ q k we have J p,M (α) ≈ J p (p k /q k ) and Jp,M (α) ≈ Jp (p k /q k ).The asymptotics of Jp,M (α) as M → ∞ at various irrational α was studied in detail in [2,6].In particular, for a quadratic irrational α it was shown that with some constant Cp (α) and an implied constant depending only on α.Moreover, the constants satisfy the relation Cp (α) + C−p (α) = 1.In this paper, we establish a similar result for J p,M (α).
Theorem 5.For any −∞ ≤ p ≤ ∞, p = 0 and any quadratic irrational α, with some constant C p (α) and an implied constant depending only on α.
The constants C p (α) and Cp (α) are closely related to the limit of the functions h p and hp at quadratic irrationals.As an illustration, consider , 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 .
In particular, while we cannot establish the continuous extension of h ±∞ to √ 3 − 1, we know that in case they can be continuously extended to that point, their values must be h this is in good accordance with the numerics.For a general quadratic irrational α, the constant C p (α) can be similarly expressed in terms of the limit of h p at the points of the finite orbit of α under T 2 , provided that these limits exist.

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 Jp (r) with a random rational r; more precisely, for a randomly chosen element of where Ẽp,q = 3Vol(4 1 ) π 3 log q log log q + Dp log q and σq = 3Vol(4 1 ) 2π 2 log q, with the constant Here γ denotes the Euler-Mascheroni constant.This was proved in [1] for p = 2, but the proof works mutatis mutandis for all 0 < p ≤ ∞.The identity J−p (r) = q/ Jp (r) mentioned in Section 2 means that log Jp (a/q) + log J−p (a/q) = log q, and a limit law follows for −∞ ≤ p < 0 as well.
In this paper, we show a similar limit law for J p (r) with a random rational r.
where, for any p = 0, E p,q = sgn(p) 3 4π 2 log q log log q + D p log q and σ q = 3 8π log q, with the constant Remark.The identity J −p (r) = 1/J p (1 − r) and the fact that a/q → 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 first sum, with suitable centering and scaling, converges in distribution to 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 Jp .We follow a similar strategy for J p .We consider the telescoping sum log J p (r) = j≥0 h p (T 2j r); note that h p (0) = 0. Using Theorems 2 and 3, we can write h p (r) = sgn(p)a εp /8 + g p (r) with an a.e.continuous Lebesgue integrable function g p (x). Letting a/q = [0; a 1 , a 2 , . . ., a L ] be a random fraction, we thus have 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.log M , with the constant Dp defined in (9).Formula (2) is a special case of Theorem 7 with p = ∞.Since log Jp,M (α) + log J−p,M (α) = log M + o(log M ) in µ-measure, a similar limit law holds for log Jp,M (α) with −∞ ≤ p < 0.
Theorem 8. Let α ∼ µ with a Borel probability measure µ on [0, 1] which is absolutely continuous with respect to the Lebesgue measure.For any where, for any p = 0, E p,M = sgn(p) 3 4π 2 log M log log M + D p log M and σ M = 3 8π log M , with the constant D p defined in (10).
Theorem 1 is a special case of Theorem 8 with p = ∞ and p = −∞.4 The function h p Throughout this section, we fix a real number α and a parameter −∞ ≤ p ≤ ∞, p = 0, and define ε p as in (8).If α ∈ Q, we write its continued fraction expansion in the form α = [a 0 ; a 1 , a 2 , . . ., a L ], and we let q be the denominator of α in its reduced form.If α ∈ Q, we write its continued fraction expansion in the form α = [a 0 ; a 1 , a 2 , . ..], and set L = ∞ and q = ∞.
The convergents to α are denoted by p /q = [a 0 ; a 1 , a 2 , . . ., a ], 0 ≤ < L + 1.Any integer 0 ≤ N < q can be uniquely written in the form N = L−1 =0 b (N )q , where 0 ≤ b 0 (N ) < a 1 and 0 ≤ b (N ) ≤ a +1 , 1 ≤ < L are integers which further satisfy the rule that b +1 (N ) = a +2 implies b (N ) = 0.This is the so-called Ostrowski expansion of N with respect to α, a special number system tailored to the circle rotation by α; in fact, it was first introduced in connection to S N (α) [19].The Ostrowski expansion of course has finitely many terms; more precisely, if 0 ≤ N < q K with some integer 0 The distance from the nearest integer function is denoted by • .We will often use the fact that except if = 0 and a 1 = 1; however, in the latter case b 0 (N ) = 0 for all 0 ≤ N < q, and q 0 α does not enter our formulas.Recall also the recursion q +1 = a +1 q + q −1 with initial conditions q 0 = 1, One of our main tools is an explicit formula for S N (α) due to Ostrowski [19] (see [4, p. 23] for a more recent proof).
Lemma 9 (Ostrowski).Let 0 ≤ N < q be an integer with Ostrowski expansion Remark.The alternating factor (−1) +1 in Ostrowski's explicit formula is related to the fact that S N (α) is an odd function in the variable α.An application of the second iterate of the Gauss map corresponds to shifting the partial quotients by two indices, leaving the factor (−1) +1 unchanged.

Local optimum
In this section, we "locally optimize" S N (α) by choosing a single Ostrowski digit b k (N ).Note that the = k term in Ostrowski's explicit formula in Lemma 9 is Given an odd resp.even index k, we can thus expect a particularly large resp.small value of S N (α) when choosing b k (N ) ≈ a k+1 /2.Lemma 10 below quantifies how the value of S N (α) changes as we deviate from the optimal value a k+1 /2.In particular, in Lemma 11 below we show that in the sum q−1 N =0 e pS N (α) with p > 0 resp.p < 0, the main contribution comes from the terms with b k (N ) ≈ 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 ≤ N < q be an integer with Ostrowski expansion N = L−1 =0 b (N )q , and let 0 ≤ k < L. Define b * k = a k+1 /2 , and Then 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 By the rules of the Ostrowski expansion, here 0 ≤ k−1 j=0 b j (N )q j < q k .Therefore the second and the third line in (11) are negligible: and consequently in the first line in (11) we have This finishes the proof in the case b k+1 (N ) < a 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 ≤ k < K ≤ L be integers such that a k+1 ≥ A with a large universal constant If k is even, then Proof.We give a detailed proof in the case 0 < p < ∞.The proof for −∞ < p < 0 is entirely analogous, whereas the claims on the maximum and the minimum follow from letting p → ±∞.Assume thus that 0 < p < ∞, and that k is odd.Set Z = 0≤N <q K e pS N (α) , and consider the sets Let |b−a k+1 /2| > max{10, 10/ √ p} a k+1 log a k+1 and b = 0. Then the map injective, and by Lemma 10, Z.
As the number of possible values of b is at most a k+1 − 1, the previous three formulas lead to Z.

Factorization of J p
In this section, we establish a factorization of 0≤N <q K e pS N (α) 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 α.In the special case of a rational α and K = L, we obtain a factorization of J p (α).
All implied constants are universal.
We mention that the condition |b k (N ) − a k+1 /2| ≤ max{10, 10/ |p|} 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 ≤ N < q be an integer with Ostrowski expansion with a universal implied constant.
Proof.Apply Ostrowski's explicit formula in Lemma 9 to N , and consider the sum over 0 ≤ ≤ k−1 and k ≤ < L separately.The sum over 0 ≤ ≤ k − 1 is precisely S N 1 (α).For k ≤ < L we have Since N 1 < q k , the terms k + 1 ≤ < L in the previous formula satisfy 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 → ±∞.
Lemma 11 shows that .
For every such N , Therefore by Lemma 13, and consequently Substituting this in (12) gives It remains to replace α by p k /q k in the first main factor in the previous formula.For any 1 ≤ n < q k , we have |nα − np k /q k | = (n/q k ) q k α < 1/q k , and np k /q k is not an integer.In particular, there is no integer between nα and np k /q k , so Therefore for any 0 Replacing α by p k /q k thus introduces a negligible multiplicative error 1 + O(1/a k+1 ).

The matching lemma
Assume now that α ∈ (0, 1), and recall that we write its continued fraction expansion in the , where T 2 is the second iterate of the Gauss map T .Then α = [0; a 3 , a 4 , . . ., a L ] if α ∈ Q, with the convention that α = 0 if L ≤ 2, and α = [0; a 3 , a 4 , . ..] if α ∈ Q.Let q denote the denominator of α in its reduced form if α ∈ Q, and let q = ∞ if α ∈ Q.Let p /q = [0; a 3 , a 4 , . . ., a ], 3 ≤ < L + 1 and p 2 = 0, q 2 = 1 denote the convergents to α .The Ostrowski expansion of integers 0 ≤ N < q with respect to α will be written as Given an integer 0 ≤ N < q with Ostrowski expansion that this is a legitimate Ostrowski expansion with respect to α , that is, b (N ) = b (N ) for all 2 ≤ < L. The map N → N , from {0 ≤ N < q : b 2 (N ) < a 3 } to [0, q ) 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 0≤N <q e pS N (α) to terms of the sum 0≤N <q e pS N (α ) .By comparing S N (α) to S N (α ), the following "matching lemma" is a key ingredient in the study of the function h p .Lemma 14.Let 0 ≤ N < q be an integer with Ostrowski expansion N = L−1 =0 b (N )q with respect to α such that b 2 (N ) < a 3 .Then The implied constants are universal.
Proof.Since p , q satisfy the same second order linear recursion of which p , q are linearly independent solutions, they are linear combinations of p , q .Indeed, one readily checks that p = (a 1 a 2 + 1)p − a 2 q and q = q − a 1 p for all 2 Now let 2 ≤ j ≤ < L be integers.We claim that if either ≥ 3, or = 2 and a 3 > 1, then A classical identity of continued fractions states that q α = 1/(Rq + q −1 ) and q α = 1/(Rq + q −1 ).Formula ( 14) thus leads to q j q α − q j q α = a 1 Rq j q p j q j − p q + q j q −1 p j q j − p −1 q −1 (Rq + q −1 )(Rq + q −1 ) .
Observe that R ≥ a +1 , and recall the identity |q p −1 − q −1 p | = 1.If j = , we thus have as claimed.This finishes the proof of (15).We now prove the lemma.Since b (N ) = b (N ) for all 2 ≤ < L, Ostrowski's explicit formula in Lemma 9 gives b j (N ) q j q α − q j q α + q α − q α 2 .
By the estimate (15) and the fact that q +1 ≥ q 2 q +1 (which can be seen e.g. by induction), the absolute value of the sum over 2 ≤ < L in the previous formula is at most This finishes the proof of the first claim.

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 < ∞ and any integer a ≥ 1, 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 which suffices for the ≥ part of ( 16).If pa < 100, then simply using the fact that each term is at least 1 yields which again suffices for the ≥ part of (16).If p > 64a, then it is enough to keep the b = a/2 term in the sum, yielding which also suffices for the ≥ 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 In the last step we used the fact that sup y≥0 ye −y 2 y 0 e x 2 dx < ∞.This establishes (17).
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 In particular, r) , the formula being trivial for b 1 = 0, as in that case the two sums are identical.
The "matching" map N → N introduced in Section 4.3 is a bijection and by Lemma 14, Consequently, r ) .
We now sum over all possible values of b 0 , b 1 , and apply Lemma 15 to deduce r ) .
By the definition of h p , this means that which is an equivalent form of the claim.

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 α ∈ (0, 1) with continued fraction expansion α = [0; a 1 , a 2 , . ..] and convergents p k /q k = [0; a 1 , a 2 , . . ., a k ].Let denote the set of real numbers in (0, 1) whose first k + 1 partial quotients are identical to those of α.Recall that I k+1 ⊂ (0, 1) is an interval with rational endpoints; in particular, α ∈ int I k+1 .

In particular, if sup
and consequently lim r→α h p (r) exists and is finite by the Cauchy criterion.This proves Theorem 3.
An application of Lemma 12 to r resp.r with K = L yields 0≤N <q e pS N (r) Here b (N ) resp.b (N ) denote the digits in the Ostrowski expansion with respect to r resp.r .Consequently, with the crucial observation that depends only on α, but not on r.
The "matching" map N → N introduced in Section 4.3 is a bijection from the set and by Lemma 14 and (18) leads to This establishes the desired upper bound to the oscillation of h p on the set I k+1 ∩ Q.

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 = ±∞ is entirely analogous.Fix a reduced rational a/q ∈ (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 , . . ., a s ] with odd s ≥ 3 if p > 0, and even s ≥ 2 if p < 0, and let p k /q k = [0; a 1 , a 2 , . . ., a k ] denote its convergents.In particular, s + 1 ≡ ε p (mod 2).Let I(n) be the set of all reals of the form [0; a 1 , a 2 , . . ., a s , m, . ..] with m ≥ 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 − κ n , a/q) is a left-hand neighborhood if p > 0, whereas I(n) = (a/q, a/q+κ n ] is a right-hand neighborhood if p < 0, of length κ n = 1/(q 2 s n+q s−1 q s ).It will thus be enough to prove that sup r∈I(n)∩Q |h p (r) − W p (a/q)| → 0 as n → ∞.Now let n > A max{1, 1 |p| log 1 |p| } with a large universal constant A > 1, and let r ∈ I(n) ∩ Q be arbitrary.The continued fraction of r is thus of the form r = [0; a 1 , a 2 , . . ., a L ] with L ≥ s + 1 ≥ 3 and a s+1 ≥ n.In particular, the convergents p k /q k , 0 ≤ k ≤ L to r coincide with those to a/q for 0 ≤ k ≤ s.Let r = T 2 r = [0; a 3 , . . ., a L ] with convergents p k /q k = [0; a 3 , . . ., a k ], 3 ≤ k ≤ L and p 2 = 0, q 2 = 1.Then a /q = T 2 (a/q) = [0; a 3 , . . ., a s ] has the same convergents for 2 ≤ k ≤ s.
Following the steps in the proof of Theorem 16 leading up to (18) (with k = s), we deduce e p(S N (a/q)−sgn(p)N/(2q)) 0≤N <q e p(S N (a /q )−sgn(p)N/(2q )) Here b (N ) resp.b (N ) denote the digits in the Ostrowski expansion with respect to r resp.r .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 → N introduced in Section 4.3 is a bijection from the set .
By Lemma 14, for all such N , Hence and the desired limit relation follows.

Quadratic irrationals
Fix a quadratic irrational α and a parameter −∞ ≤ p ≤ ∞, p = 0. Throughout this section, constants and implied constants may depend on α.
Let us write the continued fraction expansion in the form α = [a 0 ; a 1 , . . ., a s , a s+1 , . . ., 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 (α) is odd in the variable α, cf. the alternating factor (−1) +1 in Ostrowski's explicit formula in Lemma 9. Solving the recursions with periodic coefficients gives that for any k ≥ 0 and 1 ≤ r ≤ m, with some explicitly computable constants η > 1, E r , G r > 0 and F r ∈ R, 1 ≤ r ≤ 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 ≤ N < q s+km be an integer with Ostrowski expansion N = s+km−1 =s b (N )q .Let i ≥ 1 be an integer, and set Proof.Note that the shift results in a legitimate Ostrowski expansion for Formula (19) shows that here q j+im q +im α − q j q α = O(η −(j+ )/m ) for all s ≤ j ≤ , and the claim follows.
We now show that log J p,M (α) with M = q s+km is approximately additive in k.
Proof.It will be enough to prove the lemma for finite p.The claim for p = ±∞ then follows from taking the limit as p → ±∞.
Note that each individual term in Ostrowski's explicit formula in Lemma 9 is O(1).In particular, S N (α) = 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 (α) by O (1). Let b (N )q 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 − (α) = S N (α) + O (1).Hence for all k ≥ 1, Now fix i, k ≥ 1.Let 0 ≤ N < q s+im and 0 ≤ N < q s+km be integers with Ostrowski expansions Note that the block of zeroes in the middle ensures that the extra rule of Ostrowski expansions (b +1 (N ) = a +2 implies b (N ) = 0) is satisfied.The map [0, q s+km ) × [0, q s+im ) → [0, q s+(i+k+1)m ), (N , N ) → N is injective.Deleting the first s Ostrowski digits of N , and then applying Lemmas 17 and 13 shows that S N (α) = S N (α) + S N (α) + O (1).Using (20) as well thus leads to Next, for any integer 0 ≤ N < q s+(i+k)m with Ostrowski expansion 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 the limit laws
For any r ∈ (0, 1) ∩ Q, define (ii) If p > 0, then for all n ∈ N, the functions g ± p are smooth on iii) If p < 0, then the functions g ± p are smooth on (0, 1), and g ± p (x) = ±2c log(1/x) for all x ∈ (0, δ p ).
Proof.Fix ε > 0. Assume first, that p > 0, and let δ p > 0 be a small constant to be chosen.If n is large enough so that 1 n − δ p ≤ 1 n+1 , then we are forced to define g . Since g p is bounded and a.e.continuous, and consequently Riemann integrable on [ 1 n+1 , 1 n − δ p ], we can approximate g p pointwise from above and from below by step functions, and extend them to ( 1 n − δ p , 1 n ) as ±2c log(1/T x).By choosing δ p small enough, we can ensure that these piecewise defined upper and lower approximating functions are ε-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 ε-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 [δ p , 1], and extend them as ±2c log(1/x) on (0, δ 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.
with a universal implied constant.
Here log ((n + 1)(m + 1) + 1)(nm + 1) ), and we can write The second term is estimated as The infinite series is easily computed using telescoping sums: By symmetry, we also have ∞ n,m=1 mR n,m = −γ, thus the second term in (23) is We can rewrite the first term in (23) as with the principal branch of the logarithm.For j = 1, 2, The previous formula together with (23) and (24) lead to the claim of the lemma.
In particular, the theorem states that for any ε > 0 there exist small constants τ = τ (ε) > 0 and δ = δ(ε) > 0 such that for all t = (t After subtracting the appropriate centering term, we thus obtain that the characteristic function  From [5, Theorem 3.1] with m = 2, φ 1 (x) = g ± p (x) and φ 2 (x) = 0, we similarly deduce j≥0 g p (T 2j (a/q)) log These formulas combined with (25) and (26) immediately yield the joint limit law Since log q/ log Q d → 1, we can replace E p,Q by E p,q and σ Q by σ q .
Proof.For the sake of simplicity, we assume that k is even, in which case log J p (p k /q k ), log J p (p k /q k ) = g p (T 2j (p k /q k )), g p (T 2j (p k /q k )) .
(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 ψ-mixing random variables.Fix real constants x 1 , x 2 such that (x 1 , x 2 ) = (0, 0); in what follows, implied constants are allowed to depend on x 1 , x 2 .The random variables  After subtracting the appropriate centering term, we thus obtain that the characteristic function

log
|2 sin(πx)| dx = 2.02988 . . .denoting the hyperbolic volume of the complement of the figure-eight knot (see Section 2) and some constant D∞ ∈ R. The maximum and the minimum now determine each other via the relation max 0≤N <M e 2πinr |, J−∞ (r) = min 0≤N <q N n=1 |1 − e 2πinr |,

Figure 1 :
Figure1: The function log J ∞ (r) = max 0≤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 < ∞ looks very similar, whereas the graph of log J −p (r) = − log J p (−r) is obtained by reflections.

Figure 4 :
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 = ±∞ look markedly different.The four depicted functions are evaluated at all reduced rationals in [0, 1) with denominator at most 150.

)
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)| ≤ c(1 + log(1/T x)) if p > 0, and |g p (x)| ≤ c(1 + log(1/x))if p < 0 with a large constant c > 0 depending only on p. Lemma 19.For any ε > 0, there exist a constant δ p > 0 and functions g ± p on [0, 1] with the following properties.