# Mean value of the class number in function fields revisited

• Hwanyup Jung
Open Access
Article

## Abstract

In this paper an asymptotic formula for the sum $$\sum L(1,\chi )$$ is established for the family of quadratic Dirichlet L-functions over the rational function field over a finite field $$\mathbb {F}_{q}$$ with q fixed. Using the recent techniques developed by Florea we obtain an extra lower order terms that was never been predicted in number fields and function fields. As a corollary, we obtain a formula for the average of the class number over function fields which also contains strenuous lower order terms and so improving on previous results of Hoffstein and Rosen.

## Keywords

Class number Function fields Quadratic Dirichlet L-functions

## Mathematics Subject Classification

11G20 11R29 14G10

## 1 Introduction

### 1.1 The number field case

In his famous Disquisitiones Arithmeticae [8], Gauss presented two conjectures concerning the average values of class numbers associated with binary quadratic forms over the integers. For completeness and to put our problem in the right context we will restate Gauss’s conjectures in the language of orders in quadratic number fields.

Let D denote an integer congruent to 0 or 1 modulo 4 and suppose that D is not a square. In this case, D can be uniquely written as $$D=D_{0}m^{2}$$ where $$D_{0},m\in \mathbb {Z}$$ and either $$D_{0}\equiv 1\bmod 4$$ or $$D_{0}=4m_{0}$$ with $$m_{0}$$ square-free and $$m_{0}\equiv 2,3\bmod 4$$. D is called a fundamental discriminant if $$m=1$$.

Consider the quadratic number field $$\mathbb {Q}(\sqrt{D})$$. The maximal order in $$\mathbb {Q}(\sqrt{D})$$ has discriminant $$D_{0}$$, and it is well known that there is a unique order $$\mathcal {O}_{D}\subset \mathcal {O}_{D_{0}}$$, called the maximal order, such that $$[\mathcal {O}_{D_{0}}:\mathcal {O}_{D}]=m$$. We denote by $$h_{D}$$ the strict class number of $$\mathcal {O}_{D}$$, and, when $$D>0$$, we denote by $$\varepsilon _{D}$$ to be the smallest unit in $$\mathcal {O}_{D}$$ such that $$\varepsilon _{D}>1$$ and $$N_{\mathbb {Q}(\sqrt{D})/\mathbb {Q}}(\varepsilon _{D})=1$$. Finally, we denote by $$R_{D}=\log (\varepsilon _{D})$$ to be the regulator of the quadratic number field $$\mathbb {Q}(\sqrt{D})$$.

In [8], Gauss considered only binary quadratic forms $$ax^{2}+2bxy+cy^{2}$$ with $$a,b,c\in \mathbb {Z}$$, in other words, he only considered even discriminants $$D=4(b^{2}-ac)$$. Recall that two quadratic forms are equivalent if it is possible to transform the first form into the second through an invertible integral linear change of variables. By defining this equivalence relation on the set of quadratic forms we have equivalence classes that will be called classes of quadratic forms. Gauss showed that the number of such equivalence classes of quadratic forms with discriminant D is finite. Let $$h_{D}$$ denote this number, we also call $$h_{D}$$ the class number.

We now will present Gauss’s conjectures reformulated in a more modern language.

### Conjecture 1.1

(Gauss) Let $$h_{D}$$ be the class number defined as above.
1. (1)
Let $$D=-4k$$ run over all negative discriminants with $$k\le N$$. Then
\begin{aligned} \sum _{1\le -D\le N}h_{D}\sim \frac{4\pi }{21\zeta (3)}N^{\frac{3}{2}}, \end{aligned}
(1.1)
as $$N\rightarrow \infty$$ and where $$\zeta (s)$$ is the Riemann zeta function.

2. (2)
Let $$D=4k$$ run over all positive discriminants such that $$k\le N$$. Then
\begin{aligned} \sum _{1\le D\le N}h_{D}R_{D}\sim \frac{4\pi ^{2}}{21\zeta (3)}N^{\frac{3}{2}}. \end{aligned}
(1.2)

The first conjecture (1.1) was first proved by Lipschitz [15] and better error terms were obtained by Mertens [17], Siegel [21] and Vinogradov [25]. The second conjecture (1.2) was first proved by Siegel [21]. Siegel was also able to average $$h_{D}$$ and $$h_{D}R_{D}$$ over all discriminants.

### Theorem 1.2

(Siegel) With the same notation as before, we have that
1. (1)
\begin{aligned} \sum _{1<-D\le N}h_{D}=\frac{\pi }{18\zeta (3)}N^{\frac{3}{2}}+O(N\log N). \end{aligned}
(1.3)

2. (2)
\begin{aligned} \sum _{1<D\le N}h_{D}R_{D}=\frac{\pi ^{2}}{18\zeta (3)}N^{\frac{3}{2}}+O(N\log N). \end{aligned}
(1.4)

In [20], Shintani proved a sharper version of part (2) of the above theorem.

Let $$\psi _{D}(n)=(\frac{D}{n})$$ denote the Kronecker symbol. We can associate to this symbol the following Dirichlet series
\begin{aligned} L(s,\psi _{D})=\sum _{n=1}^{\infty }\frac{\psi _{D}(n)}{n^{s}}. \end{aligned}
A well-known result of Dirichlet, known as Dirichlet’s class number formula, states that
\begin{aligned} L(1,\psi _{D}) = {\left\{ \begin{array}{ll} \frac{2\pi h_{D}}{w_{D}\sqrt{|D|}} &{}\quad \text { if }D<0, \\ \frac{h_{D}R_{D}}{\sqrt{D}} &{}\quad \text { if }D>0, \end{array}\right. } \end{aligned}
(1.5)
where $$w_{D}$$ denotes the number of roots of unity in $$\mathcal {O}_{D}$$. In fact, $$w_{D}=2$$ except when $$D=-4$$ or $$-6$$, when $$w_{D}=4$$ and 6 respectively. With this notation, we can summarize Siegel’s result in a single formula
\begin{aligned} \sum _{1<\pm D\le N}L(1,\psi _{D})=\frac{1}{2}\frac{\zeta (2)}{\zeta (3)}N+O(N^{\frac{1}{2}}\log N), \end{aligned}
(1.6)
where the sum is to be understood as a sum over all positive discriminants D between 1 and N, or all negative discriminants D such that $$1<|D|\le N$$. In fact, Theorem 1.2 follows from (1.5), (1.6) and partial summation.

A natural question that arises from Eq. (1.6), that was studied by Takhtadzjan and Vinogradov in [23], is about averaging $$L(s,\psi _{D})$$ at other points besides $$s=1$$.

It is important to note that all the mean values quoted above are averages over all discriminants. But we can also consider the problem of averaging over fundamental discriminants. In 1979, Goldfeld and Viola [10] put forward a few conjectures about averages over fundamental discriminants and Jutila [13] proved such conjecture in 1981 for $$s=\frac{1}{2}$$. Then, in 1985, Goldfeld and Hoffstein [9], using Eisentein series of $$\frac{1}{2}$$-integral weight, generalized Jutila’s result and proved a result valid for all s with $$\mathrm {Re}(s)\ge \frac{1}{2}$$. We will state some of these results but before, we need the following notation. Let m denote a square-free integer and let $$\chi _{m}(n)$$ be the quadratic Dirichlet character associated to the quadratic field $$\mathbb {Q}(\sqrt{m})$$. We will state Goldfeld and Hoffstein result for $$\mathrm {Re}(s)\ge 1$$ and refer the reader to their paper [9] for the full result.

### Theorem 1.3

(Goldfeld and Hoffstein) Let $$\varepsilon >0$$ be given. For $$\mathrm {Re}(s)\ge 1$$,
\begin{aligned} \sum _{1<\pm m\le N}L(s,\chi _{m})=c(s)N+O(N^{\frac{1}{2}+\varepsilon }), \end{aligned}
(1.7)
where
\begin{aligned} c(s)=\frac{3}{4}(1-2^{-2s})\zeta (2s)\prod _{p\ne 2}(1-p^{-2}-p^{-2s-1}+p^{-2s-2}). \end{aligned}

The sum is either over positive square-free m between 1 and N, or over negative square-free m with $$1<|m|\le N$$. If we set $$s=1$$ in the above theorem and using Dirichlet’s class number formula, one can average $$h_{m}$$, the class number, or $$h_{m}R_{m}$$, the class number times the regulator, over the fields $$\mathbb {Q}(\sqrt{m})$$.

We now state Jutila’s result and some of its developments. Jutila proved a first moment for quadratic Dirichlet L-functions at the centre of the critical strip.

### Theorem 1.4

(Jutila) As $$x\rightarrow \infty$$ we have that
\begin{aligned} \sum _{0<m\le x}L(\tfrac{1}{2},\chi _{m})\sim \frac{P(1)}{4\zeta (2)}x\log x, \end{aligned}
(1.8)
where
\begin{aligned} P(s)=\prod _{p}\left( 1-\frac{1}{(p+1)p^{s}}\right) . \end{aligned}
Goldfeld and Hoffstein [9] improved the error term in Jutila’s result and Young [26] showed that the error term is bounded by $$x^{\frac{1}{2}+\varepsilon }$$ if we consider a smooth version of this average value. In the same paper, Jutila also obtained a second moment for this family of L-function. Soundararajan [22] in a tour de force established an asymptotic formula for the third moment for this family of L-functions. It is conjectured that
\begin{aligned} \sum _{0<m\le x}L(\tfrac{1}{2},\chi _{m})^{k}\sim C_{k}x(\log x)^{k(k+1)/2}, \end{aligned}
(1.9)
where the sum is over all fundamental discriminants. Keating and Snaith [14] conjectured a precise value for $$C_{k}$$ using random matrix theory calculations. There is a more elaborated conjecture due to Conrey, Farmer, Keating, Rubinstein and Snaith [6] for the integral moments, and the formulas include all the principal lower order terms. The conjectures agrees with the computed first three moments.

Let $$m>0$$ and square-free and $$\mathbb {Q}(\sqrt{m})$$ be the associated quadratic fields. Then $$L(-1,\chi _{m})$$ is related to the order $$K_{2}(\mathcal {O}_{m})$$ by a conjecture of Birch and Tate, where $$K_{2}(\mathcal {O}_{m})$$ is the algebraic $$K_{2}$$ group defined as the center of the Steinberg group $$\text {St}(\mathcal {O})$$ or as the Schur multiplier of the group of elementary matrices. For more details see [16].

By using the functional equation we can relate $$L(-1,\chi _{m})$$ to $$L(2,\chi _{m})$$. And so setting $$s=2$$ in Theorem 1.3 allows us to average the size of the $$K_{2}(\mathcal {O}_{m})$$ groups, modulo the conjecture. In number fields, the conjecture is known up to powers of 2 due to a result of Mazur and Wiles [16]. In function fields, the analogue of this conjecture was proved by Tate [24]. We investigate the mean values of $$K_{2}$$ groups in function fields in a future work [2].

In 1982, Sarnak [19] investigated the asymptotic average behavior of $$h_{D}$$ over the exhausting family of sets, $$\mathcal {D}_{p,x}=\left\{ D\in \mathcal {D}_{p}:\varepsilon _{D}\le x\right\}$$ as $$x\rightarrow \infty$$. Here, $$\mathcal {D}_{p}=\{D\in \mathcal {D}:p\mid y_{D}\}$$ where $$\mathcal {D}$$ is the set of positive ring discriminants, that is, D is such that $$D>0$$ and $$D\equiv 0,1 \bmod 4$$ with D not a square. We have that $$p\ge 3$$ is a prime, or $$p=1$$ when $$\mathcal {D}_{1}=\mathcal {D}$$ and $$(x_{D},y_{D})$$ is the fundamental solution of the Pellian equation $$x^{2}-Dy^{2}=4$$. We also denote $$\varepsilon _{D}$$ to be
\begin{aligned} \varepsilon _{D}=\frac{x_{D}+y_{D}\sqrt{D}}{2}. \end{aligned}
With this notation, the main result in Sarnak’s paper [19] is given below.

### Theorem 1.5

(Sarnak) Let $$\gamma >\frac{2}{3}$$. Then
\begin{aligned} \frac{1}{|\mathcal {D}_{p,x}|}\sum _{D\in \mathcal {D}_{p,x}}h_{D}=\frac{16}{35}c_{p}\frac{\mathrm {Li}(x^{2})}{x}+O(x^{\gamma }), \end{aligned}
(1.10)
where
\begin{aligned} c_{p} = {\left\{ \begin{array}{ll} 1 &{} \text { if } p=1, \\ \frac{1+p^{2}}{p(p^{2}-1)} &{} \text { if } p\ge 3, \end{array}\right. } \end{aligned}
and $$\mathrm {Li}(u)=\int _{2}^{u}(1/\log t)dt$$ as in the ordinary prime number theorem and |A| denotes the cardinality of the set A.

In fact, Sarnak’s theorem shows that in this ordering the size of $$h_{D}$$ is about the size of $$h_{D}$$ over the sets $$\mathcal {D}_{p,x}$$. Sarnak, in the same paper, also obtains several other interesting results about $$h_{D}$$.

### Theorem 1.6

(Sarnak) With the same notation as before, we have that
1. (1)
\begin{aligned} \sum _{\left\{ D\in \mathcal {D}_{1}:\varepsilon _{D}\le x\right\} }h_{D}=\mathrm {Li}(x^{2})+O(x^{\frac{3}{2}}(\log x)^{2}), \end{aligned}
(1.11)

2. (2)
\begin{aligned} \sum _{\left\{ D\in \mathcal {D}_{1}:\varepsilon _{D}\le x\right\} }h_{D}\log \varepsilon _{D}=\frac{x^{2}}{2}+O(x^{\frac{3}{2}}(\log x)^{3}) \end{aligned}
(1.12)
as $$x\rightarrow \infty$$.

The main idea in Sarnak’s paper is to connect the quantities $$h_{D}$$ and $$\log \varepsilon _{D}$$ to lengths of closed geodesics on the Riemann surfaces $$H/\Gamma (p)$$, where H is the Lobachevskii plane with its non-Euclidian metric, and $$\Gamma (p)$$ is the principal congruence subgroup of $$PSL(2,\mathbb {Z})$$ of level p and then use the Selberg trace formula to investigate the asymptotic behavior of these lengths and so obtaining the desired results about the class number.

### 1.2 The function field case

We consider now the average values of the class number in the context of function fields over finite fields. Before we state the main result of this paper we will set up some of the function field notation that will be used in the rest of the paper.

Let $$\mathbb {F}_{q}$$ be a finite field with q elements. We assume that $$q\equiv 1 \bmod 4$$. We denote by $$\mathbb {A}=\mathbb {F}_{q}[t]$$ to be the ring of polynomials over $$\mathbb {F}_{q}$$. Let $$k=\mathbb {F}_{q}(t)$$ be the rational function field over $$\mathbb {F}_{q}$$. We also denote by $$\mathbb {A}^{+}$$ to be the set of monic polynomials in $$\mathbb {A}$$. The norm of a polynomial $$f\in \mathbb {A}$$ is defined to be $$|f|=q^{\deg (f)}$$ and the zeta function associated to $$\mathbb {A}$$ is defined to be
\begin{aligned} \zeta _{\mathbb {A}}(s)=\sum _{f\in \mathbb {A}^{+}}\frac{1}{|f|^{s}}=\frac{1}{1-q^{1-s}}. \end{aligned}
(1.13)
If we use the more convenient variable $$u=q^{-s}$$, we have that
\begin{aligned} \zeta _{\mathbb {A}}(s)=\mathcal {Z}_{\mathbb {A}}(u)=\frac{1}{1-qu}. \end{aligned}
(1.14)
Let K / k be a quadratic extension and $$\mathcal {O}_{K}$$ be the integral closure of $$\mathbb {A}$$ in K. The arithmetic of $$\mathcal {O}_{K}$$ was first considered by E. Artin [5]. It is well-known that $$\mathcal {O}_{K}=\mathbb {A}[\sqrt{m_{0}}]$$ where $$m_{0}$$ is a square-free polynomial in $$\mathbb {A}$$. We can relabel $$\mathcal {O}_{K}$$ as $$\mathcal {O}_{m_{0}}$$ and set $$h_{m_{0}}$$ equal to its class number. If $$m=m_{0}m_{1}^{2}$$ then $$h_{m}=|\mathrm {Pic}(\mathcal {O}_{m})|$$ where $$\mathrm {Pic}(\mathcal {O}_{m})$$ is the Picard group of $$\mathcal {O}_{m}$$.

Consider $$D\in \mathbb {A}$$ a square-free polynomial and put $$\mathcal {O}_{D}=\mathbb {A}[\sqrt{D}]$$. In this case, $$\mathcal {O}_{D}$$ is a Dedekind domain and the associated class number $$h_{D}$$ is equal to $$|\mathrm {Pic}(\mathcal {O}_{D})|$$. For more details see [18, p. 315]. The main aim of this paper is to investigate the average value of these numbers.

Let $$D\in \mathbb {A}$$ be a monic and square-free polynomial. We can define the quadratic character $$\chi _{D}$$ using the quadratic residue symbol for $$\mathbb {A}$$ by
\begin{aligned} \chi _{D}(f)=\left( \frac{D}{f}\right) , \end{aligned}
(1.15)
and the associated L-function by
\begin{aligned} L(s,\chi _{D})=\sum _{f\in \mathbb {A}^{+}}\frac{\chi _{D}(f)}{|f|^{s}}. \end{aligned}
(1.16)
Using [18, Proposition 4.3] we have that $$L(s,\chi _{D})$$ is a polynomial in $$u=q^{-s}$$ of degree at most $$\deg (D)-1$$. For more details about quadratic Dirichlet L-functions in function fields see [3].

We also will fix the following notation. $$\mathbb {A}_{n}^{+}$$ will denote the set of monic polynomials of degree n in $$\mathbb {A}$$. Let $$\mathbb {A}_{\le n}^{+} = \{f \in \mathbb {A}^{+}: \deg (f) \le n\}$$ and $$\mathbb {A}_{\ge n}^{+} = \{f \in \mathbb {A}^{+}: \deg (f) \ge n\}$$. For square-free polynomials we have that $$\mathcal H = \{f \in \mathbb {A}^{+}: \text {f is square-free}\}$$ and $$\mathcal H_{n} = \{f \in \mathcal H: \deg (f) = n\} = \mathcal H \cap \mathbb {A}^{+}_{n}$$. To make the notation clearer we will denote by $$d(f) = \deg (f)$$, the degree of f for any $$f \in \mathbb {A}$$.

Hoffstein and Rosen in their beautifil paper [11] proved a series of results about average values of class numbers in function fields. For example, for the average values over all discriminants they have the following results.

### Theorem 1.7

(Hoffstein and Rosen) Let m be odd and positive. Then
\begin{aligned} \frac{1}{q^{m}}\sum _{D\in \mathbb {A}_{m}^{+}}h_{D} = \frac{\zeta _{\mathbb {A}}(2)}{\zeta _{\mathbb {A}}(3)}q^{\frac{m-1}{2}}-q^{-1}. \end{aligned}
(1.17)

### Theorem 1.8

(Hoffstein and Rosen) Let m be even and positive. The following sum is over all non-square monic polynomials of degree m. Then we have that
\begin{aligned} \frac{1}{q^{m}}\sum h_{D}R_{D}=(q-1)^{-1}\left\{ \frac{\zeta _{\mathbb {A}}(2)}{\zeta _{\mathbb {A}}(3)}q^{\frac{m}{2}}-\left( 2+\left( 1-\frac{1}{q}\right) (m-1)\right) \right\} . \end{aligned}
(1.18)

A problem which is more difficult is to average the class number over fundamental discriminants, i.e., over $$D\in \mathbb {A}$$ with D square-free. With the help of functions defined on the metaplectic two-fold cover of $$GL(2,k_{\infty })$$, where $$k_{\infty }$$ is the completion of k at the prime at infinity, Hoffstein and Rosen [11] were able to establish the following theorem that can be used to prove asymptotic formulas for the average of the class number over square-free polynomials.

### Theorem 1.9

Let $$\varepsilon >0$$ be given and assume $$s\in \mathbb {C}$$ with $$\mathrm {Re}(s)\ge 1$$.
1. (1)
If $$M=2n+1$$ is odd, then
\begin{aligned} (q-1)^{-1}(q^{M}-q^{M-1})^{-1}\sum _{m}L(s,\chi _{m})=\zeta _{\mathbb {A}}(2)\zeta _{\mathbb {A}}(2s)c(s)+O(q^{-n(1-\varepsilon )}), \end{aligned}
(1.19)
where the sum is over all square-free $$m\in \mathbb {A}$$ such that $$\deg (m)=M$$ and
\begin{aligned} c(s)=\prod _{P}(1-|P|^{-2}-|P|^{-(2s+1)}+|P|^{-(2s+2)}) \end{aligned}
is a product over monic and irreducible polynomials.

2. (2)
If $$M=2n$$ is even, then
\begin{aligned} 2^{-1}(q-1)^{-1}(q^{M}-q^{M-1})^{-1}\sum _{m}L(s,\chi _{m})=\zeta _{\mathbb {A}}(2)\zeta _{\mathbb {A}}(2s)c(s)+O(q^{-n(1-\varepsilon )}), \end{aligned}
(1.20)
where the sum is over all square-free $$m\in \mathbb {A}$$ such that $$\deg (m)=M$$ and the leading coefficient of m is 1, or over all square-free m with $$\deg (f)=M$$ and the leading coefficient of m is $$-1$$.

In a recent paper, Andrade [1] by using the approximate functional equation in function fields and the Riemann hypothesis for curves over finite fields to estimate non-trivial character sums in function fields was able to establish the average value for the class number in function fields when the average is taken over fundamental discriminants.

### Theorem 1.10

(Andrade) Let $$\mathbb {F}_{q}$$ be a fixed finite field with $$q\equiv 1 \bmod 4$$. Then
\begin{aligned} \sum _{D\in \mathcal {H}_{2g+1}}h_{D}=\frac{|D|^{\tfrac{3}{2}}}{\sqrt{q}}P(2)+O(|D|), \end{aligned}
(1.21)
as $$\deg (D)\rightarrow \infty$$ and
\begin{aligned} P(s)=\prod _{\begin{array}{c} P \ \mathrm {monic} \\ \mathrm {irreducible} \end{array}}\left( 1-\frac{1}{(|P|+1)|P|^{s}}\right) . \end{aligned}

By using the same techniques as those developed by Andrade [1], Jung [12] was able to establish the average value of the class number times the regulator in the same context as in the previous result.

### Theorem 1.11

(Jung) With the same notation as before, we have that
\begin{aligned} \sum _{D\in \mathcal {H}_{2g+2}}h_{D}R_{D}=\frac{|D|^{\tfrac{3}{2}}}{q-1}P(2)+O(g^{2}|D|), \end{aligned}
(1.22)
as $$\deg (D)\rightarrow \infty$$ and $$R_{D}$$ is the regulator associated to D.

To conclude this section we want to discuss one last result. Recently, Florea [7] established an asymptotic formula for the first moment of quadratic Dirichlet L-functions in function fields. She obtained a strenuous lower order term that had not appeared in the previous work of Hoffstein and Rosen [11] and Andrade and Keating [3]. The core of the idea to obtain such a lower order term is to use the Poisson summation for function fields.

In this paper we use the Poisson summation, as developed by Florea in [7], to obtain an extra main term for the average value of the class number in function fields. With this, we are able to go beyond the results of Hoffstein and Rosen [11], Andrade [1] and Jung [12] related to the average value of the class number. The paper is organized in the following way. In the next section, we state our main result and the new formula for the average value of the class number in function fields. In Sect. 3 we present a few preliminary results that will be used in the rest of the paper. In Sect. 4 we set up the problem and present the basic strategy of how the main calculations will be carried out. In Sects. 5 and 6, we compute the main terms in the asymptotic formula. We handle the error term in Sect. 7 and we conclude the proof of the main result in Sect. 8.

## 2 The main theorem

Our main results are now presented.

### Theorem 2.1

Let $$\mathbb {F}_{q}$$ be a fixed finite field with q a prime number such that $$q\equiv 1 \bmod 4$$ and $$\epsilon >0$$. Then, as $$g\rightarrow \infty$$, we have
\begin{aligned} \sum _{D\in \mathcal H_{2g+1}} L(1,\chi _{D}) = c_{0} q^{2g+1} + c_{1} q^{\frac{g}{3}} + O(q^{g\epsilon }), \end{aligned}
(2.1)
where
\begin{aligned} c_{0}= & {} \prod _{P} \left( 1-\frac{1}{|P|^2(1+|P|)}\right) ~~\text { and} \\ c_{1}= & {} \frac{q^{\frac{5}{3}} (1-q^{\frac{2}{3}})}{3(1-q) (1-q^{\frac{5}{3}})} \prod _{P}\left( 1+\frac{1-|P|-|P|^{\frac{7}{3}}+ |P|^{\frac{8}{3}}}{|P|^3 (|P|^{\frac{1}{3}}-1) (|P|^{\frac{2}{3}}+1)}\right) . \end{aligned}

To obtain a formula for the average of the class number $$h_{D}$$ we will make use of the following analogy of Dirichlet’s Theorem due to Artin [4].

### Theorem 2.2

(Artin) For any $$D\in \mathcal H_{2g+1}$$, we have
\begin{aligned} L(1,\chi _{D}) = \frac{\sqrt{q}}{\sqrt{|D|}}\, h_{D}. \end{aligned}
(2.2)

We now have all the ingredients to obtain an asymptotic formula for the average of the class number $$h_{D}$$.

### Corollary 2.3

For $$\epsilon >0$$ given and with the same notation as before, we have that
\begin{aligned} \sum _{D\in \mathcal H_{2g+1}} h_{D} = c_{0} q^{3g+1} + c_{1} q^{\frac{4g}{3}} + O(q^{g(1+\epsilon )}). \end{aligned}

In light of the analogy between number fields and function fields we make the following conjecture for the classical case.

### Conjecture 2.4

For $$\epsilon >0$$ and using the same notation as those of Theorem 1.2 we have that
\begin{aligned} \sum _{1\le -D\le N}h_{D}=C_{0}N^{\tfrac{3}{2}}+C_{1}N^{\tfrac{2}{3}}+O(N^{\tfrac{1}{2}(1+\epsilon )}), \end{aligned}
for some positive constants $$C_{0}$$ and $$C_{1}$$.

## 3 Preliminaries and background

For any $$D\in \mathcal H_{2g+1}$$, we have from [3, Equation (3.23)] that
\begin{aligned} L(1, \chi _{D}) = \sum _{f\in \mathbb {A}_{\le g}^{+}} \frac{\chi _{D}(f)}{|f|} + \frac{1}{q^{g}} \sum _{f\in \mathbb {A}_{\le g-1}^{+}} \chi _{D}(f). \end{aligned}
It follows that
\begin{aligned} \sum _{D\in \mathcal H_{2g+1}} L(1, \chi _{D}) = \sum _{f\in \mathbb {A}_{\le g}^{+}}\frac{1}{|f|}\sum _{D\in \mathcal H_{2g+1}}\chi _{D}(f) + \frac{1}{q^{g}}\sum _{f\in \mathbb {A}_{\le g-1}^{+}} \sum _{D\in \mathcal H_{2g+1}}\chi _{D}(f). \end{aligned}
(3.1)
We state two lemmas that will be used in the calculations to follow.

### Lemma 3.1

Let $$f\in \mathbb {A}^{+}$$. Then
\begin{aligned} \sum _{D\in \mathcal H_{2g+1}} \chi _{D}(f) = \sum _{\begin{array}{c} C|f^{\infty } \end{array}} \sum _{H\in \mathbb {A}^{+}_{2g+1-2d(C)}} \chi _{f}(H) - q \sum _{C|f^{\infty }} \sum _{H\in \mathbb {A}^{+}_{2g-1-2d(C)}} \chi _{f}(H), \end{aligned}
where the first summation is over $$C\in \mathbb {A}^{+}$$ whose prime factors are among the prime factors of f.

### Proof

This is Lemma 2.2 in [7]. $$\square$$

We now state a version of Poisson summation over function fields. For $$a \in \mathbb {F}_{q}((\frac{1}{t}))$$, let $$e(a):= e^{2\pi ia_{1}/q}$$, where $$a_{1}$$ is the coefficient of $$\frac{1}{t}$$ in the expansion of a (for more details, see [7, §3]). For $$\chi$$ a general character modulo f, the generalized Gauss sum $$G(V,\chi )$$ is defined as
\begin{aligned} G(V,\chi ) = \sum _{A\, \bmod \, f} \chi (A) e\left( \frac{AV}{f}\right) . \end{aligned}
The following Poisson summation formula holds.

### Lemma 3.2

Let $$f\in \mathbb {A}^{+}$$ and let m be a positive integer.
1. (1)
If d(f) is odd, then
\begin{aligned} \sum _{M\in \mathbb {A}_{m}^{+}} \chi _{f}(M) = \frac{q^{m+\frac{1}{2}}}{|f|} \sum _{V\in \mathbb {A}^{+}_{d(f)-m-1}} G(V,\chi _{f}). \end{aligned}
(3.2)

2. (2)
If d(f) is even, then
\begin{aligned}&\sum _{M\in \mathbb {A}_{m}^{+}} \chi _{f}(M)\nonumber \\&\quad = \frac{q^{m}}{|f|}\left( G(0,\chi _{f}) + (q-1) \sum _{V\in \mathbb {A}^{+}_{\le d(f)-m-2}} G(V,\chi _{f})- \sum _{V\in \mathbb {A}^{+}_{d(f)-m-1}} G(V,\chi _{f})\right) . \end{aligned}
(3.3)

### Proof

This is Proposition 3.1 in [7]. $$\square$$

Remark that $$G(0,\chi _{f})$$ is nonzero if and only if f is a square, in which case $$G(0,\chi _{f}) = \phi (f)$$, where $$\phi (f)$$ is Euler’s phi-function for polynomials in $$\mathbb {F}_{q}[t]$$.

## 4 Setup of the problem

Invoking (3.1) and Lemma 3.1, we can write
\begin{aligned} \sum _{D\in \mathcal H_{2g+1}} L(1, \chi _{D}) = \mathcal S_{g} + \mathcal S_{g-1}, \end{aligned}
where
\begin{aligned} \mathcal S_{g} =&\sum _{f\in \mathbb {A}_{\le g}^{+}}\frac{1}{|f|}\sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g} \end{array}} \sum _{H\in \mathbb {A}^{+}_{2g+1-2d(C)}} \chi _{f}(H) \\&- q \sum _{f\in \mathbb {A}_{\le g}^{+}}\frac{1}{|f|}\sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}} \sum _{H\in \mathbb {A}^{+}_{2g-1-2d(C)}} \chi _{f}(H) \end{aligned}
and
\begin{aligned} \mathcal S_{g-1} =&\frac{1}{q^{g}}\sum _{f\in \mathbb {A}^{+}_{\le g-1}} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g} \end{array}} \sum _{H\in \mathbb {A}^{+}_{2g+1-2d(C)}} \chi _{f}(H) \\&- \frac{1}{q^{g-1}}\sum _{f\in \mathbb {A}_{\le g-1}^{+}} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}} \sum _{H\in \mathbb {A}^{+}_{2g-1-2d(C)}} \chi _{f}(H). \end{aligned}
Using the fact that (for details see section 4 in [7])
\begin{aligned} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{g} \end{array}} 1 \ll q^{g \epsilon }, \end{aligned}
we can see that the terms in $$\mathcal S_{g}$$ and $$\mathcal S_{g-1}$$ corresponding to $$C\in \mathbb {A}^{+}_{g}$$ are bounded by $$O(q^{g\epsilon })$$. We rewrite
\begin{aligned} {\mathcal S}_{g} = \sum _{f\in \mathbb {A}_{\le g}^{+}}\frac{1}{|f|}\sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}s(f;C) + O(q^{g\epsilon }) \end{aligned}
(4.1)
and
\begin{aligned} {\mathcal S}_{g-1} = \frac{1}{q^{g}}\sum _{f\in \mathbb {A}_{\le g-1}^{+}}\sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}} s(f;C) + O(q^{g\epsilon }), \end{aligned}
(4.2)
where
\begin{aligned} s(f;C) = \sum _{H\in \mathbb {A}^{+}_{2g+1-2d(C)}} \chi _{f}(H) - q \sum _{H\in \mathbb {A}^{+}_{2g-1-2d(C)}} \chi _{f}(H). \end{aligned}
For $$\ell \in \{g, g-1\}$$, write $${\mathcal S}_{\ell } = {\mathcal S}_{\ell }^\mathrm{o} + {\mathcal S}_{\ell }^\mathrm{e} + O(q^{g\epsilon })$$, where $${\mathcal S}_{\ell }^\mathrm{o}$$ and $${\mathcal S}_{\ell }^\mathrm{e}$$ denote the sum over $$f\in \mathbb {A}^{+}_{\le \ell }$$ of odd and even degree respectively. By using (3.2), if d(f) is odd, then
\begin{aligned} s(f;C) = \frac{q^{2g+\frac{3}{2}}}{|f|^{\frac{1}{2}}|C|^{2}} s^\mathrm{o}(f;C) \end{aligned}
with
\begin{aligned} s^\mathrm{o}(f;C) = \sum _{V\in \mathbb {A}^{+}_{d(f)-2g-2+2d(C)}} \frac{G(V,\chi _{f})}{|f|^{\frac{1}{2}}} - \frac{1}{q} \sum _{V\in \mathbb {A}^{+}_{d(f)-2g+2d(C)}} \frac{G(V,\chi _{f})}{|f|^{\frac{1}{2}}}. \end{aligned}
(4.3)
Hence, we have
\begin{aligned} {\mathcal S}_{g}^\mathrm{o} = q^{2g+\frac{3}{2}} \sum _{\begin{array}{c} f\in \mathbb {A}_{\le g}^{+}\\ d(f)\mathrm{: odd} \end{array}}\frac{1}{|f|^{\frac{3}{2}}} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}\frac{s^\mathrm{o}(f;C)}{|C|^{2}} \end{aligned}
(4.4)
and
\begin{aligned} {\mathcal S}_{g-1}^\mathrm{o} = q^{g+\frac{3}{2}} \sum _{\begin{array}{c} f\in \mathbb {A}_{\le g-1}^{+}\\ d(f)\mathrm{: odd} \end{array}}\frac{1}{|f|^{\frac{1}{2}}} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}\frac{s^\mathrm{o}(f;C)}{|C|^{2}}. \end{aligned}
(4.5)
By (3.3), if d(f) is even, then
\begin{aligned} s(f;C) = \frac{G(0,\chi _{f})}{\zeta _{\mathbb {A}}(2)}\frac{q^{2g+1}}{|f| |C|^{2}} + \frac{q^{2g+1}}{|f|^{\frac{1}{2}} |C|^{2}}s^\mathrm{e}(f;C) \end{aligned}
with
\begin{aligned} {s}^\mathrm{e}(f;C)&= \frac{q}{\zeta _{\mathbb {A}}(2)} \sum _{V\in \mathbb {A}^{+}_{\le d(f)-2g-3+2d(C)}} \frac{G(V,\chi _{f})}{|f|^{\frac{1}{2}}} - \sum _{V\in \mathbb {A}^{+}_{d(f)-2g-2+2d(C)}} \frac{G(V,\chi _{f})}{|f|^{\frac{1}{2}}} \nonumber \\&\quad - \frac{1}{\zeta _{\mathbb {A}}(2)} \sum _{V\in \mathbb {A}^{+}_{\le d(f)-2g-1+2d(C)}} \frac{G(V,\chi _{f})}{|f|^{\frac{1}{2}}} + \frac{1}{q} \sum _{V\in \mathbb {A}^{+}_{d(f)-2g+2d(C)}} \frac{G(V,\chi _{f})}{|f|^{\frac{1}{2}}}. \end{aligned}
(4.6)
Write $${\mathcal S}_{g}^\mathrm{e} = \mathcal M_{g} + \tilde{\mathcal S}_{g}^\mathrm{e}$$ and $${\mathcal S}_{g-1}^\mathrm{e} = \mathcal M_{g-1} + \tilde{\mathcal S}_{g-1}^\mathrm{e}$$, where
\begin{aligned} \mathcal M_{g}&= \frac{q^{2g+1}}{\zeta _{\mathbb {A}}(2)} \sum _{L\in \mathbb {A}_{\le [\frac{g}{2}]}^{+}}\frac{\phi (L^2)}{|L|^{4}} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}\frac{1}{|C|^{2}}, \end{aligned}
(4.7)
\begin{aligned} \mathcal M_{g-1}&= \frac{q^{g+1}}{\zeta _{\mathbb {A}}(2)} \sum _{L\in \mathbb {A}_{\le [\frac{g-1}{2}]}^{+}}\frac{\phi (L^2)}{|L|^{2}} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}\frac{1}{|C|^{2}} \end{aligned}
(4.8)
and
\begin{aligned} \tilde{\mathcal S}_{g}^\mathrm{e}&= q^{2g+1} \sum _{\begin{array}{c} f\in \mathbb {A}_{\le g}^{+}\\ d(f) \mathrm{: even} \end{array}}\frac{1}{|f|^{\frac{3}{2}}} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}\frac{s^\mathrm{e}(f;C)}{|C|^{2}}, \end{aligned}
(4.9)
\begin{aligned} \tilde{\mathcal S}_{g-1}^\mathrm{e}&= q^{g+1} \sum _{\begin{array}{c} f\in \mathbb {A}_{\le g-1}^{+}\\ d(f) \mathrm{: even} \end{array}}\frac{1}{|f|^{\frac{1}{2}}} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}\frac{s^\mathrm{e}(f;C)}{|C|^{2}}. \end{aligned}
(4.10)
For $$\ell \in \{g, g-1\}$$, let $${\mathcal S}_{\ell }(V=\square )$$ be the sums over V square in $$\tilde{\mathcal S}_{\ell }^\mathrm{e}$$ and $$\tilde{\mathcal S}_{\ell }^\mathrm{e}(V\ne \square )$$ be the sums over V non-square in $$\tilde{\mathcal S}_{\ell }^\mathrm{e}$$. Then $$\tilde{\mathcal S}_{\ell }^\mathrm{e} = {\mathcal S}_{\ell }(V=\square ) + \tilde{\mathcal S}_{\ell }^\mathrm{e}(V\ne \square )$$. When $$V = L^2$$, write
\begin{aligned} {\mathcal S}_{g}(V=\square ) = q^{2g+1} \sum _{\begin{array}{c} f\in \mathbb {A}_{\le g}^{+}\\ d(f)\mathrm{: even} \end{array}}\frac{1}{|f|^{\frac{3}{2}}} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}\frac{s_{\square }^\mathrm{e}(f;C)}{|C|^{2}} \end{aligned}
(4.11)
and
\begin{aligned} {\mathcal S}_{g-1}(V=\square ) = q^{g+1} \sum _{\begin{array}{c} f\in \mathbb {A}_{\le g-1}^{+}\\ d(f)\mathrm{: even} \end{array}}\frac{1}{|f|^{\frac{1}{2}}} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}\frac{s_{\square }^\mathrm{e}(f;C)}{|C|^{2}} \end{aligned}
(4.12)
with
\begin{aligned} s_{\square }^\mathrm{e}(f;C)&= \frac{q}{\zeta _{\mathbb {A}}(2)} \sum _{L\in \mathbb {A}^{+}_{\le \frac{d(f)}{2}-g-2+d(C)}} \frac{G(L^2,\chi _{f})}{|f|^{\frac{1}{2}}} - \sum _{L\in \mathbb {A}^{+}_{\frac{d(f)}{2}-g-1+d(C)}} \frac{G(L^2,\chi _{f})}{|f|^{\frac{1}{2}}} \nonumber \\&\quad - \frac{1}{\zeta _{\mathbb {A}}(2)} \sum _{L\in \mathbb {A}^{+}_{\le \frac{d(f)}{2}-g-1+d(C)}} \frac{G(L^2,\chi _{f})}{|f|^{\frac{1}{2}}} + \frac{1}{q} \sum _{L\in \mathbb {A}^{+}_{\frac{d(f)}{2}-g+d(C)}} \frac{G(L^2,\chi _{f})}{|f|^{\frac{1}{2}}}. \end{aligned}
(4.13)
Note that in (4.3), since d(f) is odd, d(V) is also odd, so V cannot be a square. For $$\ell \in \{g, g-1\}$$, define $$\mathcal S_{\ell }(V\ne \square ) = \mathcal S_{\ell }^\mathrm{o} + \tilde{\mathcal S}_{\ell }^\mathrm{e}(V\ne \square )$$. We will bound $$\mathcal S_{g}(V\ne \square )$$ and $$\mathcal S_{g-1}(V\ne \square )$$ in Sect. 7.

An immediate application of Cauchy’s theorem and the formula for the geometric series give us the following Lemma, which is the function field analogue of Perron’s formula, or if you prefer Tauberian theorems.

### Lemma 4.1

If the power series $$H(u) = \sum _{f \in \mathbb {A}^{+}} a(f) u^{d(f)}$$ converges absolutely for $$|u| \le R < 1$$, then
\begin{aligned} \sum _{f \in \mathbb {A}^{+}_{n}} a(f) = \frac{1}{2\pi i} \oint _{|u|=R} \frac{H(u)}{u^{n+1}} du \end{aligned}
(4.14)
and
\begin{aligned} \sum _{f \in \mathbb {A}^{+}_{\le n}} a(f) = \frac{1}{2\pi i} \oint _{|u|=R} \frac{H(u)}{(1-u)u^{n+1}} du. \end{aligned}
(4.15)

## 5 Main term

In this section we compute the main terms $$\mathcal M_{g}$$ and $$\mathcal M_{g-1}$$. Put
\begin{aligned} \mathcal C(u) = \prod _{P} \left( 1-\frac{u^{d(P)}}{1+|P|}\right) , \end{aligned}
(5.1)
which is analytic in $$|u|<1$$. We may further write
\begin{aligned} \mathcal C(u)&= \mathcal Z_{\mathbb {A}}\left( \frac{u}{q}\right) ^{-1} \prod _{P}\left( 1+\frac{u^{d(P)}}{(1+|P|)(|P|-u^{d(P)})}\right) \nonumber \\&= (1-u) \prod _{P}\left( 1+\frac{u^{d(P)}}{(1+|P|)(|P|-u^{d(P)})}\right) \end{aligned}
(5.2)
which furnishes an analytic continuation of $$\mathcal C(u)$$ to the region $$|u|<q$$.

The next proposition is the main result of this section.

### Proposition 5.1

For any $$\varepsilon >0$$, we have that
\begin{aligned} \mathcal M_{g} + \mathcal M_{g-1}&= \frac{q^{g+1}}{\zeta _{\mathbb {A}}(2)} \frac{1}{2\pi i} \oint _{|u| = r} \frac{(q^{g-2[\frac{g}{2}]} (1-u) u^{[\frac{g-1}{2}]} + (1-q^2 u) u^{[\frac{g}{2}]})\mathcal C(u)}{(1-u)(1-qu)(1-q^2 u) u^{g}} du \nonumber \\&+ O(q^{g\epsilon }), \end{aligned}
(5.3)
where $$r<q^{-2}$$.

### Proof

From (4.7) and (4.8) with the facts that
\begin{aligned} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}\frac{1}{|C|^{2}} = \prod _{P|f} (1-|P|^{-2})^{-1} + O(q^{g(\epsilon -2)}) ~~~\text { and }~~~ \frac{\phi (L^2)}{|L|^{2}} = \prod _{P|L} (1-|P|^{-1}), \end{aligned}
we obtain
\begin{aligned} \mathcal M_{g} = \frac{q^{2g+1}}{\zeta _{\mathbb {A}}(2)} \sum _{L\in \mathbb {A}^{+}_{\le [\frac{g}{2}]}}\frac{1}{|L|^{2} \prod _{P|L} (1+|P|^{-1})} + O(q^{g\epsilon }) \end{aligned}
and
\begin{aligned} \mathcal M_{g-1} = \frac{q^{g+1}}{\zeta _{\mathbb {A}}(2)} \sum _{L\in \mathbb {A}_{\le [\frac{g-1}{2}]}^{+}}\frac{1}{\prod _{P|L} (1+|P|^{-1})} + O(q^{g\epsilon }). \end{aligned}
By Perron’s formula (4.15), we have
\begin{aligned} \mathcal M_{g} = \frac{q^{2g+1}}{\zeta _{\mathbb {A}}(2)} \frac{1}{2\pi i} \oint _{|u| = r}\frac{\mathcal A(u)}{u(1-q^{2}u)(q^{2}u)^{[\frac{g}{2}]}} du \end{aligned}
(5.4)
and
\begin{aligned} \mathcal M_{g-1} = \frac{q^{g+1}}{\zeta _{\mathbb {A}}(2)}\frac{1}{2\pi i} \oint _{|u| = r} \frac{\mathcal A(u)}{(1-u) u^{[\frac{g-1}{2}]+1}}du, \end{aligned}
(5.5)
where $$r<q^{-2}$$ and
\begin{aligned} \mathcal A(u) = \sum _{L\in \mathbb {A}^{+}} u^{d(L)} \prod _{P|L} (1+|P|^{-1})^{-1}. \end{aligned}
By multiplicativity, we may write
\begin{aligned} \mathcal A(u) = \prod _{P}\left( 1+\frac{|P|}{1+|P|} \frac{u^{d(P)}}{1-u^{d(P)}}\right) = \mathcal Z(u) \mathcal C(u) = \frac{\mathcal C(u)}{1-qu}. \end{aligned}
(5.6)
By inserting (5.6) in both (5.4) and (5.5), and adding $$\mathcal M_{g}$$ and $$\mathcal M_{g-1}$$, we get the result.

$$\square$$

## 6 Contribution from V square

In this section, we will evaluate the terms $$\mathcal S_{g}(V=\square )$$ and $$\mathcal S_{g-1}(V=\square )$$.

### Proposition 6.1

We have that
\begin{aligned} \mathcal S_{g}(V=\square ) + \mathcal S_{g-1}(V=\square )&= - \frac{q^{g+1}}{\zeta _{\mathbb {A}}(2)} \frac{1}{2\pi i} \oint _{|u|=q^{1-\frac{\epsilon }{2}}}\\&\quad \times \frac{(q^{g-2[\frac{g}{2}]} (1-u) u^{[\frac{g-1}{2}]} + (1-q^2 u) u^{[\frac{g}{2}]})\mathcal C(u)}{(1-u)(1-qu)(1-q^2 u) u^{g}} du \\&\quad + c_{1} q^{\frac{g}{3}} + O(q^{g\epsilon }), \end{aligned}
where
\begin{aligned} c_{1} = \frac{q^{\frac{5}{3}} (1-q^{\frac{2}{3}})}{3(1-q) (1-q^{\frac{5}{3}})} \prod _{P}\left( 1+\frac{1-|P|-|P|^{\frac{7}{3}}+ |P|^{\frac{8}{3}}}{|P|^3 (|P|^{\frac{1}{3}}-1) (|P|^{\frac{2}{3}}+1)}\right) . \end{aligned}
For $$|z| > q^{-2}$$, put
\begin{aligned} \mathcal B(z,w) = \sum _{f\in \mathbb {A}^{+}} \frac{w^{d(f)} A_{f}(z)}{\prod _{P|f}(1-|P|^{-2}z^{-d(P)})} \end{aligned}
with
\begin{aligned} A_{f}(z) = \sum _{L\in \mathbb {A}^{+}} z^{d(L)} \frac{G(L^2, \chi _{f})}{\sqrt{|f|}}. \end{aligned}
For a proof of Proposition 6.1, we need the following two lemmas (see [7, section 6]).

### Lemma 6.2

For $$|z| > q^{-2}$$, we have
\begin{aligned} \mathcal B(z,w) = \mathcal Z(z) \mathcal Z(w) \mathcal Z(q z w^2) \prod _{P} \mathcal B_{P}(z,w), \end{aligned}
(6.1)
where
\begin{aligned} \mathcal B_{P}(z,w) = 1 + \tfrac{w^{d(P)}-(zw^2)^{d(P)}|P|^2-(z^2w)^{d(P)}|P|^2+(z^2 w^3)^{d(P)}|P|^2 + (zw^2)^{d(P)}|P|-(zw^3)^{d(P)}|P|}{z^{d(P)}|P|^2-1}. \end{aligned}
Moreover, $$\prod _{P} \mathcal B_{P}(z,w)$$ converges absolutely for $$|w| < q |z|$$, $$|w| < q^{-\frac{1}{2}}$$ and $$|wz| < q^{-1}$$.

### Lemma 6.3

We have
\begin{aligned} \prod _{P} \mathcal B_{P}(z,w) = \mathcal Z\left( \frac{w}{q^2 z}\right) \mathcal Z(w^2)^{-1} \prod _{P} \mathcal D_{P}(z,w), \end{aligned}
(6.2)
where
\begin{aligned}&\mathcal D_{P}(z,w) = 1\\&\quad + \tfrac{-w^{2d(P)}-\frac{w^{3d(P)}}{|P|}+\frac{w^{d(P)}}{z^{d(P)}|P|^2}+(z w^2)^{d(P)}|P|+(z w^2)^{d(P)}-(z^2 w)^{d(P)}|P|^2+(z w^3)^{d(P)} - (z^2 w^2)^{d(P)}|P|^2}{(z^{d(P)}|P|^2-1) (1+w^{d(P)})}. \end{aligned}
Moreover, $$\prod _{P} \mathcal D_{P}(z,w)$$ converges absolutely for $$|w|^2 < q |z|$$, $$|w|< q^3 |z|^2$$, $$|w|<1$$ and $$|wz| < q^{-1}$$.

### 6.1 Proof of Proposition 6.1

From (4.13), using Cauchy’s formula (4.15), we obtain
\begin{aligned} s_{\square }^\mathrm{e}(f;C) = \frac{1}{2\pi i}\oint _{|z|=q^{-1-\epsilon }} \frac{(qz-1) (1-\frac{1}{qz}) A_{f}(z)}{(1-z)z^{\frac{d(f)}{2}-g+d(C)}} dz. \end{aligned}
Hence, from (4.11) and (4.12), it follows that
\begin{aligned} \mathcal S_{g}(V=\square )&= \frac{q^{2g+1}}{2\pi i}\oint _{|z|=q^{-1-\epsilon }} \frac{z^{g} (qz-1)(1-\frac{1}{qz})}{(1-z)} \sum _{\begin{array}{c} f\in \mathbb {A}_{\le g}^{+}\\ d(f)\mathrm{: even} \end{array}} \frac{A_{f}(z)}{|f|^{\frac{3}{2}}z^{\frac{d(f)}{2}}}\\&\times \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}\frac{1}{|C|^{2} z^{d(C)}} dz \end{aligned}
and
\begin{aligned} \mathcal S_{g-1}(V=\square )&= \frac{q^{g+1}}{2\pi i}\oint _{|z|=q^{-1-\epsilon }} \frac{z^{g} (qz-1)(1-\frac{1}{qz})}{(1-z)} \sum _{\begin{array}{c} f\in \mathbb {A}_{\le g-1}^{+}\\ d(f)\mathrm{: even} \end{array}} \frac{A_{f}(z)}{|f|^{\frac{1}{2}}z^{\frac{d(f)}{2}}}\\&\times \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}\frac{1}{|C|^{2} z^{d(C)}} dz. \end{aligned}
Write
\begin{aligned} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\le g-1} \end{array}}\frac{1}{|C|^{2} z^{d(C)}} = \prod _{P|f}(1-|P|^{-2}z^{-d(P)})^{-1} - \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\ge g} \end{array}}\frac{1}{|C|^{2} z^{d(C)}} \end{aligned}
and using the fact that (see [7, Proof of Lemma 6.1])
\begin{aligned} \bigg |\sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{\ge g} \end{array}}\frac{1}{|C|^{2} z^{d(C)}}\bigg | \ll q^{g(\epsilon -1)}, \end{aligned}
we obtain
\begin{aligned} {\mathcal S}_{g}(V=\square ) = \frac{q^{2g+1}}{2\pi i}\oint _{|z|=q^{-1-\epsilon }} \frac{z^{g} (qz-1)(1-\frac{1}{qz})}{(1-z)} H_{g}(z) dz + O(q^{g\epsilon }) \end{aligned}
and
\begin{aligned} {\mathcal S}_{g-1}(V=\square ) = \frac{q^{g+1}}{2\pi i}\oint _{|z|=q^{-1-\epsilon }} \frac{z^{g} (qz-1)(1-\frac{1}{qz})}{(1-z)} H_{g-1}(z) dz + O(q^{g\epsilon }), \end{aligned}
where
\begin{aligned} H_{g}(z) = \sum _{\begin{array}{c} f\in \mathbb {A}_{\le g}^{+}\\ d(f)\mathrm{: even} \end{array}} \frac{A_{f}(z)}{|f|^{\frac{3}{2}}z^{\frac{d(f)}{2}}\prod _{P|f}(1-|P|^{-2}z^{-d(P)})} \end{aligned}
and
\begin{aligned} H_{g-1}(z) = \sum _{\begin{array}{c} f\in \mathbb {A}_{\le g-1}^{+}\\ d(f)\mathrm{: even} \end{array}} \frac{A_{f}(z)}{|f|^{\frac{1}{2}}z^{\frac{d(f)}{2}}\prod _{P|f}(1-|P|^{-2}z^{-d(P)})}. \end{aligned}
Using the Perron’s formula (4.14), we have
\begin{aligned} H_{g}(z) = \frac{1}{2\pi i} \oint _{|w|=r_{2}} \frac{\mathcal B(z,w)}{w (1-q^3 z w^2) (q^3 z w^2)^{[\frac{g}{2}]}} dw - \frac{1}{2\pi i} \oint _{|w|=r_{2}} \frac{q^3 z w \mathcal B(z,w)}{1-q^3 z w^2} dw \end{aligned}
(6.3)
and
\begin{aligned} H_{g-1}(z) = \frac{1}{2\pi i} \oint _{|w|=r_{2}}\frac{\mathcal B(z,w)}{w (1-q z w^2) (q z w^2)^{[\frac{g-1}{2}]}} dw - \frac{1}{2\pi i} \oint _{|w|=r_{2}}\frac{q z w\mathcal B(z,w)}{1- q z w^2}dw, \end{aligned}
(6.4)
where the second integrals in (6.3) and (6.4) are zero since the integrands have no poles inside the circle $$|w|=r_{2}<q^{-1}$$. Hence, we have
\begin{aligned} {\mathcal S}_{g}(V=\square ) =&\, q^{2g+1} \left( \frac{1}{2\pi i}\right) ^{2} \oint _{|z|=q^{-1-\epsilon }}\oint _{|w|=r_2} \\&\times \frac{z^{g} (qz-1)(1-\frac{1}{qz})\mathcal B(z,w)}{w (1-z) (1-q^3 z w^2) (q^3 z w^2)^{[\frac{g}{2}]}} dz dw + O(q^{g\epsilon }) \end{aligned}
and
\begin{aligned} {\mathcal S}_{g-1}(V=\square ) =&\, q^{g+1} \left( \frac{1}{2\pi i}\right) ^{2} \oint _{|z|=q^{-1-\epsilon }}\oint _{|w|=r_2}\\&\times \frac{z^{g} (qz-1)(1-\frac{1}{qz})\mathcal B(z,w)}{w (1-z) (1-q z w^2) (q z w^2)^{[\frac{g-1}{2}]}} dz dw + O(q^{g\epsilon }). \end{aligned}
Now, we use the formula for $$\mathcal B(z,w)$$ in (6.1) and the formula for $$\prod _{P} \mathcal B_{P}(z,w)$$ in (6.2) to obtain that
\begin{aligned} {\mathcal S}_{g}(V=\square ) = - q^{2g+1}\left( \frac{1}{2\pi i}\right) ^{2}\oint _{|z|=q^{-1-\epsilon }}\oint _{|w|=r_2} F(z,w) dz dw + O(q^{g\epsilon }) \end{aligned}
and
\begin{aligned} {\mathcal S}_{g-1}(V=\square ) = - q^{g+1} \left( \frac{1}{2\pi i}\right) ^{2}\oint _{|z|=q^{-1-\epsilon }}\oint _{|w|=r_2} G(z,w) dz dw + O(q^{g\epsilon }), \end{aligned}
where
\begin{aligned} F(z,w)&= \tfrac{z^g (1-\frac{1}{qz}) \prod _{P}\mathcal B_{P}(z,w)}{w (1-z) (1-qw) (1-q^2 z w^2)(1-q^3 z w^2) (q^3 z w^2)^{[\frac{g}{2}]}}\\&= \tfrac{z^g (1-\frac{1}{qz}) (1-qw^2) \prod _{P}\mathcal D_{P}(z,w)}{w (1-z) (1-qw) (1-\frac{w}{q z}) (1-q^2 z w^2)(1-q^3 z w^2) (q^3 z w^2)^{[\frac{g}{2}]}}, \\ G(z,w)&= \tfrac{z^g (1-\frac{1}{qz}) \prod _{P}\mathcal B_{P}(z,w)}{w (1-z) (1-qw) (1-q^2 z w^2)(1-q z w^2) (q z w^2)^{[\frac{g-1}{2}]}}\\&= \tfrac{z^g (1-\frac{1}{qz}) (1-qw^2) \prod _{P}\mathcal D_{P}(z,w)}{w (1-z) (1-qw) (1-\frac{w}{q z}) (1-q^2 z w^2)(1-q z w^2) (q z w^2)^{[\frac{g-1}{2}]}}. \end{aligned}
Shrinking the contour $$|z| = q^{-1-\epsilon }$$ to $$|z|=q^{-2+\frac{\epsilon }{2}}$$, we don’t encounter any poles. We enlarge the contour $$|w|=r_{2} < q^{-1}$$ to $$|w|=q^{-\frac{1}{2}-\frac{3\varepsilon }{4}}$$, and we encounter two simple poles, one at $$w=q^{-1}$$ and one at $$w=qz$$. Then we have
\begin{aligned} {\mathcal S}_{g}(V=\square )&= \frac{q^{2g+1}}{2\pi i}\oint _{|z| = q^{-2+\frac{\epsilon }{2}}}\mathrm{Res}(F(z,w);w=q^{-1})dz\nonumber \\&\quad + \frac{q^{2g+1}}{2\pi i}\oint _{|z| = q^{-2+\frac{\epsilon }{2}}}\mathrm{Res}(F(z,w);w=qz) dz \nonumber \\&\quad - q^{2g+1} \left( \frac{1}{2\pi i}\right) ^{2} \oint _{|w|=q^{-\frac{1}{2}-\frac{3\varepsilon }{4}}}\oint _{|z|=q^{-2+\frac{\epsilon }{2}}} F(z,w) dz dw \end{aligned}
(6.5)
and
\begin{aligned} {\mathcal S}_{g-1}(V=\square )&= \frac{q^{g+1}}{2\pi i}\oint _{|z| = q^{-2+\frac{\epsilon }{2}}}\mathrm{Res}(G(z,w);w=q^{-1})dz\nonumber \\&\quad + \frac{q^{g+1}}{2\pi i}\oint _{|z| = q^{-2+\frac{\epsilon }{2}}}\mathrm{Res}(G(z,w);w=qz) dz \nonumber \\&\quad - q^{g+1} \left( \frac{1}{2\pi i}\right) ^{2} \oint _{|w|=q^{-\frac{1}{2}-\frac{3\varepsilon }{4}}}\oint _{|z|=q^{-2+\frac{\epsilon }{2}}} G(z,w) dz dw, \end{aligned}
(6.6)
where the third terms in (6.5) and in (6.6) are bounded by $$O(q^{g\epsilon })$$. Now we evaluate the residues of F(zw) and G(zw) at $$w=q^{-1}$$ and $$w=qz$$, we can write
\begin{aligned} {\mathcal S}_{g}(V{=}\square ) {=} {\mathcal A}_{g} + {\mathcal B}_{g} + O(q^{g\epsilon }) ~~~\text { and }~~~ {\mathcal S}_{g-1}(V=\square ) = {\mathcal A}_{g-1} + {\mathcal B}_{g-1}+O(q^{g\epsilon }), \end{aligned}
(6.7)
where
\begin{aligned} {\mathcal A}_{g}&= - \frac{q^{2g+1}}{2\pi i} \oint _{|z| = q^{-2+\frac{\epsilon }{2}}} \frac{z^g (1-\frac{1}{qz})\prod _{P}\mathcal B_{P}(z,q^{-1})}{(1-z)^2 (1-qz) (qz)^{[\frac{g}{2}]}} dz, \\ {\mathcal B}_{g}&= - \frac{q^{2g+1}}{2\pi i} \oint _{|z| = q^{-2+\frac{\epsilon }{2}}} \frac{z^g (1-\frac{1}{qz}) (1-q^3 z^2) \prod _{P}\mathcal D_{P}(z,qz)}{(1-z) (1-q^2 z) (1-q^4 z^3) (1-q^5 z^3) (q^5 z^3)^{[\frac{g}{2}]}} dz \end{aligned}
and
\begin{aligned} {\mathcal A}_{g-1}&= - \frac{q^{g+1}}{2\pi i} \oint _{|z| = q^{-2+\frac{\epsilon }{2}}} \frac{q z^g (1 - \frac{1}{q z}) \prod _{P}\mathcal B_{P}(z,q^{-1})}{(1-z)^2 (q - z) (q^{-1}z)^{[\frac{g-1}{2}]}} dz, \\ {\mathcal B}_{g-1}&= - \frac{q^{g+1}}{2\pi i} \oint _{|z| = q^{-2+\frac{\epsilon }{2}}} \frac{z^g (1-\frac{1}{qz}) (1-q^3 z^2) \prod _{P}\mathcal D_{P}(z,qz)}{(1-z) (1-q^2 z) (1-q^4 z^3) (1-q^3 z^3) (q^3 z^3)^{[\frac{g-1}{2}]}} dz. \end{aligned}

### Lemma 6.4

We have
\begin{aligned} {\mathcal A}_{g} + {\mathcal A}_{g-1} = - \frac{q^{g+1}}{\zeta _{\mathbb {A}}(2)} \frac{1}{2\pi i} \oint _{|u|=q^{1-\frac{\epsilon }{2}}} \frac{(q^{g-2[\frac{g}{2}]} (1-u) u^{[\frac{g-1}{2}]} + (1-q^2 u) u^{[\frac{g}{2}]})\mathcal C(u)}{(1-u)(1-qu)(1-q^2 u) u^{g}} du. \end{aligned}

### Proof

We make the change of variables $$z = (qu)^{-1}$$. Then the contour of integration will become the circle around the origin $$|u| = q$$, and note that $$\prod _{P}\mathcal B_{P}(\frac{1}{qu}, \frac{1}{q})$$ has an analytic continuation for $$q^{-2}<|u|<q$$. We have
\begin{aligned} {\mathcal A}_{g} = \frac{q^{g+2}}{2\pi i} \oint _{|u|=q^{1-\frac{\epsilon }{2}}} \frac{\prod _{P}\mathcal B_{P}(\frac{1}{qu}, \frac{1}{q})}{(1-qu)^2 u^{[\frac{g-1}{2}]}} du \end{aligned}
and
\begin{aligned} {\mathcal A}_{g-1} = \frac{q^{2g+2}}{2\pi i} \oint _{|u|=q^{1-\frac{\epsilon }{2}}} \frac{(1-u) \prod _{P}\mathcal B_{P}(\frac{1}{qu}, \frac{1}{q})}{(1-qu)^2 (1- q^2 u) (q^{2}u)^{[\frac{g}{2}]}} du. \end{aligned}
Now, add $${\mathcal A}_{g}$$ and $${\mathcal A}_{g-1}$$ using the fact that $$(1-u)\prod _{P}\mathcal B_{P}(\frac{1}{qu}, \frac{1}{q}) = \frac{\mathcal C(u)}{\zeta _{\mathbb {A}}(2)}\frac{(qu-1)}{q u}$$, we get the result. $$\square$$

### Lemma 6.5

We have
\begin{aligned} {\mathcal B}_{g} + {\mathcal B}_{g-1} = c_{1} q^{\frac{g}{3}} + O(q^{g\epsilon }), \end{aligned}
where
\begin{aligned} c_{1} = \frac{q^{\frac{5}{3}} (1-q^{\frac{2}{3}})}{3(1-q) (1-q^{\frac{5}{3}})} \prod _{P}\left( 1+\frac{1-|P|-|P|^{\frac{7}{3}}+ |P|^{\frac{8}{3}}}{|P|^3 (|P|^{\frac{1}{3}}-1) (|P|^{\frac{2}{3}}+1)}\right) . \end{aligned}

### Proof

Add $${\mathcal B}_{g}$$ and $${\mathcal B}_{g-1}$$ to get
\begin{aligned} {\mathcal B}_{g} + {\mathcal B}_{g-1} = - \frac{q^{g+1}}{2\pi i} \oint _{|z| = q^{-2+\frac{\epsilon }{2}}} h(z) dz \end{aligned}
where
\begin{aligned} h(z) = \tfrac{z^g (1-\frac{1}{qz}) (1-q^3 z^2) (q^{g-5[\frac{g}{2}]} (1-q^3 z^3) z^{3[\frac{g-1}{2}]} + q^{-3[\frac{g-1}{2}]}(1-q^5 z^3) z^{3[\frac{g}{2}]}) \prod _{P}\mathcal D_{P}(z,qz)}{(1-z) (1-q^2 z) (1-q^3 z^3) (1-q^4 z^3) (1-q^5 z^3) z^{3[\frac{g}{2}]+3[\frac{g-1}{2}]}}. \end{aligned}
Note that the numerator of h(z) has a zero at $$z=q^{-\frac{4}{3}}$$, so h(z) has no pole at $$z=q^{-\frac{4}{3}}$$. Enlarging the contour $$|z|= q^{-2}$$ to $$|z|=q^{-1-\epsilon }$$, we encounter a simple pole at $$z=q^{-\frac{5}{3}}$$ of h(z). Note that $$\prod _{P}\mathcal D_{P}(z,qz)$$ is absolutely convergent when $$q^{-2}< |z| < q^{-1}$$. Then, we have
\begin{aligned} {\mathcal B}_{g} + {\mathcal B}_{g-1}&= q^{g+1} \mathrm{Res}(h(z); z=q^{-\frac{5}{3}}) - \frac{q^{g+1}}{2\pi i} \oint _{|z| = q^{-1-\epsilon }} h(z) dz, \end{aligned}
where the second term is bounded by $$O(q^{g\epsilon })$$. Hence, by evaluating the residue of h(z) at $$z=q^{-\frac{5}{3}}$$, we can get
\begin{aligned} {\mathcal B}_{g} + {\mathcal B}_{g-1} = \frac{q^{\frac{g}{3} +\frac{5}{3}} (1-q^{\frac{2}{3}}) \prod _{P}\mathcal D_{P}(q^{-\frac{5}{3}},q^{-\frac{2}{3}})}{3(1-q) (1-q^{\frac{5}{3}})} + O(q^{g\epsilon }). \end{aligned}
A simple calculation shows that $$\mathcal D_{P}(q^{-\frac{5}{3}},q^{-\frac{2}{3}}) = 1+\frac{1-|P|-|P|^{\frac{7}{3}}+|P|^{\frac{8}{3}}}{|P|^3(|P|^{\frac{1}{3}}-1)(|P|^{\frac{2}{3}}+1)}$$. Hence, we get the result. $$\square$$

By combining (6.7) and Lemma 6.4 and 6.5, we complete the proof of Proposition 6.1.

## 7 Error from non-square V

In this section we will bound the term $$\mathcal S_{g}(V\ne \square ) = \mathcal S_{g}^\mathrm{o} + \tilde{\mathcal S}_{g}^\mathrm{e}(V\ne \square )$$ and $$\mathcal S_{g-1}(V\ne \square ) = \mathcal S_{g-1}^\mathrm{o} + \tilde{\mathcal S}_{g-1}^\mathrm{e}(V\ne \square )$$.

### Proposition 7.1

For any $$\varepsilon > 0$$, we have
\begin{aligned} \mathcal S_{g}(V\ne \square ) \ll q^{g\varepsilon } \end{aligned}
and
\begin{aligned} \mathcal S_{g-1}(V\ne \square ) \ll q^{g\varepsilon }. \end{aligned}
To prove the Proposition 7.1, we will use the following result in [7, section 7]. We have
\begin{aligned} \sum _{\begin{array}{c} C|f^{\infty }\\ C\in \mathbb {A}^{+}_{m} \end{array}} |C|^{-2} = \frac{1}{2\pi i} \oint _{|u| = r_1} \frac{1}{q^{2m} u^{m+1}\prod _{P|f}(1-u^{d(P)})} du \end{aligned}
(7.1)
with $$r_{1}<1$$. For a non-square $$V\in \mathbb {A}^{+}$$ and positive integer n, let
\begin{aligned} \delta _{V;n}(u) = \sum _{f\in \mathbb {A}_{n}^+}\frac{G(V,\chi _{f})}{|f|^{\frac{1}{2}}\prod _{P|f}(1-u^{d(P)})}. \end{aligned}
Then, if $$|u| = q^{-\varepsilon }$$, then we have
\begin{aligned} |\delta _{V;n}(u)| \ll q^{\frac{n}{2}(1+\varepsilon )} |V|^{\varepsilon }. \end{aligned}
(7.2)

### 7.1 Bounding $${\mathcal S}_{g}^\mathrm{o}$$ and $${\mathcal S}_{g-1}^\mathrm{o}$$

For $$\ell \in \{g, g-1\}$$, in (4.4) with (4.3), write $${\mathcal S}_{\ell }^\mathrm{o} = {\mathcal S}_{\ell ,1}^\mathrm{o} - {\mathcal S}_{\ell ,2}^\mathrm{o}$$, where $${\mathcal S}_{\ell ,1}^\mathrm{o}$$ and $${\mathcal S}_{\ell ,2}^\mathrm{o}$$ correspond to the sum over V with $$d(V) = d(f)-2g-2+2d(C)$$ and $$d(V) = d(f)-2g+2d(C)$$ respectively. Then, by using (7.1), we can write
\begin{aligned} {\mathcal S}_{g, 1}^\mathrm{o}&= \frac{q^{2g+\frac{3}{2}}}{2\pi i} \oint _{|u| = r_1} \sum _{n=0}^{[\frac{g-1}{2}]} \frac{1}{q^{3n+\frac{3}{2}}} \sum _{m=g-n+1}^{g-1} \frac{1}{q^{2m} u^{m+1}} \sum _{V\in \mathbb {A}^{+}_{2n-2g-1+2m}} \delta _{V;2n+1}(u) du, \\ {\mathcal S}_{g, 2}^\mathrm{o}&= \frac{q^{2g+\frac{1}{2}}}{2\pi i} \oint _{|u| = r_1} \sum _{n=0}^{[\frac{g-1}{2}]} \frac{1}{q^{3n+\frac{3}{2}}} \sum _{m=g-n}^{g-1} \frac{1}{q^{2m} u^{m+1}} \sum _{V\in \mathbb {A}^{+}_{2n-2g+1+2m}} \delta _{V;2n+1}(u) du \end{aligned}
and
\begin{aligned} {\mathcal S}_{g-1, 1}^\mathrm{o}&= \frac{q^{g+\frac{3}{2}}}{2\pi i} \oint _{|u| = r_1} \sum _{n=0}^{[\frac{g-1}{2}]}\frac{1}{q^{n+\frac{1}{2}}} \sum _{m=g-n+1}^{g-1} \frac{1}{q^{2m} u^{m+1}} \sum _{V\in \mathbb {A}^{+}_{2n-2g-1+2m}} \delta _{V;2n+1}(u) du, \\ {\mathcal S}_{g-1, 2}^\mathrm{o}&= \frac{q^{g+\frac{1}{2}}}{2\pi i} \oint _{|u| = r_1} \sum _{n=0}^{[\frac{g-1}{2}]}\frac{1}{q^{n+\frac{1}{2}}} \sum _{m=g-n}^{g-1} \frac{1}{q^{2m} u^{m+1}} \sum _{V\in \mathbb {A}^{+}_{2n-2g+1+2m}} \delta _{V;2n+1}(u) du \end{aligned}
with $$r_{1} < 1$$. Now, using (7.2) to bound $$\delta _{V;2n+1}(u)$$ and trivially bounding the sum over V, we can get that $${\mathcal S}_{\ell , 1}^\mathrm{o} \ll q^{g\varepsilon }$$ and $${\mathcal S}_{\ell , 2}^\mathrm{o} \ll q^{g\varepsilon }$$, so $${\mathcal S}_{\ell }^\mathrm{o} \ll q^{g\varepsilon }$$ for $$\ell \in \{g, g-1\}$$.

### 7.2 Bounding $$\tilde{\mathcal S}_{g}^\mathrm{e}(V\ne \square )$$ and $$\tilde{\mathcal S}_{g-1}^\mathrm{e}(V\ne \square )$$

For $$\ell \in \{g, g-1\}$$, from (4.9) and (4.10) with (4.6), we write
\begin{aligned} \tilde{\mathcal S}_{\ell }^\mathrm{e}(V\ne \square ) = \tilde{\mathcal S}_{\ell ,1}^\mathrm{e}(V\ne \square ) - \tilde{\mathcal S}_{\ell ,2}^\mathrm{e}(V\ne \square ) + \tilde{\mathcal S}_{\ell ,3}^\mathrm{e}(V\ne \square ) - \tilde{\mathcal S}_{\ell ,4}^\mathrm{e}(V\ne \square ), \end{aligned}
where $$\tilde{\mathcal S}_{\ell ,1}^\mathrm{e}(V\ne \square ), \tilde{\mathcal S}_{\ell ,2}^\mathrm{e}(V\ne \square ), \tilde{\mathcal S}_{\ell ,3}^\mathrm{e}(V\ne \square )$$ and $$\tilde{\mathcal S}_{\ell ,4}^\mathrm{e}(V\ne \square )$$ correspond to the sum over non-square V with $$d(V) \le d(f)-2g-3+2d(C)$$, $$d(V) = d(f)-2g-2+2d(C)$$, $$d(V) \le d(f)-2g-1+2d(C)$$ and $$d(V) = d(f)-2g+2d(C)$$ respectively. Then, by using (7.1), we can write
\begin{aligned} \tilde{\mathcal S}_{g,1}^\mathrm{e}(V\ne \square )&= \frac{(q-1) q^{2g+1}}{2\pi i} \oint _{|u| = r_1} \sum _{n=0}^{[\frac{g}{2}]}\frac{1}{q^{3n}} \sum _{m=g-n+2}^{g-1} \frac{1}{q^{2m} u^{m+1}} \sum _{\square \ne V\in \mathbb {A}^{+}_{\le 2n-2g-3+2m}}\delta _{V;2n}(u) du, \\ \tilde{\mathcal S}_{g,2}^\mathrm{e}(V\ne \square )&= \frac{q^{2g+1}}{2\pi i} \oint _{|u| = r_1} \sum _{n=0}^{[\frac{g}{2}]} q^{-3n} \sum _{m=g-n+1}^{g-1} \frac{1}{q^{2m} u^{m+1}} \sum _{\square \ne V\in \mathbb {A}^{+}_{2n-2g-2+2m}}\delta _{V;2n}(u) du, \\ \tilde{\mathcal S}_{g,3}^\mathrm{e}(V\ne \square )&= \frac{(q-1) q^{2g}}{2\pi i} \oint _{|u| = r_1} \sum _{n=0}^{[\frac{g}{2}]} q^{-3n} \sum _{m=g-n+1}^{g-1} \frac{1}{q^{2m} u^{m+1}} \sum _{\square \ne V\in \mathbb {A}^{+}_{\le 2n-2g-1+2m}}\delta _{V;2n}(u) du, \\ \tilde{\mathcal S}_{g,4}^\mathrm{e}(V\ne \square )&= \frac{q^{2g}}{2\pi i} \oint _{|u| = r_1} \sum _{n=0}^{[\frac{g}{2}]} q^{-3n} \sum _{m=g-n}^{g-1} \frac{1}{q^{2m} u^{m+1}} \sum _{\square \ne V\in \mathbb {A}^{+}_{2n-2g+2m}}\delta _{V;2n}(u) du \end{aligned}
with $$r_{1} < 1$$. Now, using (7.2) to bound $$\delta _{V;2n}(u)$$ and trivially bounding the sum over V, we can get that $$\tilde{\mathcal S}_{g,j}^\mathrm{e}(V\ne \square ) \ll q^{g\varepsilon }$$ for $$1 \le j \le 4$$, so $$\tilde{\mathcal S}_{g}^\mathrm{e}(V\ne \square ) \ll q^{g\varepsilon }$$. The calculations for $$\tilde{\mathcal S}_{g-1, j}^\mathrm{e}(V\ne \square )$$ are similar to the previous ones and we will not repeat it. Similarly, we obtain that $$\tilde{\mathcal S}_{g-1,j}^\mathrm{e}(V\ne \square )\ll q^{g\varepsilon }$$ for $$1 \le j \le 4$$, so $$\tilde{\mathcal S}_{g-1}^\mathrm{e}(V\ne \square ) \ll q^{g\varepsilon }$$.

## 8 Proof of Theorem 2.1

In this section we give a proof of Theorem 2.1 by combining the results from the previous sections. From Sect. 4, we have
\begin{aligned} \sum _{D\in \mathcal H_{2g+1}} L(1,\chi _{D}) =&\mathcal M_{g} + \mathcal M_{g-1} + \mathcal S_{g}(V=\square ) + \mathcal S_{g-1}(V=\square )\\&+ \mathcal S_{g}(V\ne \square ) + \mathcal S_{g-1}(V\ne \square ). \end{aligned}
By Proposition 7.1, $$\mathcal S_{g}(V\ne \square )\ll q^{g\epsilon }$$ and $$\mathcal S_{g-1}(V\ne \square )\ll q^{g\epsilon }$$. By Proposition 5.1 and 6.1, we have
\begin{aligned}&\mathcal M_{g} + \mathcal M_{g-1} + \mathcal S_{g}(V=\square ) + \mathcal S_{g-1}(V=\square ) = \frac{q^{g+1}}{\zeta _{\mathbb {A}}(2)} \frac{1}{2\pi i} \oint _{|u| = r} \alpha (u) du \\&\quad - \frac{q^{g+1}}{\zeta _{\mathbb {A}}(2)} \frac{1}{2\pi i} \oint _{|u| = R} \alpha (u) du + c_{1} q^{\frac{g}{3}} + O(q^{g\epsilon }), \end{aligned}
where $$r<q^{-2}$$, $$1< R < q$$ and $$\alpha (u)=\frac{(q^{g-2[\frac{g}{2}]} (1-u) u^{[\frac{g-1}{2}]} + (1-q^2 u) u^{[\frac{g}{2}]})\mathcal C(u)}{(1-u)(1-qu)(1-q^2 u) u^{g}}$$. Recall that $$\mathcal C(u)$$ has an analytic continuation for $$|u|<q$$ and $$\mathcal C(1) = 0$$ (see equation (5.2)). Note that the numerator of $$\alpha (u)$$ has a zero at $$u=q^{-1}$$ and $$u=1$$, so $$\alpha (u)$$ has no pole at $$u=q^{-1}$$ and $$u=1$$. Between the circles $$|u|=r$$ and $$|u|=R$$, the integrand $$\alpha (u)$$ only has one simple pole at $$u=q^{-2}$$. Then we have
\begin{aligned} \frac{q^{g+1}}{\zeta _{\mathbb {A}}(2)} \frac{1}{2\pi i} \left( \oint _{|u| = r} \alpha (u) du - \oint _{|u|=R} \alpha (u) du\right) = - \frac{q^{g+1}}{\zeta _{\mathbb {A}}(2)} \mathrm{Res}(\alpha (u); u=q^{-2}). \end{aligned}
Now, by computing the residues of $$\alpha (u)$$ at $$u=q^{-2}$$, we have
\begin{aligned} \mathcal M_{g} + \mathcal M_{g-1} + \mathcal S_{g}(V=\square ) + \mathcal S_{g-1}(V=\square )&= c_{0} q^{2g+1} + c_{1} q^{\frac{g}{3}} + O(q^{g\epsilon }), \end{aligned}
which concludes the proof of Theorem 2.1. $$\square$$

## Notes

### Acknowledgements

We would like to thank an anonymous referee whose comments and suggestions helped to improve the presentation of the paper.

## References

1. 1.
Andrade, J.C.: A note on the mean value of $$L$$-functions in function fields. Int. J. Number Theory 8(07), 1725–1740 (2012)
2. 2.
Andrade, J.C., Jung, H.: Lower order terms in the mean value of $$K_2({\cal{O}})$$-groups in function fields (in preparation)Google Scholar
3. 3.
Andrade, J.C., Keating, J.P.: The mean value of $$L(\frac{1}{2},\chi )$$ in the hyperelliptic ensemble. J. Number Theory 132(12), 2793–2816 (2012)
4. 4.
Artin, E.: Quadratische Körper in Geibiet der Höheren Kongruzzen I and II. Math. Z. 19, 153–296 (1924)
5. 5.
6. 6.
Conrey, J.B., Farmer, D.W., Keating, J.P., Rubinstein, M.O., Snaith, N.C.: Integral moments of $$L$$-functions. Proc. Lond. Math. Soc. 91(1), 33–104 (2005)
7. 7.
Florea, A.: Improving the error term in the mean value of $$L(\frac{1}{2}, \chi )$$ in the hyperelliptic ensemble. Preprint(2015)Google Scholar
8. 8.
Gauss, C.F.: Disquisitiones Arithmeticae. Yale University Press, New Haven (1966)
9. 9.
Goldfeld, D., Hoffstein, J.: Eisentein series of $$\frac{1}{2}$$-integral weight and the mean value of real Dirichlet $$L$$-series. Invent. Math. 80, 185–208 (1985)
10. 10.
Goldfeld, D., Viola, C.: Mean values of $$L$$-functions associated to elliptic, Fermat, and other curves at the center of the critical strip. J. Number Theory 11, 305–320 (1979)
11. 11.
Hoffstein, J., Rosen, M.: Average values of $$L$$-series in function fields. J. Reine Angew. Math. 426, 117–150 (1992)
12. 12.
Jung, H.: A note on the mean value of $$L(1,\chi )$$ in the hyperelliptic ensemble. Int. J. Number Theory 10(4), 859–874 (2014)
13. 13.
Jutila, M.: On the mean value for $$L(1/2,\chi )$$ for real characters. Analysis 1, 149–161 (1981)
14. 14.
Keating, J.P., Snaith, N.C.: Random matrix theory and L-functions at $$s=1/2$$. Commun. Math. Phys. 214(1), 91–110 (2000)
15. 15.
16. 16.
Mazur, B., Wiles, A.: Class fields of abelian extensions of $$\mathbb{Q}$$. Invent. Math. 76, 179–330 (1984)
17. 17.
Mertens, F.: Über einige asymptotische Gesetze der Zahlentheorie. J. Reine Angew. Math. 77, 289–338 (1874)
18. 18.
Rosen, M.: Number Theory in Function Fields, Graduate Texts in Mathematics, vol. 210. Springer, New York (2002)
19. 19.
Sarnak, P.: Class numbers of indefinite binary quadratic forms. J. Number Theory 15(2), 229–247 (1982)
20. 20.
Shintani, T.: Zeta functions associated with the vector space of quadratic forms. J. Fac. Sci. Univ. Tokyo, Sec. 1 A 22, 25–65 (1975)
21. 21.
Siegel, C.L.: The average measure of quadratic forms with given determinant and signature. Ann. Math. 45, 667–685 (1944)
22. 22.
Soundararajan, K.: Nonvanishing of quadratic Dirichlet $$L$$-functions at $$s=1/2$$. Ann. Math. 155(2), 447–488 (2000)
23. 23.
24. 24.
Tate, J.: Symbols in arithmetic. Int. Congr. Math. 1, 201–211 (1970)Google Scholar
25. 25.
Vinogradov, I.M.: On the number of integer points in a sphere. Izv. Akad. Nauk. SSSR Ser. Mat. 27, 957 (1963)
26. 26.
Young, M.P.: The first moment of quadratic Dirichlet $$L$$-functions. Acta Arith. 138(1), 73–99 (2009)