What is the probability that a random integral quadratic form in $n$ variables has an integral zero?

We show that the density of quadratic forms in $n$ variables over $\mathbb Z_p$ that are isotropic is a rational function of $p$, where the rational function is independent of $p$, and we determine this rational function explicitly. When real quadratic forms in $n$ variables are distributed according to the Gaussian Orthogonal Ensemble (GOE) of random matrix theory, we determine explicitly the probability that a random such real quadratic form is isotropic (i.e., indefinite). As a consequence, for each $n$, we determine an exact expression for the probability that a random integral quadratic form in $n$ variables is isotropic (i.e., has a nontrivial zero over $\mathbb Z$), when these integral quadratic forms are chosen according to the GOE distribution. In particular, we find an exact expression for the probability that a random integral quaternary quadratic form has an integral zero; numerically, this probability is approximately $98.3\%$.


Introduction
An integral quadratic form Q in n variables is a homogeneous quadratic polynomial where all coefficients c ij lie in Z. The quadratic form Q is said to be isotropic if it represents 0, i.e., if there exists a nonzero n-tuple (k 1 , . . . , k n ) ∈ Z n such that Q(k 1 , . . . , k n ) = 0. We wish to consider the question: what is the probability that a random integral quadratic form in n variables is isotropic? In this paper, we give a complete answer to this question for all n, when integral quadratic forms in n variables are chosen according to the Gaussian Orthogonal Ensemble (GOE) of random matrix theory [1]. In particular, in the most interesting case n = 4, we show that the probability that a random integral quaternary quadratic form is isotropic is given by More precisely, let D be a piecewise smooth rapidly decaying function on the vector space R n(n+1)/2 of real quadratic forms in n variables (i.e., D(x) and all its partial derivatives are o(|x| −N ) for all N > 0), and assume that Q D(Q)dQ = 1; we call such a function D a nice distribution on the space of real n-ary quadratic forms. Then we define the probability, with respect to the distribution D, that a random integral n-ary quadratic form Q has a property P by lim X→∞ Q integral, with property P D(Q/X) if the limit exists. Let ρ D n denote the probability with respect to the distribution D that a random integral quadratic form in n variables is isotropic. If D = GOE is the distribution on the space of n × n symmetric matrices given by 1 where each entry of the matrix A is an identical and independently distributed Gaussian-i.e., the Gaussian Orthogonal Ensemble-then we use ρ n := ρ GOE n to denote the probability, with respect to the GOE distribution, that a random n-ary quadratic form over Z is isotropic.
We wish to explicitly determine the probability ρ n that a random n-ary quadratic form over Z, with respect to the GOE distribution, is isotropic, i.e., has a nontrivial zero over Z. To accomplish this, we first recall the Hasse-Minkowski Theorem, which states that a quadratic form over Z is isotropic if and only if it is isotropic over Z p for all p and over R. For any distribution D as above, let ρ D n (p) denote the probability that a random integral quadratic form, with respect to the distribution D, is isotropic over Z p , and let ρ D n (∞) denote the probability that it is isotropic over R (i.e., is indefinite). Then it is not hard to show (for the details, see Section 2) that ρ n (p) = ρ D n (p) is independent of D, and is simply given by the probability that a random n-ary quadratic form over Z p , with respect to the usual additive measure on Z n(n+1)/2 p , is isotropic over Z p . Moreover, we will also show in Section 2 that the probability ρ D n (∞) that a random integral quadratic form is isotropic over R is equal to the probability that a random real quadratic form (with respect to the same distribution D) is indefinite.
For any distribution D as above, it can be deduced from the work of Poonen and Voloch [6], together with the Hasse-Minkowski Theorem, that:

Theorem 1
The probability ρ D n that a random (with respect to the distribution D) integral quadratic form in n variables is isotropic is given by the product of the local probabilities: See Section 2 for details. Hence, to determine ρ D n , it suffices to determine ρ D n (∞) and ρ n (p) for all p. We treat first the probability ρ n (p) that a random n-ary quadratic form over Z p is isotropic. Our main result here is that, for each n, the quantity ρ n (p) is given by a fixed rational function in p that is independent of p (this even includes the case p = 2), and we determine these rational functions explicitly. Specifically, we prove the following theorem: Theorem 2 Let ρ n (p) denote the probability that a quadratic form in n variables over Z p is isotropic. Then and ρ n (p) = 1 for all n ≥ 5.
Our method of proof for Theorem 2 is uniform in n, and relies on establishing certain recursive formulae for densities of local solubility for certain subsets of n-ary quadratic forms defined by their behavior modulo powers of p. In particular, we obtain a new recursive proof of the well-known fact that every n-ary quadratic form over Q p is isotropic when n ≥ 5. See Section 3 for details. We turn next to the probability ρ n (∞) = ρ GOE n (∞) that a real n-ary quadratic form is isotropic. Closed form expressions for ρ n (∞) for n ≤ 3 were first given by Beltran in [4, (7)], while in [2] it was argued that 1 − ρ n (∞) decays like e −n 2 (log 3)/4 as n → ∞.
In Section 4, we show how to obtain an exact formula for ρ n (∞) for any given n. More precisely, using the de Bruijn identity [3] for calculating certain determinantal integrals, we express ρ n (∞) as the Pfaffian of an explicit n ′ × n ′ matrix, where n ′ := 2⌈n/2⌉, whose entries are given in terms of values of the gamma and incomplete beta functions at integers and half-integers. Indeed, let Γ denote the usual gamma function Γ(s) = ∞ 0 x s−1 e −x dx, and β t the usual incomplete beta function Then we have the following theorem giving expressions for ρ n (∞): Theorem 3 Let n ≥ 1 be any integer, and define n ′ := 2⌈n/2⌉. When real n-ary quadratic forms are chosen according to the n-dimensional Gaussian Orthogonal Ensemble, the probability of isotropy over R is given by where A is the n ′ × n ′ skew-symmetric matrix whose (i, j)-entry a ij is given for i < j by (Note that the second case in (6) arises only when n is odd.) Theorem 3 allows one to calculate ρ n (∞) exactly in closed form for any given n. In particular, it follows from the Pfaffian representation in Theorem 3 that ρ n (∞) is a polynomial in π −1 of degree at most ⌊ n+1 4 ⌋ with coefficients in Q( √ 2) (see Remark 9). In Table 1, we give the resulting formulae for ρ n (∞) for all n ≤ 8, and also provide numerical approximations. (For any n > 8, we have ρ n (∞) ≈ 1 to more than 10 decimal places!) Combining Theorems 1, 2, and 3, we finally obtain the following theorem giving the probability ρ n that a random integral quadratic form in n variables has an integral zero: Theorem 4 Let D be any nice (i.e., piecewise smooth and rapidly decaying) distribution. Then the probability ρ D n that a random integral quadratic form in n variables with respect to the distribution D is isotropic is given by If D = GOE is the GOE distribution, then the quantities ρ n (∞) = ρ D n (∞) are as given in Theorem 3. n ρ n (∞) = ρ n (∞) ≈  Table 1: Probability ρ n (∞) that a random n-ary quadratic form over R from the GOE distribution is isotropic, for n ≤ 8.
In particular, when D = GOE, we have ρ n = 0 for n = 1, 2, and 3, while for n = 4 we obtain the expression (2) for ρ 4 . For n ≥ 5, we have ρ n = ρ n (∞), and so the values of ρ n are as given by Theorem 3. Theorem 4 shows that n = 4 is in a sense the most interesting case, as all places play a nontrivial role in the final answer. It is also interesting to compare how the probabilities change if instead of the GOE we use the uniform distribution U on quadratic forms, where each coefficient of the quadratic form is chosen uniformly in the interval [−1/2, 1/2]. While the quantities ρ U n (∞) can easily be expressed as explicit definite integrals, it seems unlikely that they can be evaluated in compact and closed form for general n in this case. Using numerical integration, or a Monte Carlo approximation, we can compute ρ U n (∞) ≈ 0, 0.627, 0.901, 0.982, 0.998, and > 0.999 for n = 1, 2, 3, 4, 5, and 6, respectively. It is known (see, e.g., [1,Theorem. 2.3.5]) that 1 − ρ U n (∞) decays faster than e −cn for some constant c > 0; the actual rate of decay is likely even faster.
In particular, we have ρ U 4 = ρ U 4 (∞) p ρ 4 (p) ≈ 97.0%, which is slightly smaller than the GOE probability ρ GOE 4 ≈ 98.3%. We summarize the values of ρ D n , and provide numerical values in the cases of the uniform and GOE distributions, in Table 2.
This paper is organized as follows. In Section 2, we prove the product formula in Theorem 1. The theorem is known in the case of the uniform distribution U (or indeed any uniform distribution supported on a box) for any n ≥ 4 by the work of Poonen and Voloch [6], which in turn depends on the Ekedahl sieve [5]. To complete the proof of Theorem 1, we first prove directly that both sides of (4) are equal to 0 for n ≤ 3. For n ≥ 4, we prove that (4) is true for a general nice distribution D by approximating D by a finite weighted average of uniform box distributions, where the result is already known. The condition that D is rapidly decreasing (as in the case of D = GOE) plays a key role in the proof; indeed, we show how counterexamples to (4) can be constructed when this condition does not hold.
In Section 3, we then prove Theorem 2, i.e., we determine for each n the exact p-adic density of n-ary quadratic forms over Z p that are isotropic. The outline of the proof is as follows. First, we note that a quadratic form in n variables defined over Z p can be anisotropic only if its reduction modulo p Table 2: Probability that a random integral quadratic form in n variables is isotropic, for a general distribution D, for the uniform distribution, and for the GOE distribution.
has either two conjugate linear factors over F p 2 or a repeated linear factor over F p . We first compute the probability of each of these cases occurring, which is elementary. We then determine the probabilities of isotropy in each of these two cases by developing certain recursive formulae for these probabilities, in terms of other suitable quantities, which allow us to solve and obtain exact algebraic expressions for these probabilities for each value of n. We note that our general argument shows in particular that quadratic forms in n ≥ 5 variables over Q p are always isotropic, thus yielding a new recursive proof of this well-known fact. Finally, we prove Theorem 3 in Section 4, i.e., we determine for each n the probability that a random real n-ary quadratic form from the GOE distribution is indefinite. We accomplish this by first expressing, as a certain determinantal integral, the probability that an n × n symmetric matrix from the GOE distribution has all positive eigenvalues. We then show how this determinantal integral can be evaluated using the de Bruijn identity [3], allowing us to obtain an expression for the probability of positive definiteness in terms of the Pfaffian of an explicit skew-symmetric matrix A, as given in Theorem 3. We note that the values of these probabilities were known previously for n ≤ 3 (cf. [4, (7)]).
We end this introduction by remarking that the analogues of Theorems 2 and 4 also hold over a general local or global field, respectively. Here, we define global densities of quadrics as in [6, §4]; more general densities with respect to "nice distributions" could also be defined in an analogous manner. Indeed, the analogue of Theorem 1 holds (with the identical proof), where the product on the right hand side of (4) should be taken over all finite and infinite places of the number field (the densities at the complex places are all equal to 1, since all quadratic forms over C are isotropic). Theorem 2 also holds over any finite extension of Q p , with the same proof, provided that when making substitutions in the proofs we replace p by a uniformiser, and when computing probabilities we replace p by the order of the residue field.

The local product formula: Proof of Theorem 1
Let D be any nice (piecewise smooth and rapidly decaying) distribution. Our aim in this section is to prove the following three assertions from the introduction: (a) ρ D n (p) is equal to the probability ρ n (p) that a random n-ary quadratic form over Z p , with respect to the usual additive measure on Z is equal to the probability that a random n-ary quadratic form over R, with respect to the distribution D, is indefinite; and Items (a) and (b) are trivial in the case that D = U is the uniform distribution, or more generally and 0 outside this box; here a = (a 1 , . . . , a n(n+1)/2 ) and Meanwhile, Theorem 1 for n ≥ 4, in the case that D is the uniform distribution U, follows from the work of Poonen and Voloch [6, Theorem 3.6] (which establishes the product formula for the probability that an integral quadratic form with respect to the distribution D is locally soluble), together with the Hasse-Minkowski Theorem (which states that a quadratic form is isotropic if and only if it is locally soluble). In fact, the proof of [6, Theorem 3.6] (which in turn relies on the Ekedahl's sieve [5]) immediately adapts to the case where D = U( a, b) without essential change.
To show that Theorem 1 holds also when D = U( a, b) and n ≤ 3, it suffices to prove that in this case both sides of (4) are equal to 0. To see this, we may use Theorem 2, which does not rely on the results of this section, and which states that the probability that a random n-ary quadratic form over Z p is isotropic is equal to ρ n (p) = 0, 1/2, or 1 − p/(2(p + 1) 2 ) for n = 1, 2, or 3, respectively. This immediately implies that the right hand side of (4) is zero. To see that the left hand side of (4) is zero, we note that if a quadratic form over Z is isotropic, then it must be isotropic over Z p for all p (the easy direction of the Hasse-Minkowski Theorem). By the Chinese Remainder Theorem, the (limsup of the) probability ρ D n that a random integral n-ary quadratic form is isotropic with respect to the distribution D = U( a, b) is at most p<Y ρ n (p) for any Y > 0. Letting Y now tend to infinity shows that ρ D n = 0 for n = 1, 2, or 3, i.e., the left hand side of (4) is also zero.
Thus we have established items (a)-(c), for all n, in the case that D = U( a, b) is a constant distribution supported on a box [ a, b]. Clearly (a)-(c) then must hold also for any finite weighted average of such box distributions U(·, ·).
To show that (a)-(c) hold for general nice distributions D, we make use of the following elementary lemma regarding integration of rapidly decaying functions.
Lemma 5 Let f be any piecewise smooth rapidly decaying function on R m . Then Proof: For any N > 0, let f N (y) be equal to f (y) if |y| ≤ N, and 0 otherwise. Then f N is piecewise smooth with bounded support, and so is Riemann integrable. Thus we have Since f is rapidly decreasing, for any ε > 0 we may choose N large enough so that |y|>N |f (y)|dy < ε and (1/X m ) y∈Z m , |y/X|>N |f (y/X)| < ε for any X ≥ 1. For this value of N, the left hand side of (8) is within ε of the left hand side of (7), while for each X ≥ 1, the expression in the limit on the right hand side of (8) is within ε of the expression in the limit on the right hand side of (7). Since we have equality in (8), we conclude that the left hand side of (7) is within 2ε of both the lim inf X→∞ and the lim sup X→∞ of the expression in the limit of the right hand side of (7). Since ε is arbitrarily small, we have proven (7).
Note that Lemma 5 does not necessarily hold if we drop the condition that f is rapidly decaying. For example, if f the characteristic of a finite-volume region having a cusp going off to infinity containing a rational line through the origin (and thus infinitely many lattice points on that line), then the left hand side of (7) is finite while the expression in the limit on the right hand side of (7) is infinite for any rational value of X.
Lemma 5 implies in particular that for any nice distribution D. Now any piecewise smooth rapidly decaying function can be approximated arbitrarily well by a finite linear combination of characteristic functions of boxes. Let D be a nice distribution. For any ε > 0, we may find a nice distribution D ε that is a finite weighted average of box distributions U(·, ·), such that |D(y) − D ε (y)|dy < ε.
3 The density of n-ary quadratic forms over Z p that are isotropic: Proof of Theorem 2

Preliminaries on n-ary quadratic forms over Z p
Fix a prime p. For any free Z p -module V of finite rank, there is a unique additive p-adic Haar measure µ V on V which we always normalize so that µ V (V ) = 1. All densities/probabilities are computed with respect to this measure. In this section, we take V = V n to be the n(n + 1)/2-dimensional Z p -module of n-ary quadratic forms over Z p . We then work out the density ρ n (p) (i.e. measure with respect to µ V ) of the set of n-ary quadratic forms over Z p that are isotropic. We start by observing that a primitive n-ary quadratic form over Z p can be anisotropic only if, either: (I) the reduction modulo p factors into two conjugate linear factors defined over a quadratic extension of F p , or (II) the reduction modulo p is a constant times the square of a linear form over F p . Let ξ (n) 1 and ξ (n) 2 be the probabilities of Cases I and II, i.e. the densities of these two types of quadratic forms in V n . Then ξ is the probability that a form is primitive, but not in Cases I or II. Let α (n) 1 (resp. α (n) 2 ) be the probability of isotropy for quadratic forms in Case I (resp. Case II). Then

Some counting over finite fields
Let η (n) 1 (resp. η (n) 2 ) be the probability that a quadratic form is in Case I (resp. Case II) given the "point condition" that the coefficient of x 2 1 is a unit. Similarly, let ν (n) 1 be the probability that a quadratic form is in Case I given the "line condition" that the binary quadratic form Q(x 1 , x 2 , 0, . . . , 0) is irreducible modulo p. Note that it is impossible to be in Case II given the line condition, but we may also define ν j , are given by the following easy lemma.

Lemma 6
The probabilities that a random quadratic form over Z p is in Case I or Case II are as follows.
• Case I (all; relative to point condition; relative to line condition) Proof: Case I: There are (p 2n − 1)/(p 2 − 1) linear forms over F p 2 up to scaling; subtracting the (p n − 1)/(p − 1) which are defined over F p , dividing by 2 to account for conjugate pairs and then multiplying by p − 1 for scaling gives (p n −1)(p n −p)

2(p+1)
Case I forms, and hence the value of ξ Case II is similar and easier: the number of Case II quadratic forms is p n −1, of which p n −p n−1 satisfy the point condition and none satisfy the line condition; the given formulae follow.

Recursive formulae
We now outline our strategy for computing the densities ρ n (p) using (21), by evaluating α (n) j for j = 1, 2. If a quadratic form is in Case I, then we may make a (density-preserving) change of variables, transforming it so that its reduction is an irreducible binary form in only two variables. Now isotropy forces the values of those variables, in any primitive vector giving a zero, to be multiples of p; so we may scale those variables by p and divide the form by p. Similarly, if a form is in Case II, then we transform it so that its reduction is the square of a single variable, scale that variable and divide out. After carrying out this process once, we again divide into cases and repeat the procedure, which leads us back to an earlier situation but with either the line or point conditions, which we need to allow for.
To make this precise, we introduce some extra notation for the probability of isotropy for quadratic forms which are in Case I or Case II after the initial transformation: let β (n) 1 (resp. β (n) 2 ) be the probability of isotropy given we are in Case I (resp. Case II) after one step when the original quadratic form was in Case I, and similarly γ (n) 1 (resp. γ (n) 2 ) the probability of isotropy given we are in Case I (resp. Case II) after one step when the original quadratic form was in Case II.

Proof: We have α
(2) 1 = 0 since a binary quadratic form that is irreducible over F p is anisotropic. Now assume that n ≥ 3, and (for Case I) Q(x 1 , . . . , x n ) (mod p) has two conjugate linear factors. Without loss of generality, the reduction modulo p is a binary quadratic form in x 1 and x 2 . Now any primitive vector giving a zero of Q must have its first two coordinates divisible by p, so replace Q(x 1 , . . . , x n ) by 1 p Q(px 1 , px 2 , x 3 , . . . , x n ). The reduction modulo p is now a quadratic form in x 3 , . . . , x n . If the new Q is identically zero modulo p, then, after dividing it by p, we obtain a new integral form that lands in Cases I and II with probabilities ν (n) 1 and ν (n) 2 , respectively, since it satisfies the line condition; otherwise, we divide into cases as before, with the probabilities of being in each case given by ξ The result for α (n) 2 is proved similarly: without loss of generality the reduction modulo p is a quadratic form in x 1 only, we replace Q(x 1 , . . . , x n ) by 1 p Q(px 1 , x 2 , . . . , x n ), whose reduction modulo p is a quadratic form in x 2 , . . . , x n . If the new Q is identically zero modulo p, then, after dividing by p, we have an integral form that lands in Cases I and II with probabilities η Proof: In Case I, the initial transformation leads to a quadratic form for which the valuations of the coefficients satisfy 1 and β (n) 1 (resp. β (n) 2 ) are the probabilities of isotropy given that the reduction modulo p of the form in x 3 , x 4 , . . . , x n is in Case I (resp. Case II).
Similarly, in Case II the initial transformation leads to and γ 2 ) are the probabilities of isotropy given that the reduction modulo p of the form in x 2 , x 3 , . . . , x n is in Case I (resp. Case II).
(i) To evaluate β (n) 1 we may assume, after a second linear change of variables, that we have and that the reductions modulo p of both 1 p Q(x 1 , x 2 , 0, . . . , 0) and Q(0, 0, x 3 , x 4 , 0, . . . , 0) are irreducible binary quadratic forms. Any zero of Q must satisfy x 3 ≡ x 4 ≡ 0 (mod p). This gives a contradiction when n = 4, so that Q(x 1 , . . . , x 4 ) is anisotropic, and β (ii) To evaluate β (n) 2 , we may assume that the valuations of the coefficients satisfy and that the reduction modulo p of 1 p Q(x 1 , x 2 , 0, . . . , 0) is an irreducible binary quadratic form. If n = 3 then Q is anisotropic, and β (iii) For γ (n) 1 , we may assume that the valuations of the coefficients satisfy and the reduction of Q(0, x 2 , x 3 , 0, . . . , 0) modulo p is irreducible. Any zero of Q now satisfies x 2 ≡ x 3 ≡ 0 (mod p). When n = 3 this gives a contradiction, so Q(x 1 , x 2 , x 3 ) is anisotropic, and γ . , x n ) brings us back to the situation in (22) but with the point condition, so that Cases I and II occur with probabilities η (iv) Lastly, for γ (n) 1 , we may assume that the valuations of the coefficients satisfy If n = 2 then Q(x 1 , x 2 ) is anisotropic , and γ
Note that our proof of Theorem 2 also yields a (recursive) algorithm to determine whether a quadratic form over Q p is isotropic. Tracing through the algorithm, we see that, for a quadratic form of nonzero discriminant, only finitely many recursive iterations are possible (since we may organize the algorithm so that at each such iteration the discriminant valuation is reduced), i.e., the algorithm always terminates. In particular, when n ≥ 5, our algorithm always yields a zero for any n-ary quadratic form of nonzero discriminant; hence every nondegenerate quadratic form in n ≥ 5 variables is isotropic.
4 The density of n-ary quadratic forms over R that are indefinite: Proof of Theorem 3

Preliminaries on the Gaussian Orthogonal Ensemble (GOE)
We wish to calculate the probability ρ n (∞) that a real symmetric matrix M from the n-dimensional GOE has an indefinite spectrum. The distribution of matrix entries in the GOE is invariant under orthogonal transformations. Since real symmetric matrices can be diagonalised by an orthogonal transformation, the GOE measure can be written directly in terms of the eigenvalues λ(M), yielding the distribution here where (ϕ i (λ j )) = (λ i−1 j ) is a Vandermonde matrix, and the normalizing factor Z .
Note that the probability that the matrix M is indefinite is related to the probability p + n that all its eigenvalues are positive by ρ n (∞) = 1 − P(positive definite) − P(negative definite) = 1 − 2p + n , where the second equality follows by symmetry. Below we will calculate p + n , and hence obtain the value of ρ n (∞).

de Bruijn's identity
We recall a useful result from [3, §4] for calculating determinantal integrals of the type we will need. As a generalisation of an expression for the volume of the space of symmetric unitary matrices, de Bruijn considered integrals of the form: Ω = · · · a≤x 1 ≤···≤xn≤b det 1≤i,j≤n (ϕ i (x j ))dx 1 . . . dx n .
The integral (27) may be rewritten as the Pfaffian of either an n × n skew-symmetric matrix if n is even, or an (n + 1) × (n + 1) skew-symmetric matrix if n is odd. More precisely, let n ′ := 2⌈n/2⌉; then we have Ω = Pf(A), where A is the n ′ × n ′ skew-symmetric matrix whose (i, j)-entry a ij is given for i < j by a sign(y − x)ϕ i (x)ϕ j (y)dxdy if i < j ≤ n; b a ϕ j (x)dx if i < j = n + 1.
The second case occurs only when n is odd. Note that this holds for a general measure dx; below, we will use dx = e −λ 2 /4 dλ, where dλ is the Lebesgue measure on R.
The Pfaffian form of the integral is found by expanding the determinant and using a signature function to keep track of the signs and the ordering of the x i . This signature function of n variables can be broken up into a sum of products of two-variable pieces (and a one-variable piece if n is odd) and thus the integral can be factorised into a sum of products of two (and one) dimensional integrals which is recognised as of the form (28) for a matrix with entries (29).

Calculation of ρ
The ordering in the domain of integration below means that we can replace |∆(λ)| by ∆(λ). It then follows that p + n is given by the integral where the last equality follows from the result of §4.2. Here, A = (a ij ), where for i < j ≤ n we define