Boundary effect on the nodal length for Arithmetic Random Waves, and spectral semi-correlations

We test M. Berry's ansatz on nodal deficiency in presence of boundary. The square billiard is studied, where the high spectral degeneracies allow for the introduction of a Gaussian ensemble of random Laplace eigenfunctions ("boundary-adapted arithmetic random waves"). As a result of a precise asymptotic analysis, two terms in the asymptotic expansion of the expected nodal length are derived, in the high energy limit along a generic sequence of energy levels. It is found that the precise nodal deficiency or surplus of the nodal length depends on arithmetic properties of the energy levels, in an explicit way. To obtain the said results we apply the Kac-Rice method for computing the expected nodal length of a Gaussian random field. Such an application uncovers major obstacles, e.g. the occurrence of"bad"subdomains, that, one hopes, contribute insignificantly to the nodal length. Fortunately, we were able to reduce this contribution to a number theoretic question of counting the"spectral semi-correlations", a concept joining the likes of"spectral correlations"and"spectral quasi-correlations"in having impact on the nodal length for arithmetic dynamical systems. This work rests on several breakthrough techniques of J. Bourgain, whose interest in the subject helped shaping it to high extent, and whose fundamental work on spectral correlations, joint with E. Bombieri, has had a crucial impact on the field.

∆ϕ j + λ j ϕ j = 0, satisfying either Dirichlet or Neumann boundary conditions, where ∆ = div •∇ is the Laplace-Beltrami (Laplacian) operator on M, and λ j ≥ 0 are the energy levels (or simply the energies). It is well-known that the spectrum of ∆ is purely discrete, i.e. there exists a complete orthonormal system {ϕ j } j≥1 (orthonormal basis), spanning the whole of L 2 (M), so that all the spectral multiplicities are finite, and λ j → ∞ as j → ∞ being the high energy limit. Much of the focus in the study of the nodal lines of Laplace eigenfunctions has been turned to the study of the nodal length, i.e. the total length L (ϕ j ) of the curve ϕ −1 j (0) on M, as j → ∞. Yau's conjecture [27] asserts that the nodal length is commensurable with λ j , i.e. (1.2) c M · λ j ≤ L (ϕ j ) ≤ C M · λ j for some positive constants c M , C M > 0. Yau's conjecture was proven [6,7,11] for M analytic, and more recently the optimal lower bound [18] and polynomial upper bound [19] were established for the more general, smooth, case (see also [17]).
1.2. Nodal length for random fields. One way to obtain stronger (or more precise) results than (1.2) is to study the nodal length L (f ) of random functions f , an approach that has been actively pursued, in particular in the recent few years. As a concrete direction of research within the indicated scope, one may take a Gaussian random field f : R 2 → R (or f : R d → R, d ≥ 2) and study the distribution of the nodal length L (f ; R) of f restricted to B(R) ⊆ R 2 , the radius-R centred ball, R → ∞. For 1 f : R 2 → R stationary a straightforward application of the standard Kac-Rice formula yields a precise expression (1.3) E[L (f ; R)] = c · Vol(B(R)), whereas a significantly heavier machinery involving perturbation theory (and asymptotic analysis of the 2-point correlation function) yields an asymptotic expression for the variance Var(L (f ; R)), as R → ∞. One may go further by applying the Wiener chaos decomposition on L (f ; R) to obtain [15] a limit law for the distribution of L (f ; R) Var(L (f ; R)) .
Alternatively to working with a fixed random field restricted to expanding balls, one may fix a compact surface M, consider a Gaussian ensemble of random functions on M, i.e. a sequence f n : M → R of Gaussian random fields indexed by M, and study the asymptotic distribution of the nodal length of f n , that is the total length L (f n ) of f −1 n (0), as n → ∞; in some natural examples (to be discussed below) f n possesses a natural scaling with n.
Berry [2] suggested that for M generic chaotic, there exists a (non-rigorous) link between the (deterministic) eigenfunctions ϕ j as in (1.1), and the restriction of monochromatic isotropic random wave g (a particular random field on R 2 to be defined immediately below), to B(R) with R ≈ λ j ; this vague relation, usually referred to as "Berry's Random Wave Model" (RWM), agreed in a wide community, is subject to many numerical tests with overwhelmingly positive outcomes. In particular, the study of the nodal structures of g restricted to B(R) as R → ∞ facilitates our understanding of the nodal structures of ϕ j in the high energy limit. Berry's monochromatic isotropic random wave g is uniquely defined as the centred Gaussian random field on R 2 with covariance function r g (x − y) = r g (x, y) := E[g(x) · g(y)] = J 0 (|x − y|), x, y ∈ R 2 , whose Fourier transform on R 2 is the arc length of the unit circle (meaning that the monochromatic waves are propagating uniformly in all directions). Since r g depends only on the Euclidean distance |x − y|, the law of g is invariant under all translations g(·) → g(· + z), z ∈ R 2 , and rotations g(·) → g(o ·), o ∈ O(2) (i.e. g is stationary isotropic); it has applications in the study of ocean waves propagating [20,21]. Consistent to the above (1.3), the expected nodal length for this stationary model is easily found to be (1.4) E[L (g; R)] = c 0 · Vol(B(R)), with c 0 > 0 explicitly evaluated, via a straightforward application of the Kac-Rice formula. Berry [3,Formula (28)] further found that the variance is logarithmic, i.e. satisfying the asymptotic law (1.5) Var(L (g; R)) = c 1 · R 2 log R + O R→∞ (R 2 ), much smaller than one would expect, due to an "obscure cancellation" (see also [26]).
The central objective of this manuscript is investigating the effect of nontrivial boundary on the nodal structures of Laplace eigenfunctions, first and foremost on the nodal length, either in the vicinity of the boundary, or globally. Berry argued that, since the nodal line is perpendicular to 1 From this point we will tacitly assume that all the involved random fields are sufficiently smooth and are satisfying some non-degeneracy assumptions. the boundary [9] (except for intersection points with higher degree vanishing), its presence should impact its length negatively compared to (1.4), he referred to as "nodal deficiency". He backed this ansatz by a precise evaluation of the secondary term around the boundary for the "boundary-adapted random waves", a Gaussian random field constrained to satisfy the boundary conditions, Dirichlet or Neumann, on an infinite straight line.
It was concluded that, bearing in mind that the primary term in his asymptotic expansion of nodal length for this boundary-adapted case is consistent to (1.4), whereas the secondary term was, a large number of wavelengths away from the boundary, negative (identical between Dirichlet and Neumann boundary conditions), with total contribution in absolute value larger than the length fluctuations in (1.5) (possibly extending to the boundary-adapted case), based on one sample only, one should be able to detect the deficiency of the total nodal length of Laplace eigenfunctions for surfaces with boundary compared to the boundary-less case. Gnutzmann and Lois [12] supported Berry's deficiency ansatz by performing a mean nodal volume calculation for M cuboid of arbitrarily high dimension, a dynamical system with separation of variables, while averaging w.r.t. energy levels (rather than w.r.t. a Gaussian ensemble). for some nonnegative integers a, {e j } j≤s , {h k } k≤r , and p j ≡ 1 mod 4 and q ≡ 3 mod 4 are primes. By a classical result due to E. Landau [16] the sequence S ⊆ Z is thin, i.e. of asymptotic density 0, and, what is stronger, with some semi-explicit constant c 0 > 0. Any function g n : T 2 → R on the torus T 2 = R 2 /Z 2 of the form where a µ ∈ C are some constants satisfying the condition (1.10) a −µ = a µ and N n = |E n | is the size of the lattice points set E n (equivalently, N n = r 2 (n), the number of ways to express n as a sum of two squares), is a real-valued Laplace eigenfunction with eigenvalue (1.11) λ n = 4π 2 n.
The convenience pre-factor 1 √ Nn on the r.h.s. of (1.9) has no bearing on the nodal set of g n , and will be understood below. Conversely, any real-valued Laplace eigenfunction on T 2 is necessarily of the form (1.9) for some n ∈ S.
The linear space of functions (1.9) may be endowed with a probability measure by making the coefficients {a µ } µ∈En i.i.d. standard complex valued Gaussian random variables, save for the condition (1.10) to ensure the g n are real-valued; this model is called "Arithmetic Random Waves". Alternatively and equivalently, Arithmetic Random Waves is the Gaussian ensemble of centred stationary random fields with the covariance functions (1.12) p n (x) = E[g n (x) · g n (0)] = 1 N n µ∈En cos(2π x, µ ); its (random) nodal length Z n = L (g n ) on T 2 is our etalon, representing the boundary-less cases for comparison against the appearance of nontrivial boundary. As it is the case with stationary random fields, it is easy to evaluate its expected nodal length to be Rudnick and Wigman [23] gave the useful upper bound (1.14) showing, in particular, that the distribution of Zn √ n concentrates around the constant π √ 2 . Krishnapur-Kurlberg-Wigman [13] further resolved the question of the true asymptotic behaviour of the variance on the l.h.s. of (1.14), requiring the following background in the two squares problem. For every n we define the atomic probability measure (1.15) ν n = 1 N n µ∈En δ µ/ √ n on the unit circle S 1 , supported on the angles of S 1 corresponding to points of E n . It is known that for a "generic" sequence {n} ⊆ S the angles {µ/ √ n} µ∈En equidistribute on S 1 , i.e. there exists a relative density 1 sequence {n} ⊆ S, so that with ' ⇒ standing for the weak- * convergence of probability measures on S 1 , and in particular N n → ∞. However, there exist [10,13,14] other attainable measures, i.e. weak- * partial limits of the sequence {ν n } n∈S , and even under the (generic) constraint N n → ∞, the accumulation set of the sequence { ν n (4)} of the 4th Fourier coefficients of ν n (being the first nontrivial Fourier coefficient) is the whole of [−1, 1]. The said work [13] established the precise asymptotic relation and, bearing in mind that 1 + ν n (4) 2 is bounded away from both 0 and infinity, in particular, it shows that the fluctuations around the mean of Z n are of the order of magnitude important below, just like (1.5), due to an unexpected cancellation ("arithmetic Berry's cancellation"). Later a non-universal limit theorem for Z n was obtained [22].
1.4. Boundary-adapted Arithmetic Random Waves. The boundary-adapted Arithmetic Random Waves are random Laplace eigenfunctions on the unit square Q = [0, 1] 2 , subject to Dirichlet boundary conditions. Let S be the as above (1.6), n ∈ S, and µ = (µ 1 , µ 2 ) ∈ E n a lattice point with E n given by (1.7). Any function of the form Q → R is a Laplace eigenfunction with eigenvalue satisfying the Dirichlet boundary conditions on Q (cf. (1.11)). However, given µ = (µ 1 , µ 2 ) ∈ E n and µ = (±µ 1 , ±µ 2 ) ∈ E n , the resulting maps as in (1.19) differ at most by a sign. Therefore, to avoid redundancies, we introduce the equivalence relation on E : (µ 1 , µ 2 ) ∼ (µ 1 , µ 2 ) if µ 1 = ±µ 1 and µ 2 = ±µ 2 . The general form of a Laplace eigenfunction on Q satisfying Dirichlet boundary conditions assumes the form for some n ∈ S, and we endow this linear space with a Gaussian probability measure by making the {a µ } µ∈En/∼ i.i.d. standard (real) Gaussian random variables. If either µ 1 = 0 or µ 2 = 0, then the corresponding summand in (1.21) vanish, so that we are allowed to assume that both µ 1 = 0 and µ 2 = 0. We then call the random function (1.21) equipped with the said Gaussian probability measure "boundary-adapted Arithmetic Random Waves", much like the Arithmetic Random Waves (1.9). Alternatively (and equivalently), the boundary-adapted Arithmetic Random Waves is the ensemble of Gaussian centred random fields indexed by x ∈ Q, with covariance functions n ∈ S, x = (x 1 , x 2 ), y = (y 1 , y 2 ) ∈ Q. The f n are not stationary, even though, around generic points in Q, far away from the boundary, f n asymptotically tends to stationarity [8], understood in suitable regime, after suitable re-scaling. The main interest of this manuscript is the expected nodal length of f n , and its comparison to (1.13), from this point on tacitly assuming N n → ∞.
) be the total nodal length of f n on Q, and recall the notation (1.15) and (1.20). There exists a subsequence of energy levels S ⊆ S satisfying the following properties: a. The sequence S is of relative asymptotic density 1 within S. b. The set of accumulation points of the sequence of numbers { ν n (4)} n∈S is [−1, 1]. c. Along n ∈ S we have N n → ∞, and The asymptotics (1.23) is expressed in terms of λ n rather than in terms of n in a way that the leading term on the r.h.s. of (1.23) agrees with (1.13) explicitly, for there is a discrepancy factor of 2 otherwise, due to the discrepancy between (1.11) and (1.20). The boundary effect is then encapsulated within the second, correction, term On one hand the asymptotics (1.23) shows that, since, outside a thin set of n ∈ S, we have the convergence (1.16) of ν n to the uniform measure on S 1 , for such a sequence of n the correction term is asymptotic to confirming Berry's ansatz on the nodal deficiency. On the other hand, bearing in mind that, by property (b) of the sequence in Theorem 1.1, the accumulation set of { ν n (4)} n∈S is the whole of [−1, 1], without exclusions from S , C n · N n fluctuates infinitely in the asymmetric interval The maximal nodal deficiency (resp. maximal nodal surplus) in (1.24) is uniquely attained by the Cilleruelo measure 1 4 (δ ±1 + δ ±i ) (resp. its tilt by π/4), consistent with our interpretation of the amplified horizontal and vertical wave propagation for Cilleruelo sequences (resp. their π/4-tilt for the tilted Cilleruelo), in light of Berry's rationale of nodal deficiency occurring as a result of nodal lines perpendicular to the boundary. Finally, we notice that, judging by the analogous quantity for the Arithmetic Random Waves (1.18), and applying M. Berry's reasoning, explained in §1.2, we expect the fluctuations of L n to be of the same order of magnitude ≈ √ n Nn as C n (a by-product of the aforementioned "miraculous" cancellation). That means that, unlike the situation in [3], one cannot detect the nodal surplus or deficiency judging by the total nodal length based on one sample only. However, this could be mended by taking more samples, or, likely, by restricting the sample to the vicinity of the boundary.
The main conclusion (1.23) of Theorem 1.1 is valid for "generic" n ∈ S ⊆ S only, rather than for the whole sequence n ∈ S, though, importantly, this generic family is sufficiently rich so that to exhibit a variety of different asymptotic biases of the correction term (1.24). Below Theorem 1.4 will be stated, a version of Theorem 1.1 with an explicit control over the error term in (1.23), valid for the whole sequence n ∈ S of energy level, expressed in terms of the so-called "spectral semicorrelations", defined in §1.5 (see Definition 1.2). Our failure to unrestrict the statement of Theorem 1.1 for the whole sequence n ∈ S is then a by-product of Theorem 1.3 below asserting a bound for the semi-correlations for a generic sequence of energy levels. We do believe that (1.23) holds for n ∈ S, with no further restriction.  be an even number, with k ≥ 1 an integer. The length-l spectral correlation set [13] is the set (1.26) R l (n) = (µ 1 , . . . , µ l ) ∈ E l n : l j=1 µ j = 0 of all l-tuples of lattice points in E n whose sum vanishes; by an elementary congruence obstruction modulo 2, for l odd the corresponding correlation sets are all empty. The size of R l (n) is directly related to the l-th moment of the covariance function (1.12) corresponding to the Arithmetic Random Waves: and bounding |R 6 (n)| was a key ingredient for bounding the remainder while proving (1.17) in [13]. Since, for k ≥ 2, fixing µ 1 , . . . , . . . , µ l−2 so that determines the remaining two lattice points µ l−1 and µ l up to permutation, it is readily seen that for every l ≥ 4, be the set of all l-tuples cancelling out in pairs, where S l is the symmetric group permuting the ltuples, of size |D l (n)| ∼ c k · N k n . Evidently, for every l and n ∈ S, we have the inclusion Hence, in particular (1.27) |R l (n)| N k n , recalling (1.25). Bombieri and Bourgain [4] showed that (1.28) |R 6 (n)| N 7/2 n , and established the striking inequality for some γ > 0, valid for density-1 sequence of n ∈ S, or, alternatively, conditionally for the full sequence S, so that, in particular, for these n, the optimal inequality (1.29) |R l (n)| N k n holds (recall (1.25)).
In [5], the notion of spectral quasi-correlations, was instrumental for studying the analogue of Z n for the Arithmetic Random Waves (1.9), restricted to domains decreasing with n above Planck scale, e.g discs with radius n −1/2+δ ("Shrinking balls"). For l as above and > 0, a length-l quasi correlation is an l-tuple (µ 1 , . . . , µ l ) of points in E n so that It was shown [5,Theorem 1.4] that for n generic and l arbitrary even number, the quasi-correlation set is empty.
In this manuscript we introduce a new concept, of semi-correlations, instrumental within the proof of Theorem 1.1, as it will allow us to control the problematic singular set in Q, see Corollary 2.6, and, we believe, of independent interest on its own right. From the above definition, it is evident that so that, in particular, |M l (n)| N k n , cf. (1.27). Quite remarkably, the following optimal upper bound holds for the semi-correlation set size, albeit for a generic sequence only. c. Along n ∈ S we have N n → ∞ and (1.31) |M l (n)| = O N k n . By using a standard diagonal argument it is possible to choose a density 1 sequence S ⊆ S, satisfying (1.31) for all l ≥ 4 even (with constant involved in the 'O'-notation depending on l). Theorem 1.3 is stronger compared to the upper bound (1.29) for the spectral correlations, due to Bombieri-Bourgain, also valid for a density one sequence of n ∈ S. In addition to claiming the upper bound for the semi-correlations rather, significantly weaker than correlation, at also asserts the richness of the postulated sequence in terms of the angular distribution of E n , expressed in terms of the Fourier coefficients { ν n (4)} n∈S . The following result is a version of Theorem 1.1, with an explicit control over the error term in (1.23), expressed in terms of the spectral semi-correlations. After a significant amount of effort put into, we still do not know whether (1.31) holds for all l even, along n ∈ S with no further restriction, and believe this question to be of sufficiently high interest, both for applications of the type of Theorem 1.1, and intrinsic, to be addressed in the future.  2.1.1. The Kac-Rice formula. The Kac-Rice formula is a meta-theorem allowing one to evaluate the (d − 1)-volume of the zero set of a random field F : R d → R, for F satisfying some smoothness and non-degeneracy conditions. For F : R d → R, a sufficiently smooth centred Gaussian random field, we define the zero density (first intensity) of F . Then the Kac-Rice formula asserts that for some suitable class of random fields F and D ⊆ R d a compact closed subdomain of R d , one has the equality We would like to apply (2.1) on the random fields f n in (1.21) to evaluate the expectation on the l.h.s. of (1.23). Unfortunately, for some n, the aforementioned non-degeneracy conditions fail decisively for some points of Q. For these cases, an approximate version of Kac-Rice was developed [24, Proposition 1.3] (in a slightly different context of evaluating the variance), so that rather than holding precisely, (2.1) would hold approximately, still yielding the asymptotic law for the evaluated expectation. Nevertheless, for this particular case, by excising some neighbourhoods of the problematic degenerate set, consisting of a union of a grid and finitely many isolated points, and by applying the Monotone Convergence Theorem, we will be able to deduce that (2.1) holds precisely, save for the length of the said deterministic grid contained in the nodal set of f n for some n ∈ S of a particular form.
Let n ∈ S be of the form (1.8), and denote the associated number so that, in particular, Q 2 n |n. We will establish later (cf. Lemma 3.1 below) that in such a scenario, all of the µ 1 and µ 2 on the r.h.s. of (1.21) are divisible by Q n , so that if Q n > 1, then necessarily the (deterministic) grid Lemma 3.1 will also assert that such a situation is only possible in this scenario, i.e. all the components {µ 1 } µ∈En/∼ are divisible by a maximal number d > 1, if and only d = Q n in (2.2). The following proposition is the announced Kac-Rice formula, with the said caveat (namely, the length of G n , manifested on the r.h.s. of (2.6)).
be the zero density of f n . Then, for every n ∈ S, we have K 1 ∈ L 1 (Q), and moreover, we have where Q n is as in (2.2).
For example, by comparing (2.6) to (2.1), we may deduce as a particular by-product of Proposition 2.1, that (2.1) holds precisely in our case, if and only if Q n = 1, i.e. the grid is empty. Below it will be demonstrated that Q n on the r.h.s. of (2.6) does not contribute to the Kac-Rice integral (nor to the correction term √ nC n in (1.23), with C n given by (1.24)), e.g., it is easily dominated by

2.1.2.
The joint distribution of (f n (x), ∇f n (x)). By the definition (2.5) of the zero density function of f n , to investigate K 1 (x) we naturally encounter the value distribution of both f n (x), determined by Var(f n (x)), and ∇f n (x) conditioned on f n (x) = 0, determined by its 2 × 2 (conditional) covariance matrix. On recalling that the covariance function r n of f n is given by (1.22) with an elementary manipulation and well-known trigonometric identities yielding Further, we need to evaluate the covariance matrix of ∇f n (x) conditioned on f n (x) = 0. A scrupulous direct computation, carried out in Appendix A shows that the corresponding (normalised) covariance matrix is given by the following: , conditioned on f n (x) = 0, and appropriately normalised, is the following 2 × 2 real symmetric matrix: where v n is given by (2.7) and (2.8); 2.1.3. Singular set. Next, we aim at analysing the asymptotic behaviour of the r.h.s. of (2.6). Towards this goal we will separate the domain Q of the integration on the r.h.s. of (2.6) into the "good" or nonsingular set, where K 1 is "tame", i.e. admits precise asymptotic (Proposition 2.7), and the "bad" or singular sets, which itself consists of small singular squares so that to be able to control the integral of K 1 . First, we will bound the total contribution of the singular set (Corollary 2.6) from above, by separately bounding the number of small singular squares (Proposition 2.4), appealing to the bound for spectral semi-correlations in Theorem 1.3, and the contribution of a singular small square (Proposition 2.5).
Below it will asserted that for most of the points x ∈ Q, both the value of v n (x) is close to unit (equivalently, s n (x) is small), and Ω n in (2.9) is close to the unit matrix (equivalently, Γ n is small); we will designate the other points as "singular", and excise them while performing an asymptotic analysis on K 1 . To quantify it, we take 0 > 0 and c 0 > 0, and keep them fixed but sufficiently small throughout. We will endow the singular set with a structure of a union of small squares (cf. [23,24]).
and for 1 ≤ i, j ≤ K denote the small square We have the partition Q = 1≤i,j≤K Q ij of the square into a union of small squares, disjoint save for boundary overlaps. a. Recall the notation in (2.8) and (2.9). A small square Q ij in (2.13) is "singular" if it contains a point x 0 ∈ Q ij satisfying either of the three inequalities: of all small singular squares. c. The complement Q \ Q s of the singular set is called "nonsingular set".
The following couple of propositions assert a bound for the total measure of the singular set, and for the contribution of a single singular square respectively. Combining these two will yield an upper bound for the total contribution of the singular set Q s to the integral on the r.h.s. of (2.6). Proposition 2.4 (Bound for the measure of the singular set). For every l ≥ 4 even integer we have the following bound for the measure of the singular set in terms of the length-l spectral correlation set (1.30): where the constant involved in the 'O -notation depends only on l.
Proposition 2.5 (Bound for a single small square). Let Q ⊆ Q be an arbitrary square of side length c 0 √ n with c 0 > 0 sufficiently small. Then with the constant involved in the 'O'-notation in (2.15) absolute.
It is worthy of a mention that the doubling exponent method due to Donnelly-Fefferman [11], with relation to Yau's conjecture (1.2), yields the deterministic bound of O (1) for the nodal length of f n restricted to Q as in Proposition 2.5, that, being better than the global bound of √ n, falls short from being sufficient for our needs 2 , by a significant margin. We believe that the optimal upper bound on the r.h.s. of (2.15) should be O 1 √ n , however, after some effort, we were not able to prove that. Instead, we sacrifice a power of N n by virtually not exploiting the summation in (1.22) (except the invariance of E n w.r.t. µ = (µ 1 , µ 2 ) → (µ 2 , µ 1 )), in the hope to gain the lost power of N n while bounding the number of singular squares (equivalently, the measure of Q s ), which is precisely what is achieved in Proposition 2.4, with the help of Theorem 1.3. In particular, Proposition 2.5 applies to all singular squares Q ij ⊆ Q s , leading to the following, possibly sub-optimal, result.
Corollary 2.6. For every l ≥ 4 even integer we have the following bound for the contribution of the singular set to the integral on the r.h.s. of (2.6): The upshot of Corollary 2.6 is that, thanks to Theorem 1.3, by choosing l sufficiently big, we can make the r.h.s. of (2.16) smaller than √ n · N −A n , with A > 0 arbitrarily large. That is crucial if we are to majorise it by the second term in the claimed asymptotic expansion (1.23), of order of magnitude ≈ √ n Nn . The proof of Corollary 2.6 is immediate given Propositions 2.4 and 2.5, and, thereupon, conveniently omitted.

2.1.4.
Perturbative analysis on the non-singular set. Outside the singular set, the precise analysis for the density function is feasible.
Proposition 2.7 (Asymptotics for K 1 outside Q s ). Let 0 > 0 be a sufficiently small number, and recall that s n (·) and Γ n (·) are given by (2.8) and (2.10) respectively. Then K 1 admits the following asymptotics, uniformly for x ∈ Q \ Q s , where the leading term is given by Any bound of the form O N A n √ n , A > 0, would be sufficient for our purposes, by choosing l sufficiently high (see how Theorem 1.1 is inferred from Theorem 1.4, as explained immediately after the latter theorem). and the error term is bounded by with constant involved in the 'O'-notation absolute.
We observe that, by the definition (2.10) with (2.11)-(2.12), the diagonal entries of Γ n (x) are bounded by an absolute constant (using the nonnegativity of the d ·;n (x) 2 ), and therefore, so are the diagonal entries of Ω n (x) in (2.9), and, further, all the entries of Ω n are bounded by an absolute constant, by the Cauchy-Schwarz inequality 3 . Taking also into account (2.8), and the definition (2.17) of L(x) = L n (x), we conclude that L(x) is uniformly bounded with the involved constant absolute; this will prove useful later, while restricting (or, rather, unrestricting) the range of the integration in (2.6) to Q \ Q s .
2.1.5. Proof of Theorem 1.4. The following lemma will be proved in §7 below. (2.17), and l ≥ 4 an even number. Then Given the above results, the proof of Theorem 1.4 is rather straightforward.
with Q n given by (2.2). First, we claim that for every A > 0, so that the contribution of the grid length is majorised by the error term on the r.h.s. of (1.32). To this end, we recall the prime decomposition (1.8) of n, and write Since, as it is well-known, and N n = O(n ) for every > 0, we may easily write (taking A : This argument recovers the Gaussian Correlation Inequality in this particular case, see e.g. [25]. which is (2.21). Next, we use the asymptotics of K 1 on the nonsingular set claimed in Proposition 2.7 to write

2.2.
Outline of the proof of Theorem 1.3. To prove Theorem 1.3, our first step as in [4], is to restrict ourselves to the set of integers n ∈ S with "typical" factorization type. This is accomplished (for square-free n) with the help of Lemma 8.1. Fixing "typical" n = p 1 p 2 . . . p r with p 1 < p 2 < · · · < p r , the key observation then is that any non-trivial relation of the form can be rewritten as a non-degenerate quasi-linear equation with respect to the Gaussian primes p j = π jπj , where each π * j,s = {π j ,π j } with rotation factor α s ∈ Z. Thus, having primes p 1 , p 2 . . . p r−1 fixed, the equation (2.24) determines arg π r , and therefore prime p r in a unique fashion (see the proof of Proposition 8.2 for the details). After conditioning on this value of p r and taking into account Lemma 8.1, we deduce that equality (2.24) can occur only for small proportion of numbers n ∈ S. This is accomplished in Proposition 8.2 for those n ∈ S which are free of small prime factors and in Proposition 8.3 for general n ∈ S.
In order to show that, the set of accumulation points of the sequence of numbers { ν n (4)} n∈S is the whole of [−1, 1], we choose n ∈ S of the form n = p m n p, where p n and p are appropriately chosen primes and m ∈ S using classical result due to Kubilius (Lemma 8.4). This is the content of Proposition 8.5.
Outline of the paper. The rest of the paper is organised as follows. The proof of a version of the Kac-Rice formula in Proposition 2.1 will be given in §3, and the asymptotics for the Kac-Rice integral on the r.h.s. of (2.6) will be analysed throughout §4- §7, as follows. An upper bound of Proposition 2.4 for the singular set Q s as in Definition (2.3) in terms of the semi-correlations set will be established in §4, whereas a contribution of a single small square Q ij ⊆ Q s of Proposition 2.5 will be controlled in §5.
The perturbative analysis of Proposition 2.7 for the zero density on the nonsingular set will be carried out in §6, whose contribution to the expected nodal length of f n will be evaluated in §7. A proof of Theorem 1.3, bounding the semi-correlation set, will be given in §8, whereas some more technically demanding computations, required as part of proofs for the said results, will be performed in the appendix.

PROOF OF PROPOSITION 2.1: KAC-RICE FORMULA FOR EXPECTED NODAL LENGTH
In view of [1, Theorem 6.3] (see also [1, Proposition 1.2]), the equality (2.6) holds provided that the Gaussian distribution of f n (x) is non-degenerate for every x ∈ Q. It is easy to construct examples of numbers n, so that this non-degeneracy condition fails decisively for some points in Q. Let Lemma 3.1. Let n be of the form (1.8), recall that Q n is given by (2.2), and the grid G n as in (2.3). Then we have the decomposition where A n ⊆ Q is a finite set of isolated points in Q.
Proof. First we aim at proving the announced decomposition (3.2). Let x = (x 1 , x 2 ) ∈ H n , whence, by the definition (3.1) of H n , for all µ ∈ E n / ∼ either µ 1 x 1 ∈ Z or µ 2 x 2 ∈ Z holds, and recall that we assumed that µ 1 , µ 2 = 0 for all µ ∈ E n / ∼ (as otherwise the corresponding summand in (1.21) necessarily vanishes). Assume that for some µ ∈ E n we have µ 1 x 1 ∈ Z, and denote l := µ 1 x 1 ∈ Z. Then, since x 1 ∈ [0, 1] and µ 2 1 + µ 2 2 = n, necessarily |l| ≤ √ n, and x 1 = l µ 1 . Hence, if for some µ = (µ 1 , µ 2 ) ∈ E n / ∼ we have µ 1 x 1 ∈ Z, and for some µ = ( µ 1 , µ 2 ) ∈ E n / ∼ we have µ 2 x 2 ∈ Z, then both coordinates (x 1 , x 2 ) belong to the finite set A n := l µ j : 0 < |l| ≤ √ n, µ ∈ E n / ∼ , so that, by prescribing A n ⊆ A n , the A n in the decomposition (3.2), is finite, provided that we prove that the rest of H n is indeed the grid G n . By the above, we may assume that x ∈ H n satisfies (3.3) µ 1 x 1 ∈ Z for all µ ∈ E n / ∼, and claim that in this case necessarily x 1 is of the form for some 1 ≤ k ≤ Q n − 1, taking care of the symmetric case (µ 2 x 2 ∈ Z for all µ ∈ E n / ∼) along identical lines. Once having (3.4) established, that would yield that x ∈ G n on the grid (see (2.3)), and we would only have the burden of proving the converse inclusion G n ⊆ H n (which is easy).
To the end of proving (3.4), we let (3.5) Q n := gcd{µ 1 : µ ∈ E n / ∼} = gcd{µ 2 : µ ∈ E n / ∼} be the greatest common divisor of the abscissas of all the lattice points in E n . Then, since the set of integers d so that d ∈ x 1 ∈ Z is an ideal in Z, we have Q n x 1 ∈ Z (equivalently, since we can express Q n as a linear combination of {µ 1 : µ ∈ E n / ∼}). The above shows that (3.3) is equivalent to the single condition Q n x 1 ∈ Z. That is, , and, since x 1 ∈ (0, 1), we also get 1 ≤ k ≤ Q n − 1, yielding (3.4) (that, as mentioned above, in turn implies x ∈ G n ), once we prove that Q n = Q n , to be shown next.
To this end we recall the prime decomposition (1.8) of n, and work in the ring of Gaussian integers Z[i] (which is a unique factorization domain, or, simply, UFD), where we think of E n ⊆ R 2 as embedded into C, via the map µ = (µ 1 , µ 2 ) → µ 1 + iµ 2 . For every prime p j in the decomposition (1.8) we associate a prime element π j ∈ Z[i] with norm π j 2 = p j , and take a 0 = a − 2 a/2 = 0 a even 1 a odd .
With this notation, and (2.2), one may express every µ ∈ E n / ∼ (i.e., as an element of C, up to a sign or complex conjugation) as for some 0 ≤ k j ≤ e j , j = 1, . . . s. This implies that Q n |Q n at once. To see that also Q n |Q n , we further exploit the UFD property of Z[i], implying, in particular, that the gcd in Z[i] is well-defined. By the definition (3.5) of Q n , we have that Q n |µ 1 , µ 2 for all µ ∈ E n / ∼, and so Q n |µ in Z[i], valid for all µ ∈ E n , i.e. Q n |Q n := gcd{µ : µ ∈ E n / ∼} ∈ Z[i]. However, by making the two choices k j := e j , and k j := 0, having only Q n · (1 + i) a 0 as a common factor in (3.6), it shows that Q n = Q n · (1 + i) a 0 , and recalling that either a 0 = 0 or a 0 = 1, the readily established |Q n |Q n , and Q n |Q n (so that Q n could be either Q n or Q n · (1 + i), the latter not being an integer number), this readily implies Q n = Q n , that, as it was mentioned above, yields that x ∈ G n . To finish the statement of Lemma 3.1 it is sufficient to observe that if x 1 is of the form (3.4), then, in light of (3.5), and Q n = Q n above, (3.3) is satisfied, so that the inclusion G n ⊆ H n holds.
With the above preparatory result we are now in a position to conclude the proof of Proposition 2.1.
Proof of Proposition 2.1. Around each points in x i ∈ H n we excise a small ball B(x i , ε), and denote with the intention to apply the Kac-Rice method to evaluate the expected nodal length of the restriction f n | Qε of f n to the remaining set. That is, we excised the radius-ε balls centred at each of the finitely many points A n , and, possibly, finitely many rectangles of the form (x 1 − ε, x 1 + ε) × (0, 1) and (0, 1) × (x 2 − ε, x 2 + ε), centred at the horizontal and vertical bars of the grid G n , in case it is nonempty. Since outside H n , the random field f n satisfies the non-degeneracy hypothesis of [1, Theorem 6.3], the Kac-Rice formula (2.1) holds for f n restricted to Q ε , asserting that the restricted expected nodal length is given by On one hand, since, on recalling (2.4), the restricted nodal length {L (f n | Qε )} ε>0 is an increasing sequence of nonnegative random variables with the a.s. limit On the other hand, by the definition, We will need the following auxiliary lemmas, whose proofs will be given in §4.2 below.
Lemma 4.1. Let Q ij ⊂ Q s be a singular small square. Then necessarily one of the followings holds: a. For every y ∈ Q ij , |s n (y)| > 0 /2.
The respective measures of Q s,1 and Q s,2 will be bounded in the following lemma. Recall that M l (n) is the length-l spectral semi-correlation set (1.30).  Proof of Lemma 4.1. We assume that for some i, j, there exists x 0 ∈ Q ij with (4.5) |s n (x 0 )| > 0 , and claim that for all x ∈ Q ij , the inequality (4.6) |s n (x)| > 0 /2 holds (assuming c 0 is sufficiently small), i.e. scenario (a) of Lemma 4.1 prevails. On recalling the definition (2.8) of s n , and differentiating (2.8) explicitly, it is easy to obtain the uniform bound with some absolute constant c 1 > 0. This readily implies that s n (·/ √ n) is a Lipschitz function with associated constant absolute, i.e.
Essentially the same argument works for the other two scenarios (b) and (c) of Lemma 4.1, on recalling the definition (2.10) of Γ n (·), and exploiting the Lipschitz property of both tr(Γ n (·)) and det(Γ n (·)), in place of s n (·). These are easy to establish to be with Lipschitz constant of order of magnitude at most √ n, by differentiating the individual entries of Γ n (·).
Proof of Lemma 4.3. We first aim to prove the first statement Since l is even, we may bound Recalling the definition of the semi-correlation set M l (n) in (1.30), we observe that, for i = 1, 2, we easily evaluate: and the same (4.10) whereas for the other integral in (4.8), we recall the correlation set (1.26) to bound as, obviously, R l (n) ⊆ M l (n). The first statement (4.3) of Lemma 4.3 follows directly from (4.8), (4.9), (4.10) and (4.11), via Chebyshev's inequality. Finally, the same argument as above also yields the second statement (4.4) of Lemma 4.3, upon observing that for every y ∈ Q s,2 we have |s n (y)| ≤ 0 with 0 small; so on Q s,2 we can Taylor expand the function that appear in the entries of the conditional covariance matrix Γ n (x).

PROOF OF PROPOSITION 2.5: CONTROLLING THE CONTRIBUTION OF A SMALL SQUARE
5.1. Proof of Proposition 2.5. We will first state the following lemma, whose proof will be given in §5.2 immediately below.

Proof of Lemma 5.1.
Proof. Let η, µ ∈ E n / ∼, and Q ⊆ Q be an arbitrary square of side length c 0 √ n with c 0 > 0 sufficiently small. Now we write where x 1 ∈ [0, 1], k η = η 1 x 1 π ∈ Z is the integer value of η 1 x 1 /π, independent of x 1 by the above, and h η = h η (x 1 ) ∈ (−π/2, π/2]. We also denote the numbers k µ , x µ 1 and h µ = h µ (x 1 ) are defined analogously, with η 1 replaced by µ 1 . Note that, h η and h µ , both being linear functions of x 1 , satisfy the relation , that will be exploited below. Finally, we denote crucially depending on η, µ and Q only (but independent of x 1 ).
First, we bound the contribution of the main term in the integrand on the r.h.s. of (5.17). To this end we notice that h η and h µ are both linear functions of x 1 , so we are going to exploit their inter-dependence (5.6) (and its analogue for h µ ) to write: where we denoted (5.19) x 1 := πx 1 − x η 1 , a linear transformation of the variable x 1 , and used (5.12). We complete the expression on the r.h.s. of (5.18) to a square: note that we may assume that s µ = 0 and s η = 0 (holding outside a discrete set of x 2 ). Substituting the identity (5.20) into (5.18), we may bound the contribution of the main term of the integral on the r.h.s. of (5.17) as where we have transformed the coordinates (5.19), andĨ i is some shift of the interval I i .
Another transformation of coordinates w.r.t. x 1 shows that, denoting I i the new range of integration, (5.21) is equal to since the integral w.r.t. t is bounded by an absolute constant.
Next, we turn to evaluating the contribution of the error term Q |s η s µ | · E η,µ (x 1 ) to the integral (5.17). By (5.14), we have (5.23) we will bound the 1st integral on the r.h.s. of (5.23), with the last one being bounded along similar lines, and the 2nd and the 3rd ones are easier, as the corresponding numerator is divisible by both h η and h µ (see the argument below). We might bound the 1st integral on the r.h.s. of (5.23) (or the integral w.r.t. x 1 ), using the Cauchy-Schwarz inequality to bound the denominator from below, so that which has the unfortunate burden of having to deal with h µ in the denominator, that could potentially be much smaller than h η . To deal with this obstacle we exploit the relation (5.10) between h η and h µ once again, both being linear functions of x 1 . We write For the former integral on the r.h.s. of (5.25) we use the aforementioned idea (5.24) to bound the denominator from below since |h η | ≤ π 2 is bounded, so that, after the integration w.r.t. x 2 , we obtain Concerning the latter integral on the r.h.s. of (5.25) (or the double integral on Q), since, as above, h η is bounded, we have readily evaluated above as the main term (see (5.22)). Combining the estimates (5.27) and (5.26), and substituting them into (5.25) (integrated w.r.t. x 2 on I j ) yield the bound for the 1st integral on the r.h.s. of (5.23), and its analogues for the other integrals on the r.h.s. of (5.23) also follow (the 4th is symmetric, whereas the 2nd and the 3rd are easier, with no need to deal with the denominator). Substituting (5.28) and its analogues for the other three integrals in (5.23) into (5.23), we finally obtain a bound for the contribution of the error term This, together with (5.22), and (5.17), implies the statement (5.1) of Lemma 5.1 in this non-degenerate case (5.11).
Finally, we treat the degenerate case x η 1 = x µ 1 , or, equivalently, (5.30) In this case the situation becomes easier to analyse, and the main terms of the expansion (5.13) vanishes via (5.30), so that here (5.13) reads with the same bound (5.14) for the error term. The argument leading to (5.26) above works unimpaired, with no need to bound the extra term (5.27) here, as the precise identity (5.30) reduces bounding the integral (5.25) (after integrating w.r.t. x 2 on I j ) to bounding (5.26) with no remainder term (5.27). This shows that in this degenerate case, (5.29) holds, and, by (5.31), it also shows that the statement (5.1) of Lemma 5.1 holds here.

PROOF OF PROPOSITION 2.7: PERTURBATIVE ANALYSIS ON THE NON-SINGULAR SET
Proof. The proof of Proposition 2.7 rests on a precise Taylor analysis for the density function K 1 .
We exploit the fact that the Gaussian expectation (2.5) is an analytic function with respect to the parameters of the corresponding covariance matrix outside its singularities. It is then possible to Taylor expand K 1 explicitly, in the domain Q \ Q s , where both s n (x) and the all the entries of Γ n (x) are small. We first expand the factor 1 Var(f n (x)) = 1 1 − s n (x) = 1 + 1 2 s n (x) + 3 8 s 2 n (x) + O(s 3 n (x)). (6.1) that appear in (2.5). Next, we consider the Gaussian integral Observing that , we expand the exponential in (6.2) as: so that the Gaussian integral (6.2) is such that . We introduce the following notation: and (6.4) In Lemma 6.1, postponed at the end of this section, we evaluate the terms I i (Γ n (x)); we use Lemma 6.1 to write Finally we expand the factor 1 det(I 2 + Γ n (x)) .

PROOF OF LEMMA 2.8: BOUNDARY EFFECT AND ERROR TERM
We first prove Lemma 2.8a. By the definition (2.17) of L n (x), we have [tr(Γ n (x))] 2 dx. (7.1) The following technical lemma evaluates the individual integrals encountered within (7.1).
Lemma 7.1. The integrals of the individual terms on the r.h.s. of (7.1) admit the following asymptotics. a.
The proof of Lemma 7.1 is postponed till Section C.
Each point ξ r can be uniquely written as a product ξ r = i k ξr j≤s π * j,r where each π * j,r ∈ {π j ,π j } and k ξr ∈ {0, 1, 2, 3}. We now regroup the terms in the last expression by collecting π s andπ s into different summands to end up with an equivalent form  In the latter case we must have Since n ∈ F s we have p 1 p 2 . . . p s−1 =ñ|n and so by definitionñ ∈ S \S. This implies that (8.2) and consequently (8.1) must be trivial with A s−1 = B s−1 = 0. This contradicts the definition of n ∈ F s . Hence tan(φ s ) is determined uniquely and so is the corresponding prime p s . Indeed, if π (1) s = x 2 + y 2 and p (2) s = a 2 + b 2 are two primes corresponding to the same angle φ s , then Since (a, b) = (x, y) = 1, we have that |a| = |x| and |b| = |y| and therefore a 2 + b 2 = x 2 + y 2 = p (1) s := p s . We are now ready to estimate the number of m ∈ Ω M,K which give rise to a nontrivial solution of (1.30). By Lemma 8.1, we can restrict ourselves to m = p 1 p 2 . . . p r ∈ Ω M,K , with K < p 1 < p 2 < · · · < p r and p j ≥ 2 jΦ(j) for any 1 ≤ j ≤ r and some slowly growing function Φ(x) to be determined later. Clearly for each such m, there exists unique 1 ≤ s ≤ r such that the product p 1 p 2 . . . p s ∈ F s . Given K < p 1 < p 2 < · · · < p s−1 we can form at most 2 2k(s−1) sums A s−1 and B s−1 and thus produce at most 2 2k(s−1) distinct n = p 1 p 2 . . . p s−1 p s ∈ Ω M,K . By Lemma 8.1, p s ≥ max{2 sΦ(s) , K} and therefore the total number of elements inS ∩ [1, M ] induced by the elements in F s is at most The result now follows by letting K → ∞.
for some positive constant b ∈ R.
We now choose particular "thin" subset of S, to guarantee the desired limiting behaviour of { ν n (4)} n∈S . Proof. Fix large m ≥ 1 and small ε > 0. By Lemma 8.4, we can select prime p n = π nπn , p n = 1 (mod 4) and |arg(π n )| ≤ ε 100m . We further select prime p such that Consider the number of the form n = p m n p. It is easy to see that (8.4) | ν pn (4) − 1| ≤ 2m and N n > 2 m . Using an elementary inequality valid for |x j |, |y j | ≤ 1 and the fact that ν n (4) = ( ν pn (4)) m ν p (4), we can estimate We are left to show that equation (1.30) has only trivial solutions for appropriately chosen values of p n , p, which satisfy (8.3) and (8.4). Let π n = r n e iφ and p = π ·π with arg π = α. Clearly each integer point on the circle of radius √ n can be written as ξ j = √ ne i(jφ±α+r π 2 ) for some |j| ≤ m and r = {0, 1, 2, 3}. For such defined n, upon taking real parts, equaton (1.30) can be rewritten in the form 2k j=1 ε j cos l j φ ± α + πr j 2 = 0, (8.5) where ε j = {+1, −1} and |l j | ≤ m for 1 ≤ j ≤ 2k. By collecting terms with equal phases l j φ and using elementary trigonometric identities, we can rewrite (8.5) in the form there are only finitely many choices for the coefficients α j , α j , β j , β (1) j and therefore we can select angle α for which the corresponding prime p satisfies (8.3) and such that a sin α + b cos(α) = 0 for all a, b ∈ Z with |a| + |b| = 0 and |a|, |b| ≤ 2k. Now since each F r (φ) is a trigonometric polynomial of a total degree at most 4k, each non degenerate equation (8.6) has at most 4k solutions. Since there are only finitely many of such equations, we can select p n sufficiently large which satisfies (8.4)  Remark 8.6. It is possible to give a construction of n in Proposition 8.5 which is square-free. The idea is to use Lemma 8.4 and choose inductively sequence of primes p 1 < p 2 < · · · < p m such that p j = π jπj and |arg(π j )| ≤ 1 m 2 with the property that for any 1 ≤ r ≤ m we have cos(r · arg(π m )) / ∈ span N {cos( i≤m−1 a i arg(π i ))} where −m ≤ a i ≤ m, a i ∈ N. The latter can be ensured by taking sufficiently sparse sequence of primes p 1 , p 2 . . . . Now select n = p · p 1 . . . p m with |μ p (4) − s| ≤ δ and δ sufficiently small. We leave the details to the interested reader. APPENDIX A. PROOF OF LEMMA 2.2: EVALUATING Ω n (·), THE NORMALISED CONDITIONAL

COVARIANCE MATRIX
The ultimate goal of this section is evaluating the 2 × 2 (normalised) covariance matrix Ω n (·) in (2.9) of ∇f n (x), conditioned upon f n (x) = 0. First, we will need to evaluate ( §A.1) the (unconditional) 3 × 3 covariance matrix Σ n (x) of (f n (x), ∇f n (x), and then apply ( §A.2) the well-known procedure for conditioning in the Gaussian case.
A.1. Evaluating the unconditional covariance matrix.

A.2. Proof of Lemma 2.2.
Proof. Let Θ n (x) be the conditional covariance matrix of the Gaussian vector (∇f n (x)|f n (x) = 0), related to Ω n (x) via the normalisation (A.4) Ω n (x) = 2 nπ 2 Θ n (x). Once the (unconditional) covariance matrix Σ n of (f n (x), ∇f n (x)) is, following Lemma A.1, known, the conditional covariance matrix Θ n (x) is given by the standard Gaussian transition formula: B t n (x)B n (x).