\clearpage \setcounter{section}{0} \setcounter{equation}{0} \renewcommand{\thesection}{S\arabic{section}} \renewcommand{\theequation}{S\arabic{equation}} \renewcommand{\theHsection}{supp.\arabic{section}} \renewcommand{\theHequation}{supp.\arabic{equation}} \pdfbookmark[0]{Supplementary material}{supplement-bookmark} \section*{Supplementary material}\label{sec:supplement} \noindent\begin{tabular}{@{}p{.26\linewidth}p{.68\linewidth}@{}} Main trace theorem & \hyperref[sec:profile-estimates]{S5} gives the analytic estimates. \hyperref[sec:dependencies]{S7} lists their inputs.\\ Fixed-level traces & \hyperref[sec:prime-square]{S6} computes the local constants.\\ Variance and mean & \hyperref[sec:level-one-variance]{S8} proves the variance for smooth cutoffs. \hyperref[sec:sharp-variance]{S9} handles sharp cutoffs and second terms for the mean.\\ Related results & \hyperref[sec:prime-power]{S1} treats extension fields. \hyperref[sec:angles]{S2} studies other angle laws. \hyperref[sec:supp-open]{S3} lists open questions and \hyperref[sec:supp-numerical]{S4} gives numerical checks.\\ \end{tabular} Section, result and equation numbers with the prefix S refer to the supplementary material. We use the article's notation $Q_T$ for the beta-binomial law, $\|\cdot\|_Q$ for the weighted norm, and $P^u$ for the unnormalized count measure. For a field of size $q$ we use the same bias grid with step $\Delta_q=(4\sqrt q)^{-1}$ and write \[ R_\varepsilon(T,q)=\frac Tq\log^3(2q/T) +q^{-1/3+\varepsilon}\max(T,\sqrt q)^{1/4}. \] \section{Prediction over prime-power fields}\label{sec:prime-power} Let $q=p^n$ with $p\ge5$ and $n\ge2$. Choose a nonsingular short Weierstrass equation uniformly over $\F_q$. The isomorphism classes then have weights proportional to $1/\#\operatorname{Aut}_{\F_q}(E)$. Let $P_T$ be the count law for bias $f_t=1/2+t/(4\sqrt q)$, where $t=q+1-\#E(\F_q)$, and $P_T^{\rm o}$ its restriction to ordinary curves ($p\nmid t$), normalized to have mass one. \begin{lemma}[Restricted trace weights in fixed characteristic] \label{lem:extension-smoothing} Let $q=p^n$ with fixed $p$, let $J$ be a fixed finite set of primes containing $p$, and let $A$ be a fixed trace class modulo $M$. For $u=F^{(J)}1_A$ on $|t|<2\sqrt q$ and $1\le T\le q$, \[ \|P^u-\gamma_B Q_T\|_Q^2\ll_{M,J,\varepsilon}R_\varepsilon(T,q). \] Here $F^{(J)}$ omits terms divisible by any prime of $J$, $B=q^{2/3}\max(T,\lceil\sqrt q(\log q)^8\rceil)^{-1/4}$ and $\gamma_B$ is the constant Fourier coefficient of the restricted smooth cutoff. \end{lemma} \begin{proof} Apply Lemma~3.4 with grid step $\Delta_q$. Omitting the factors at $J$ leaves moduli prime to $q$, so all the roots used in the expansion are units. The Fourier shifts from $1_A$ change denominators by factors bounded in terms of $M$. The conductor in the Mellin shift is at most $4q$, and the grid and smoothing estimates apply to the interior lattice, whether or not $2\sqrt q$ is integral. \end{proof} \begin{theorem}\label{thm:prime-power} With absolute implied constants, for $1\le T\le q$, \[ \KL(P_T\Vert Q_T)\ll\sqrt{T/q}\,\log^4(2q/T)+q^{-1/100}\log^7q, \] and for $T\ge q$, \[ \KL(P_T\Vert Q_T)=\tfrac12\log(T/q)+O\bigl(1+\tfrac pq\log T\bigr). \] As $q\to\infty$ through such prime powers, the divergence tends to zero if and only if $T=o(q)$. Moreover, for $1\le T\le q$ and every $\varepsilon>0$, \[ \chi^2(P_T^{\rm o}\Vert Q_T)\ll_\varepsilon R_\varepsilon(T,q)+q^\varepsilon/p . \] For each fixed $p$ the term $q^\varepsilon/p$ can be omitted, with an implied constant depending on $p$ and $\varepsilon$. In both cases $\KL(P_T\Vert Q_T)$ satisfies the same bound with an additional $O(q^{-1/2}\log(q+1))$. \end{theorem} \begin{proof} For ordinary $t$, the number of equations is $(q-1)H(4q-t^2)/2$ \cite[Lemma~2]{KaplanPetrow}. The supersingular probability $\eta$ is at most $(p+23)/(12q)$, since there are at most $(p-1)/12+2$ supersingular $j$-invariants~\cite[Theorem~V.4.1]{Silverman} and $q-1$ equations per $j$~\cite[Lemma~2]{KaplanPetrow}. The beta-binomial bound $Q_T(k)\gg (T+1)^{-3/2}$ and convexity give \[ \KL(P_T\Vert Q_T) \le \log(1+\chi^2(P_T^{\rm o}\Vert Q_T)) +\eta\bigl(\tfrac32\log(T+1)+O(1)\bigr). \] \emph{Short observations.} Set $F(t)=\pi H(4q-t^2)/\sqrt{4q-t^2}$ and take the coefficients of Lemma~3.2 with $q$ in place of $p$. The ordinary masses are $\Delta_q\sigma(f_t)F(t)/(1-\eta)$. For $p\nmid t$, the two simple roots modulo $p$ of $x^2-tx+q$ lift to all powers of $p$, so $b_t(p^j)=1$. Define $\tilde b_t(n)=b_t(n_0)$ for all traces, where $n_0$ is the prime-to-$p$ part of $n$, and let $\tilde F_N(t)=\sum_{n\le N}\tilde b_t(n)/n$. For a reduced $a/d$ with $p\nmid d$, the coefficient of $e(at/d)$ in $\sum_{A0$, the cosine test of Theorem~3.1 detects the integer trace grid when $T\ge cq$, proving necessity of $T=o(q)$. \emph{Sharper estimates for ordinary curves.} Now use $U=\sum_n\tilde b_t(n)n^{-1}\psi(n/B)$ with the smooth cutoff of Theorem~3.1. On ordinary traces $\tilde b_t=b_t=c_t*\chi$, with $\chi$ of conductor at most $4q$. The Mellin shift and hybrid Weyl bound give $|F-U|\ll_\varepsilon q^{1/6+\varepsilon}B^{-1/2}$, which costs $O_\varepsilon(q^{1/3+\varepsilon}/B)$ in squared norm. The Fourier formula with the cutoff inserted gives coefficients $O(\tau(d)d^{-3/2})$ for $p\nmid d\le 2B$. On the interior grid $U=O_\varepsilon(q^\varepsilon)$, since $4q-t^2\ne0$ and the sum of $|b_t(m)|/m$ over $m\le 2B$ prime to $p$ has that bound. Thus (2) applies with $q$ in place of $p$, and (1) bounds the term $U1_{p\mid t}$ in squared norm by $O_\varepsilon(q^\varepsilon\Delta_q(\sqrt q/p+1))$. Take $B=q^{2/3}T^{-1/4}$, center at the mass of the ordinary law, and normalize by $1-\eta$. Below the range of (2), contract by keeping only $T$ flips as in Theorem~3.1. For fixed $p$, apply Lemma~\ref{lem:extension-smoothing} with $J=\{p\}$ to the nonzero trace classes modulo $p$, since $F1_{p\nmid t}=(1-1/p)^{-1}F^{(p)}1_{p\nmid t}$. Convexity then gives the two asserted KL bounds. \end{proof} \begin{corollary}[Legendre family over $\F_q$]\label{cor:legendre-q} Fix a prime $p\ge5$. For $q=p^n$ sample $\lambda$ uniformly in $\F_q\setminus\{0,1\}$ and use the trace of $y^2=x(x-1)(x-\lambda)$ over $\F_q$ for the bias $1/2+t/(4\sqrt q)$. The count law of the ordinary parameters has chi-square divergence $O_{p,\varepsilon}(R_\varepsilon(T,q))$ from $Q_T$ for $1\le T\le q$. As $n\to\infty$ the logarithmic loss of the family tends to zero if and only if $T=o(q)$, and for $T\ge q$ it is $\frac12\log(T/q)+O_p(1+(p/q)\log T)$. \end{corollary} \begin{proof} The prime-field case is Corollary~4.5. The $Y_1(4)$ isogeny remains defined over $\F_q$, so (6) counts rational points of order four there. At ordinary traces the formulas for full rational $2$- and $4$-torsion~\cite[Lemmas~2--4]{KaplanPetrow} and the local identities at 2 express the weights in terms of $F$ and $F^{(2)}$. Remove the factor at $p$ as in Theorem~\ref{thm:prime-power}, then apply Lemma~\ref{lem:extension-smoothing} with $J=\{p\}$ or $\{2,p\}$ and moduli dividing $16p$. The supersingular parameters are roots of a polynomial of degree $(p-1)/2$~\cite[Theorem~V.4.1]{Silverman}, so the ordinary probability is bounded below and the additional KL cost is $O((p/q)\log(T+1))$. This yields the short-length result. Each curve has at most twelve points of order four, so the ordinary Legendre count law is bounded by a fixed multiple of the full ordinary law. Its squared norm for $T\ge q$ is $O_p(1+\sqrt{T/q})$. For the lower bounds, all traces lie in one class modulo 4. The support has at most $\sqrt q+1$ points and the cosine test at frequency $2\pi\sqrt q$ detects the lattice for $T\ge cq$. \end{proof} \subsection{Bounds from the Dirichlet critical-line theorem} The quadratic case of Alp\"oge's theorem \cite{AlpogeAnnouncement,SutherlandVerification} allows us to replace $R_\varepsilon(T,q)$ in Theorem~\ref{thm:prime-power} and Corollary~\ref{cor:legendre-q} by \[ R_\varepsilon^*(T,q)=\frac Tq\log^3(2q/T) +q^{-1/2+\varepsilon}\max(T,\sqrt q)^{1/4}. \] Apply the balance and thinning in Proposition~7.1 with $q$ in place of $p$. The Mellin shift gives the same squared tail $O_\varepsilon(q^\varepsilon/B)$ with fixed Euler factors omitted. Add the varying-characteristic and supersingular terms of Theorem~\ref{thm:prime-power}. \section{Hecke angles, Kloosterman angles and general families}\label{sec:angles} Proposition~2.1 bounds loss using moments up to order $\sqrt T$, and Lemma~2.2 gives lower bounds from the support size. \subsection{Gaussian Hecke angles} Let $\xi((\alpha))=(\alpha/|\alpha|)^4$ over $\mathbb Q(i)$, and draw a prime ideal of norm at most $X$ with weight $w_{\mathfrak p}=\log N\mathfrak p/\Theta(X)$, where $\Theta(X)=\sum_{N\mathfrak p\le X}\log N\mathfrak p$. Use the bias $(1+\Re\xi(\mathfrak p))/2$. Write $A_X^{(T)}$ for this word law. The reference is $B_{\mathrm{KT}}^{(T)}=B_{1/2,1/2}^{(T)}$. The moments of the Hecke-angle law in Proposition~2.1 are $\sqrt2\Re M_m(X)$, where $M_m(X)=\sum_{\mathfrak p}w_{\mathfrak p}\xi(\mathfrak p)^m$. Write $\log^+ x=\max(0,\log x)$. \begin{theorem}\label{thm:hecke} For sufficiently large $X$, unconditionally, \[ \tfrac12\log^+\!\left(T(\log X)^2/X^2\right)-O(1) \le \KL(A_X^{(T)}\Vert B_{\mathrm{KT}}^{(T)}) \le \tfrac12\log^+(T/X^2)+\log\log X+O(1). \] Thus for $T\ge X^2$ the loss is $\tfrac12\log(T(\log X)^2/X^2)+O(1)$. If $1/2<\beta<1$ and all $L(s,\xi^m)$, $m\ge1$, are zero-free in $\Re s>\beta$, then \[ \KL(A_X^{(T)}\Vert B_{\mathrm{KT}}^{(T)}) \ll_\beta \sqrt T\,X^{2\beta-2}\log^4(X(2+T)). \] In particular the loss tends to zero for $T\le X^{4(1-\beta)-\varepsilon}$ with fixed $\varepsilon>0$. \end{theorem} \begin{proof} Inert and ramified prime ideals have total weight $O(X^{-1/2})$. For distinct split prime ideals, unique factorization prevents their generators from having $\alpha\bar\gamma$ equal to a unit times a rational integer. After rotation by a unit, its argument lies in $[-\pi/4,\pi/4]$ and $|\Im(\alpha\bar\gamma)|\ge1$. Since $|\alpha\bar\gamma|\le X$, the angles $4\arg\alpha$ are spaced $\gg 1/X$. The dual large sieve~\cite{Montgomery} bounds the squared moment sum over an interval of $L$ modes by $(L+X)\sum_{\mathfrak p}w_{\mathfrak p}^2\ll (L+X)\log X/X$. Apply this on blocks of length $\lceil\sqrt{T+1}\rceil$ in Proposition~2.1. Including the inert and ramified ideals gives $\chi^2\ll\log X(1+\sqrt T/X)$. Take $\KL\le\log(1+\chi^2)$. The support bound uses $O(X/\log X)$ prime ideals. For the zero-free estimate the finite conductor is fixed and the archimedean parameter is $O(m)$, giving $O(\log(2+m+|t|))$ zeros per unit height interval. In the explicit formula~\cite[pp.~282--285]{Rajan} use a half-integer cutoff and height $H\asymp X$ at distance $\gg1/\log(X+m+2)$ from the zero ordinates. Moving to $(1-\beta)/2$ costs $O_\beta((X^{(1-\beta)/2}+X/H)\log^2(X+m+2))$ on the vertical and horizontal contours. The zeros contribute $O_\beta(X^\beta\log^2(X+m+2))$ and the prime powers $O(\sqrt X\log^2 X)$. Thus $M_m(X)\ll_\beta X^{\beta-1}\log^2(X(2+m))$. Sum the squares with the weights of Proposition~2.1. \end{proof} \begin{proposition}\label{prop:hecke-short} For every $\varepsilon>0$, the Gaussian Hecke loss tends to zero unconditionally and uniformly for $1\le T\le X^{6/5-\varepsilon}$. \end{proposition} \begin{proof} Choose $0<\tau<3/5$ and $06/5-\varepsilon$. Add a nonnegative smooth compactly supported radial weight $\Phi(N\mathfrak p/Y)$ to the moment, denoting the normalized result by $M_m^\Phi(Y)$. For a fixed smooth even angular test $g$ of compact support with $\widehat g(0)>0$, Parseval and the sector variance bound \cite[Corollary~5]{HLR} give $\sum_{m\ne0}|\widehat g(m/Y^\tau)|^2|M_m^\Phi(Y)|^2=o(1)$. Thus the unweighted square sum up to $\delta Y^\tau$ is $o(1)$ for some fixed $\delta>0$. In Proposition~2.1 the remaining modes cost $O(T\exp(-C Y^{2\tau}/T))$ for some $C>0$, using $|M_m^\Phi|\le1$. The smoothed divergence is $o(1)$ uniformly for $Y\ge X^c$. For the interval $(Y/2,Y]$ take $\Phi\ge1$ on $[1/2,1]$ and $\int\Phi\le(1+\eta)/2$. The prime ideal theorem bounds the smooth to sharp mass ratio by $1+\eta+o(1)$. This also bounds the ratio of the sharp likelihood to the smooth likelihood, so the squared norm of the sharp likelihood has upper limit at most $(1+\eta)^2$. Let $\eta\to0$ and combine the intervals down to $Y_0\asymp X^c$ by convexity. The primes below $Y_0$ have mass $O(X^{c-1})$ and divergence $O(\log X)$ by the large sieve bound since $\sqrt T=o(Y_0)$. \end{proof} \subsection{Kloosterman angles} For an odd prime $p$, choose $c$ uniformly in $\F_p^\times$, and let $\theta_c\in[0,\pi]$ satisfy \[ \sum_{x\in\F_p^\times} e_p(x+c/x) =2\sqrt p\cos\theta_c . \] Here $e_p(t)=\exp(2\pi i t/p)$ for an integer representative of $t\in\F_p$. Use bias $(1+\cos\theta_c)/2$ and write $A_p^{(T)}$ for its word law. The reference is $B_{\rm ST}^{(T)}=B_{3/2,3/2}^{(T)}$. \begin{lemma}[One bias against the Sato--Tate reference]\label{lem:one-bias} If $D_T(f)$ is the KL divergence of $T$ flips of bias $f$ from $B_{\rm ST}^{(T)}$, then uniformly for $f\in[0,1]$, \[ D_T(f)=\tfrac52\log(T+1)-\log\bigl((1+Tf)(1+T(1-f))\bigr)+O(1). \] \end{lemma} \begin{proof} For the reference count law, the gamma ratios give \[ Q_T(k)\asymp (T+1)^{-2}\sqrt{(k+1)(T-k+1)}. \] Apply the two expected logarithm estimates and the entropy estimate in the proof of Lemma~2.2. The identity $(1+Tf)(1+T(1-f))=T+1+Tv$, where $v=Tf(1-f)$, gives the stated form. \end{proof} \begin{theorem}\label{thm:kloosterman} For $T\ge1$, with absolute constants, \[ \begin{aligned} \KL(A_p^{(T)}\Vert B_{\rm ST}^{(T)}) &\le \chi^2(A_p^{(T)}\Vert B_{\rm ST}^{(T)})\ll (T+1)^{3/2}/p,\\ \KL(A_p^{(T)}\Vert B_{\rm ST}^{(T)}) &\ge\tfrac12\log(T+1)-\log(p-1)-O(1). \end{aligned} \] For $p^{2/3}\le T\le e^{\sqrt p}$, \[ \KL(A_p^{(T)}\Vert B_{\rm ST}^{(T)}) \le \tfrac12\log(T/p^{2/3})+O(1). \] \end{theorem} In particular, the loss tends to zero for $T=o(p^{2/3})$ and diverges if $T/p^2\to\infty$. \begin{proof} The $m$th moment is $(p-1)^{-1}\sum_c U_m(\cos\theta_c)$. Katz bounds the sum by $(m+1)\sqrt p/2$~\cite[Example~13.6]{Katz}. Indeed, it is, up to the factor $\pm p^{-m/2}$, the trace sum of $\operatorname{Sym}^m\mathrm{Kl}_2$ on $\mathbb G_m$. For $m\ge1$, the $SL_2$ monodromy gives $H_c^2=0$~\cite[Theorem~11.1]{Katz}. The space $H_c^1$ has dimension at most $(m+1)/2$ \cite[Theorem~0.2]{FuWan} and weights at most $m+1$~\cite{Deligne}. Proposition~2.1 sums the squared moment bound, and Lemma~2.2 gives the lower bound since the support has at most $p-1$ points. For the intermediate range put $S=\lfloor p^{2/3}\rfloor$. The divergence $\chi^2$ at length $S$ is bounded, so the true count mass $a_S(k)$ satisfies $a_S(k)\le b_S(k)+\sqrt{b_S(k)\chi^2}$ for the reference mass $b_S(k)$. At $0$ and $S$, $b_S(k)=O(S^{-3/2})$. Therefore $a_S(k)=O(p^{-1/2})$ at these counts, and $(1-1/S)^S\ge1/4$ bounds the bias mass of $\min(f,1-f)<1/S$ by $\eta=O(p^{-1/2})$. Outside this set both ratios $(1+Tf)/(1+Sf)$ and $(1+T(1-f))/(1+S(1-f))$ are at least $T/(2S)$. Everywhere they are at least one. Lemma~\ref{lem:one-bias} now gives $\E(D_T(f)-D_S(f))\le \tfrac12\log(T/S)+O(1)+2\eta\log(T/S)$. The mixture loss at $T$ is $\E D_T(f)-I(f;W_T)$, where $W_T$ is the length-$T$ word. Since the information is nondecreasing in $T$ and the loss at $S$ is bounded, the same upper bound holds for the loss at $T$. Its last term is bounded for $T\le e^{\sqrt p}$. \end{proof} The normalized Gauss sums of nontrivial characters give the same vanishing-loss range $T=o(p^{2/3})$ against the uniform-angle reference. Orthogonality gives hyper-Kloosterman sums with moments $O(m/\sqrt p)$~\cite[Scholium~4.0.1 and Theorem~4.1.1]{Katz}. The Wasserstein estimates of Kowalski--Untrau and Rahimi~\cite{KU,Rahimi} also imply total-variation convergence in this range, using affinity $\cos^T((\theta-\phi)/2)$ for the product laws at angles $\theta,\phi$. Proposition~2.1 controls logarithmic loss. \subsection{One-parameter families of elliptic curves} Let $\F_q$ have characteristic at least $5$. Let $U$ be an open subset of $\mathbb P^1$ over $\F_q$ whose complement has $r$ geometric points. Let $E\to U$ be an elliptic curve with nonconstant $j$-invariant. For $n\ge1$ choose $x$ uniformly in $U(\F_{q^n})$, put $a_x=q^n+1-\#E_x(\F_{q^n})$, and use the bias $1/2+a_x/(4q^{n/2})$. Write $A_{E,n}^{(T)}$ for the word law. \begin{proposition}\label{prop:family} If $q^n\ge2r$ then, with absolute constants, \[ \begin{aligned} \chi^2(A_{E,n}^{(T)}\Vert B_{\rm ST}^{(T)}) &\ll (r-2)^2(T+1)^{3/2}q^{-n},\\ \KL(A_{E,n}^{(T)}\Vert B_{\rm ST}^{(T)}) &\ge\tfrac12\log(T+1)-\tfrac n2\log q-O(1). \end{aligned} \] \end{proposition} For fixed $r$, the moment bound gives vanishing loss at $T=o(q^{2n/3})$, and the trace lattice gives divergence when $T/q^n\to\infty$. For Legendre, the class-number calculation in Corollary~\ref{cor:legendre-q} closes the gap in fixed characteristic. \begin{proof} The fibre cohomology sheaf $\mathcal F$ has rank two and weight one. Nonconstant $j$ gives an affine base and geometric monodromy $SL_2$~\cite[Lemme~3.5.5]{Deligne}. Semistable reduction after an extension of degree dividing 24 gives tameness at the $r$ missing points. In particular $r\ge3$, since the tame fundamental group of the affine line is trivial and that of $\mathbb G_m$ is abelian. For $m\ge1$, $\operatorname{Sym}^m\mathcal F$ is geometrically nontrivial and irreducible. The Euler--Poincar\'e formula \cite[2.3.1]{Katz} gives $\dim H_c^1=(m+1)(r-2)$, with the other compactly supported cohomology zero. Its weights are at most $m+1$~\cite[Th\'eor\`eme~3.3.1]{Deligne}, so the trace formula gives \[ \Bigl|\sum_{x\in U(\F_{q^n})}U_m(a_x/(2q^{n/2}))\Bigr| \le(m+1)(r-2)q^{n/2}. \] Divide by $|U(\F_{q^n})|\ge q^n/2$ and apply Proposition~2.1. The lower bound follows from Lemma~2.2 because there are at most $4q^{n/2}+1$ integer traces. \end{proof} \section{Open questions for the supplementary families}\label{sec:supp-open} The short-length constant for ordinary curves over $\F_{p^n}$, $n\ge3$, and its dependence on $p$ and $n$ remain open. Stronger sector variance bounds could improve the Gaussian Hecke range. For Kloosterman angles and one-parameter families, weighted square sums of Frobenius moments through degree $\sqrt T$ could narrow the unresolved intervals $[p^{2/3},p^2]$ and $[q^{2n/3},q^n]$, respectively. \section{Numerical checks}\label{sec:supp-numerical} The ancillary file \texttt{paper\_checks.json} records prediction losses and checks of local constants. The variance samples are in \texttt{variance\_check.json}. The shortest run has cutoffs $7,9,12$ and therefore reaches at most the first nonzero level-one cusp-form space. In samples near $10^5$ and $10^6$, comparable lengths $T$ give comparable variances even when $T/p$ differs by a factor of ten, leaving the leading term in Theorem~\ref{thm:level-one-variance} unresolved at these sizes. \section{Estimates for the short-length profile}\label{sec:profile-estimates} We use the notation of \hyperref[lem:short-profile]{Lemma~6.2}. Let $g$ be a trace weight and $g_B$ its smooth cutoff. Write $\gamma_B$ for the cutoff Fourier coefficients, extended with period one, and $Z_p,Z_B$ for the masses of $P^g,P^{g_B}$. \begin{lemma}[The averaged class-number tail]\label{lem:averaged-tail} For $0<\varepsilon<1$, outside $O_{g,\varepsilon}(X^{1-\varepsilon/4})$ primes in $(X,2X]$, the bound \begin{equation}\label{eq:supp-averaged-class-tail} \Delta_p\sum_{t^2<4p}|g(t)-g_B(t)|^2 +\|P^g-P^{g_B}\|_Q^2\ll_{g,\varepsilon}p^\varepsilon/B \end{equation} holds for all $B\ge1$ and $1\le T\le p$. \end{lemma} \begin{proof} With $-D_t=d_t r_t^2$, the discriminant count and Heath--Brown bound in Section~6 of the article give $\sum_{X0$, outside $O_{g,\delta_0}(X^{1-\xi})$ primes in $(X,2X]$, uniformly for $p^{-\delta_0}\le c=T/p\le1/2$, \[ \|P^g-Z_pQ_T\|_Q^2 =\mathcal C_{A_p}^g(c)+O_{g,\delta_0}(c^{3/2}+cp^{-\nu}). \] On these primes $Z_p$ differs from the complete constant Fourier coefficient by $O_{g,\delta_0}(p^{-\nu})$. \end{lemma} \begin{proof} On $X0. \] Take $\varepsilon$ small relative to $\rho$. The squared tail \eqref{eq:supp-averaged-class-tail} divided by $c$ is $O(X^{-\rho+\varepsilon})$. For the mass, sum the Abel bound $O((\sqrt p\|\beta\|)^{-1})$ at nonintegral frequencies against $\gamma_B$, and add the $O_g(p^{-1/2})$ Riemann-sum error at zero. This gives $|Z_B-\gamma_B(0)|\ll_{g,\varepsilon}p^{-1/2}B^{1/2+\varepsilon}$, whose square saves a power since $B/(pc)\ll X^{-3\rho}$. Only fixed denominators shift to zero, where the coefficient tail is $O_g(B^{-1/2})$. Equation~\eqref{eq:supp-averaged-class-tail} gives the claim for $Z_p$. Use $h=1/T$. On $w_\phi<\sqrt T$ only traces in two intervals of length $O(T/\sqrt p)$ contribute appreciably, since $T^2/p$ grows by a power. The edge argument of Lemma~3.3 bounds the squared norm by $O(\sqrt T/p)$ times the local sum of $|g_B(t)|^2$; the subtracted sine costs $O_g(c^{3/2})$. For $c\ge p^{-\rho}$, Lemma~3.3 with the constant included gives $O_{g,\varepsilon}(c^{3/2}+p^\varepsilon B\sqrt T/p)$, with $B/\sqrt T\ll X^{-\rho/2}$. For $cD_0$. Write the Gaussian as $e^{-vH^2\beta^2}$ with $v$ in a fixed compact positive interval. Open $S(a,an;d)=\sum_{b\bmod d}^{*}e((a^2\bar b+bn)/d)$. The coefficient at frequency $b/d$ in $n$ is \[ C_d e(\alpha s) \sum_{\substack{a\in\mathbf Z,\ (a,d)=1\\a/d+\alpha\ne0}} e(a^2\bar b/d)e(as/d)e^{-vH^2(a/d+\alpha)^2}. \] After removing $C_de(\alpha s)$, Parseval bounds the square mean over a period by $O(d/H)$, also for the $v$ derivative. Since $d\le2B\ll\sqrt X$, the additive large sieve \cite[Theorem~1]{MontgomeryVaughan} and integration over $|s|\le3\sqrt X$ bound the integer sum of the high squared integrals by \[ \ll_{g,\varepsilon}(X+B^2)\sqrt X \sum_{d>D_0}d^{-4}d\frac{d}{H} \ll_{g,\varepsilon}\frac{X^{3/2}}{H D_0}. \] The derivative bound and the fundamental theorem of calculus allow the supremum over $v$. The angular factor is $O(W/X)$ since $w^2d\phi=w|ds|$. Restricting to the target prime class, summing the $W$ bands and dividing by $X(U/X)$ gives $O_{g,\varepsilon}(X^{-\rho+\varepsilon})$. Sum over shifts by the triangle inequality. Markov over the $O(\log X)$ length bands gives $O_{g,\delta_0}(cp^{-\nu})$ outside a power-saving exceptional set. \emph{Comparison with the diagonal.} For $d>D_0$, the shifted Gaussian sum is $O(d\sqrt T/w)$ since $w/\sqrt T\ll X^{\delta_0/2}$. Weil's bound gives high diagonal $O_{g,\varepsilon}(p^\varepsilon\sqrt c/D_0)$ after integration. Cauchy--Schwarz also controls coincidences between low and high modes of different shifts. The low diagonal is $O_g(c\log^3(2/c))$ by Lemma~3.3. Combining the bounds identifies the bulk heat norm with the diagonal up to $O(cp^{-\nu})$. The coefficient square sum modulo one is bounded, so the translate sum $O(1+\sqrt{c/(y(1-y))})$ at $y=(1+\cos\phi)/2$ bounds the diagonal edge by $O_g(c^{3/2})$. The cutoff-to-complete squared coefficient error is $O_g(B^{-1}\log^4(2B))$ by Weil and the $h_d$ tail. The same bound holds with fixed shifts and after angular integration, so Cauchy--Schwarz saves a power since $(Bc)^{-1}\ll X^{-\rho}$. Here $w^2=16py(1-y)$ and $w^2|d\phi|/(2\pi p)=\sigma(y)|dy|$ give the diagonal $\mathcal C_{A_p}^g(c)$. The multiplier comparison in the proof of Lemma~6.2 has relative error $O(T^{-1/2}\log^3p)$ against the heat bound $O_g(c\log^3(2p))$. The remaining terms are negligible by Gaussian decay and $|m_{g_B,p}(m)|\ll_{g,\varepsilon}p^\varepsilon(m+1)$. Project off the first sine in \eqref{eq:odd-heat} and use \eqref{eq:supp-averaged-class-tail} and Cauchy--Schwarz to restore the full centered count measure. \end{proof} \begin{lemma}[Reduction at short weight cutoffs]\label{lem:endpoint-heat} Fix $\lambda>0$, $1/60$. Put $U=\lambda p^{2a}$, $c=U/p$, $B=X^{3/4-a/2}$ and $D_+=X^{1/2-a+\omega}$. In \eqref{eq:odd-heat} use $h=1/U$. Write $V_+$ for the nonzero-frequency Gaussian sum \[ V_+(\phi)=2\pi w\sum_{\beta\ne0}\gamma_B^+(\beta)e(\beta s) e^{-2\pi^2w^2\beta^2/U},\qquad w=2\sqrt p\sin\phi,\quad s=2\sqrt p\cos\phi . \] Here $\gamma_B^+$ includes only the terms with original denominator $d\le D_+$ before the shifts by the trace selectors. Let $\chi_X(\phi)=\chi(X^\omega w/\sqrt X)$, where $\chi$ is smooth with $0\le\chi\le1$, equal to zero up to one and to one from two onwards. For every fixed $J>0$, outside $O_{g,\lambda,a,\omega,J}(X(\log X)^{-J})$ primes in $(X,2X]$, \[ \|\mathcal D-\chi_X V_+\|_{\rm ang}^2 +|Z_B-\gamma_B(0)|^2\ll_{g,\lambda,a,\omega,J}c(\log X)^{-J}. \] The same assertion holds at $a=1/6$ with $B=X^{2/3-\rho}$ for any sufficiently small fixed $\rho>0$. \end{lemma} \begin{proof} \emph{The angular endpoints.} Take $W_0=X^{1/2-a+\nu}$ with small $\nu>0$, and use the finitely many shifted components $\beta=m/d+\alpha$ of S5.2. Near $\phi=0$ with $wX^{C_1}$ for large $C_1$. Enlarge the angular integral to a common interval $0\le\eta\le C_2 X^\nu$ before averaging the integers. The squared prefactor in the angular norm, including $d\phi=d\eta/\sqrt U$, is $O(U^{-3/2})$. Thus the mean squared edge norm of a denominator block divided by $c$ is \[ \ll X^{1-5a+O(\nu+\varepsilon)} \frac{(1+D^2/N)\min(1,D/L)}{DL} \ll X^{O(\nu+\varepsilon)} \left(X^{-a}+\frac D{X^{1/2+a}}\right). \] This saves a power on summing $D\le2B$, since the exponent of $B$ is strictly below $1/2+a$, with gap $\rho$ at $a=1/6$. We may restrict the sum to the primes in the designated class. Markov's inequality gives a power-saving exceptional count. The cutoff $\chi_X$ is zero on $w\sqrt X$, replace the period estimate by the preceding Ramanujan argument. At each $s$, summing over the square congruence classes gives $O_{g,\varepsilon}(d^{2+\varepsilon}/H)$ since $1\le d/H\le d$. The same bound applies to the polynomial and derivative weights. Integration over $O(\sqrt X)$ and the large sieve now give $O_{g,\varepsilon}(D^{1+\varepsilon}/X^{1/2+a})$ after normalization. The angular factor is $O(W/X)$ in both estimates. Taking a supremum over the Gaussian parameter leaves the integer interval fixed. Take $N=X$ for $d>D_+$. The bound up to $\sqrt X$ is $O(X^{1/2-a}/D)$, and above $\sqrt X$ the new bound saves a power since $D\le2B$. With $N\ll W^2$, the bounds on $D\le W$, $W\sqrt X$ are respectively $O(W/\sqrt X)$, $O(X^{-a})$ and $O(B^{1+\varepsilon}/X^{1/2+a})$. This removes the bands $W\ll X^{1/2-\omega}$ and also bounds the polynomial corrections by their squared prefactors $O_A(X^{-2\nu})$ times powers of $\log X$ after normalization by $c$. These bounds apply to the full sum and to $d\le D_+$. Markov's inequality gives the asserted precision and exceptional count. The first sine coefficient of $\mathcal D$ is a constant multiple of $\sqrt p\,e^{-1/(2U)}(Z_B-\gamma_B(0))$. Projecting onto $\sin\phi$ therefore gives the mass assertion once the projection of $\chi_X V_+$ is power-small. Set $v=p/X$ and $u=s/\sqrt X$. After division by $\sqrt p$, the projection of each frequency is an integral in $u$ with phase $e(\sqrt X\beta u)$ and smooth amplitude proportional to $\chi(X^\omega\sqrt{4v-u^2})\sqrt{4v-u^2}/v$ times the Gaussian. It extends by zero and each differentiation in $u$ costs only $O(X^{2\omega})$ times a weaker Gaussian. Since each nonzero $\sqrt X|\beta|\gg_g X^{a-\omega}$, repeated integration by parts gives arbitrary power savings, also after summing the frequencies. This proves the lemma. \end{proof} \begin{lemma}[The endpoint for fixed trace weights]\label{lem:sixth-endpoint} Fix a trace weight $g$, a unit class $p\bmod M$ as in Section~6 of the article, and $\lambda>0$. Put $U=\lambda p^{1/3}$ and $c=U/p$. For some $\xi>0$, outside $O_{g,M,\lambda}(X^{1-\xi})$ primes in the class in $(X,2X]$, \[ \sum_{m\ge1}e^{-(m+1)^2/U}m_{g,p}(m)^2 =\mathcal C^g_{A_p}(c)+O_{g,M,\lambda}(cX^{-\xi}). \] On the same primes the mass differs from its complete constant Fourier coefficient by $O_{g,M,\lambda}(X^{-\xi})$. \end{lemma} \begin{proof} \emph{The class-number remainder with omitted factors.} Take $B=X^{2/3-\rho}$ for a small fixed $\rho>0$. Add a bump supported on $(1,2)$ to the smooth cutoff $\psi$ to impose $\widehat\psi(-1/2)=0$. By linearity take $g=1_{\mathcal A}F^{(J)}$ and put $P_J=\prod_{\ell\in J}\ell$. For $D_t=|d_t|r_t^2$ let $k_\ell=v_\ell(r_t)$, $\epsilon_\ell=\chi_{d_t}(\ell)$ and $R_0=\prod_{\ell\in J}\ell^{2k_\ell}$. Dropping the factors at $J$ from $C_t$ leaves $C_t^*$ with $C_t^*(s)=(r_t/\sqrt{R_0})^{1-2s}C_t^*(1-s)$ by divisor substitution. Thus $L_t^*=L(s,\chi_{d_t})C_t^*(s)$ obeys the odd functional equation at conductor $D'_t=D_t/R_0$, \[ (D'_t/\pi)^{(s+1)/2}\Gamma((s+1)/2)L_t^*(s) =(D'_t/\pi)^{(2-s)/2}\Gamma((2-s)/2)L_t^*(1-s). \] The original omitted series is $L_t^*(s)\prod_{\ell\in J} (1-\epsilon_\ell\ell^{-s})$. Shifting its cutoff integral past the residue $F^{(J)}$ and applying the equation gives \[ F^{(J)}(t)-F_B^{(J)}(t)=(D'_t/\pi)^{-1/2} \sum_{(n,P_J)=1}\sum_v b_t(n)a_{\boldsymbol\epsilon}(v)\mathcal J(\pi nv B/D'_t), \] where $\widehat{\mathcal J}(s)=-\widehat\psi(-s) \Gamma((1+s)/2)/\Gamma(1-s/2)$ and the coefficients in $v$ are given by the absolutely convergent expansion \[ \sum_v a_{\boldsymbol\epsilon}(v)v^{-s} =\prod_{\ell\in J}\frac{1-\epsilon_\ell\ell^{s-1}} {1-\epsilon_\ell\ell^{-s}} \qquad(\Re s>0). \] Only primes in $J$ occur in $v$, with exponents at least $-1$. The absolute Dirichlet series is bounded for each $\Re s=\sigma>0$. Mellin shifts make $\mathcal J$ and its logarithmic derivatives rapidly decreasing at infinity and bounded at zero, so $n\ll_J X^\varepsilon D'_t/B0$. The pole at $1/2$ is canceled by $\widehat{\mathcal J}(1/2)=0$. The resulting bound is $O_{M,J,\varepsilon}((D'_t)^{-1/2}X^\varepsilon)$. Each selector coefficient is $O_{M,J}(1/R)$, so the zero frequency together with its Taylor corrections costs $O_{M,J,\varepsilon}(X^{-1+\varepsilon})$ in squared norm. On a band $w\asymp W\ge W_0$, Taylor expand the smooth conductor factor at $t=s=2\sqrt p\cos\phi$ along with the heat kernel. Here $D_t/w^2=1+O(r\log X)$ on the Gaussian window and $r=\sqrt p/(w\sqrt U)\ll X^{-\nu}$. The logarithmic derivative bounds give the polynomial Gaussian terms and negligible remainder of S5.3. For the other modes $d\ll X^\varepsilon W^2/(R_0B)\ll\sqrt X$, first apply weighted Cauchy--Schwarz over the shifts. The square is bounded by $O_{M,J}(1/R)$ times the sum of the squares at each shift, so the $p$-dependent selector coefficients have dropped out. At each fixed shift and smooth parameters $w/W,p/X$, open the Kloosterman sums and use the additive large sieve with cost $O(X)$ in the integer replacing $p$. The $s$ integral of the squared numerator sum costs $O(\sqrt X)$ times its period mean, since the shift is common to its terms and $d\le\sqrt X$. For $H=W/\sqrt U$, the averaged Gaussian count is \[ \frac1R\sum_{j\bmod R}\ \sum_{m/d+j/R\ne0} e^{-C H^2(m/d+j/R)^2}\ll d/H . \] Indeed the shifted grid is $\operatorname{lcm}(d,R)^{-1}\mathbf Z$ with multiplicity $(d,R)$, and the zero term is excluded. Polynomial Gaussian corrections obey the same bound with a smaller $C>0$. Taking suprema in the two smooth parameters uses the same bounds for their first and mixed derivatives. The angular factor $W/X$, the prime normalization, and summation in $d$ give squared norm $O_\varepsilon(X^\varepsilon B^{-1} W/(H\sqrt X)) =O_\lambda(cX^{-\xi})$ on average. This also bounds the Taylor corrections. Sum over the $O_J((\log X)^{|J|})$ patterns and the fixed components of $g$. Markov's inequality restores the full weight with a power saving off a power-saving exceptional set. This also controls the larger denominators with their original phases. Take $B_1=X^{2/3+\rho}$. The positive kernel $G(\phi-\theta_t)+G(\phi+\theta_t)$ has bounded integral and sum $O(\sqrt X)$ over $t$, by angle spacing. Cauchy--Schwarz and S5.1 give squared angular error $O(cX^{-\xi})$ at $B_1$, and thus the same bound for the difference of cutoffs. In its part with $d\le2B$, the coefficient difference is $O(d^{-2}\min(1,\sqrt{d/B}))$ before the Kloosterman sum. The edge estimate in the proof of S5.3 bounds these blocks, as does its interior estimate for $d>D_+$. For $d\le D_+$ the latter costs $X^{1/3}/d$ after normalization, with an extra factor $d/B$ from the squared coefficient difference. The constant mode leaves only its nonzero integer translates after first-sine projection, as in S5.3. Subtracting this low-denominator part bounds the full block $d>2B$ of $g_{B_1}$ by $O(cX^{-\xi})$ in squared angular norm off a power-saving exceptional set. This comparison applies to each fixed shifted component, using its original denominator before the shift. \emph{Products at nearby trace frequencies.} Use the reduction S5.3 with $D_+=X^{1/3+\omega}$. Let $A(n,v)$ be the signed off-diagonal with $p$ replaced by $n$ in the phases and $p/X$ by $v$ in the weights. For each fixed choice of four shifts, the restrictions in Lemma~6.2 give $\beta_i=m_i/d_i+\kappa_i/M=A_i/(Md_i)$ with $A_i=Mm_i+\kappa_i d_i$, $d_i=X^{1/3+O(\omega+\varepsilon)}$, $0<|A_i|\ll_M X^{O(\omega+\varepsilon)}$, and \[ 0<|h|,|h'|\le X^{1/6+O(\omega+\varepsilon)},\qquad h=A_1d_2-A_2d_1,\quad h'=A_3d_4-A_4d_3. \] Use denominators prime to the omitted sets. Their scalar coefficients are $d^{-2}\prod_{\ell\mid d}(1-\ell^{-2})^{-1}$ up to relative $O(\sqrt{d/B})$ by Lemma~3.2, since an omitted $h_d$ factor at $s=1$ equals one. The unsigned bound of Lemma~6.2, $O(X^{-4/3+O(\omega+\varepsilon)})$, absorbs this error, including one $v$ derivative. At coincident frequencies in $n$, Parseval on $[d_1,d_2]$ and Weil's bound give squared coefficient mass $O(X^\varepsilon(d_1d_2)^{-3})$ per pair. At $(d_1,d_2)\asymp G$ there are $O(X^{1/2+O(\omega+\varepsilon)}/G)$ pairs and at most $O(GX^{O(\omega+\varepsilon)})$ contribute at any one frequency, by the count in Lemma~6.2. Cauchy--Schwarz over these pairs gives $O(X^{-3/2+O(\omega+\varepsilon)})$. For distinct frequencies, open the four Kloosterman sums, with signs $+,-,-,+$, then sum against a smooth majorant of the prime interval by Poisson summation over integers. Let $P=\prod_i d_i$ and $Q=[d_1,d_2,d_3,d_4]$. The nonzero Poisson numerator $j$ has weight $\widehat\varphi(Xj/Q)$. Each numerator has at most $P/Q$ preimages. In particular, the absolute bound per quadruple is $O(1/(XP))$, including the four Fourier coefficients, since $\sum_{j\ne0}|\widehat\varphi(Xj/Q)|\ll Q/X$. Choose small $0<\omega,\varepsilon\ll\eta\ll\vartheta\ll1$, with $\omega,\varepsilon$ small also in terms of $\rho,\nu$. Write $d_i=b_i u_i$, taking $b_i$ to be the full part on primes dividing $M$ or shared by at least two denominators. Discard tuples with any gcd exceeding $X^\eta$ or any $b_i>X^{5\eta}$. An internal gcd divides the determinant. For a gcd across pairs, choose the two denominators involved and sum $O(D_+^2/f^2)$ over common divisors $f>X^\eta$. In both counts the partner of a denominator is fixed by its shifted numerators and determinant. The first powers of primes dividing $M$ cost a fixed factor. With all gcds small, $b_i>X^{5\eta}$ forces a squarefull part greater than $X^\eta$ and hence a square divisor $b^2$ with $b>X^{\eta/3}$. This costs $O(D_+X^{-\eta/3})$ choices for that denominator. The absolute bound for these quadruples thus saves a power. We can impose just $b_i\le X^{5\eta}$ in the completed sums: any reintroduced tuples with a large gcd are bounded by the same count. In the fixed $b_i$ tuples every prime outside $M$ occurs at least twice. The $u_i$ are pairwise coprime and prime to $MC$, where $C=\prod b_i$. Put $L=[b_1,b_2,b_3,b_4]$, $V=\prod u_i$, so $Q=LV$. The weight restricts $|j|\le X^{1/3+O(\omega+\varepsilon)}$ with negligible error. Discard also $|j|Z}v^{-1}\ll_\varepsilon Z^{-1/2}X^\varepsilon$, by the Euler product at $1/2$. Together with $Q\ge X^{4/3-O(\eta+\omega+\varepsilon)}$, these bounds give a power saving by the same absolute estimate. Write $|j|=j_0 j_1$ on the retained terms, where $j_0$ is squarefree and prime to that fixed integer, $j_1\le X^{2\vartheta}$ and $j_0\ge X^{1/3-3\vartheta}$. Write $P_1=d_1d_2,P_2=d_3d_4$. Fix the opened numerators $x_i$ modulo $b_i$. Their phases there and the frequency condition modulo $L$ are fixed by $u_i\bmod ML$, since $m_i=(A_i-\kappa_i d_i)/M$. On $u_i$, the congruence $\pm x_i Q/d_i\equiv j\pmod{u_i}$ fixes $x_i$, with $(j,V)=1$, and $m_i\equiv A_i\overline M\bmod u_i$. Thus the inverse phase on $V$ is \[ e_V\bigl(L(h^2P_2^2+h'^2P_1^2)\overline{jC^2M^2}\bigr), \qquad e_q(x)=e(x/q). \] Indeed the lifted $i$th inverse contribution is $L A_i^2(P/d_i)^2\overline{jC^2M^2}$ modulo $V$. Completing each determinant square adds a multiple of $V$. Reciprocity transfers the inverse to modulus $|j|C^2M^2$ and leaves the smooth phase $e((L/(jCM^2))(h^2P_2/P_1+h'^2P_1/P_2))$. Fix $A_i$, $h,h'$, $d_3$ (hence $d_4$), the $b_i$, and $j$. Then $d_2=(h+A_2d_1)/A_1$. Fix $u_1,u_2$ modulo $j_1C^2M^2$ for the small part of the reciprocal phase and the preceding conditions, including $(u_i,MC)=1$. Expand the Euler products into divisor sums with squarefree coefficients $\prod_{\ell\mid r}(\ell^2-1)^{-1}$. Truncating at $r\le X^\eta$ costs $O(X^{-\eta+\varepsilon})$ in the unsigned bound. The divisor conditions and integrality restrict $d_1$ to progressions. The condition $(m_i,b_i)=1$ is fixed. Impose $(A_i,u_i)=1$, $(u_1,u_2)=1$, and $(u_i,u_3u_4)=1$ for $i=1,2$ by M\"obius inversion over divisors of $A_i$, $h$ and $u_3u_4$, respectively. All steps are prime to $j_0$: a divisor condition involving a prime of $j_0$ would force a nonunit $u_i$ and contributes zero. The remaining unit conditions at $j_0$ are included in the complete sums. Modulo each prime of $j_0$ the reciprocal phase is a unit times $h^2P_2/P_1+h'^2P_1/P_2$. As a function of $d_1$ it has simple poles at the two distinct roots of $P_1=d_1(h+A_2d_1)/A_1$. The rational-function Weil bound, also after an additive linear twist, and completion give $O_\varepsilon(X^\varepsilon(1+D_+/j_0)\sqrt{j_0})$ per progression by~\cite[Theorem~1.1]{CochranePinner} and the Chinese remainder theorem. Partial summation costs $X^{O(\vartheta+\omega+\varepsilon)}$: the Gaussian and angular weights depend on the ratios $A_i/d_i$ and $\sqrt X h/P_1$, the Poisson weight has bounded variation, and the smooth reciprocal phase has variation $O(X^{O(\omega+\varepsilon)}X^{1/3}/|j|)$. The frequency inequalities cut out a bounded number of intervals along the progression. The fixed choices of $h,h',d_3,j$ cost $X^{1+O(\omega+\varepsilon)}$. The remaining small moduli and residues cost $X^{O(\eta+\vartheta+\omega+\varepsilon)}$. Including the factor $X^{-8/3+O(\omega+\varepsilon)}$ from the four coefficients, the completed sum is $O(X^{-3/2+O(\eta+\vartheta+\omega+\varepsilon)})$. Since $c^2\asymp X^{-4/3}$, the exponent margin here is $1/6$ before the small losses. With the indicated parameter order, the completed and discarded contributions are $O(c^2 X^{-\xi})$. The same holds for one $v$ derivative after decreasing $\xi$. The one-variable Sobolev bound in Lemma~6.2 thus allows $v=p/X$ and gives a power saving for the signed off-diagonal outside $O(X^{1-\xi})$ primes. \emph{The diagonal and the full angular norm.} Group equal shifted frequencies before squaring. Lemma~6.2 bounds each component's diagonal, and Cauchy--Schwarz controls their overlaps. The angle and denominator truncations cost $O(cX^{-\xi})$, while the relative error $O(\sqrt{D_+/B})$ below $D_+$ saves a power against $O(c\log^3 X)$. S5.3 and the remainder comparison restore the full norm after first-sine projection. The cross term with $d>2B$ also costs $O(cX^{-\xi})$ after decreasing $\xi$. Now \eqref{eq:odd-heat} gives the result. S5.1 and S5.3 bound $Z_g-Z_B$ and $Z_B-\gamma_B(0)$. The remaining constant coefficient tail is $O_{g,M}(B^{-1/2})$ since its denominators are fixed. \end{proof} \section{Local trace weights at arbitrary fixed level}\label{sec:prime-square} The factors of \hyperref[thm:gamma0]{Theorem~6.12} come from a single prime $\ell$ at a time. For trace $R$ and unit determinant $A$, let $\rho_i$ be the root count of $x^2-Rx+A$ modulo $\ell^i$. Set $\rho_0=1$ and $L=(1+\ell^{-1})^{-1}\sum_{i\ge0}\ell^{-i}\rho_i$. \subsection{Full and new trace weights} At level $\ell^e$ the full local trace weight is \begin{equation}\label{eq:all-full-weight} G_0=L,\qquad G_e=\sum_{j\ge0}\ell^{-j}\rho_{e+j} =\ell^e\left((1+\ell^{-1})L-\sum_{i2d$, there are two disjoint classes modulo $\ell^{j-d}$, centered at $u$ and $A/u$. With $P_h=\ell^{-h}s_h$ for $h\ge1$, subtracting the adjacent measures gives, for $h\ge1$, \[ (1-\ell^{-2})c_{2h}=(1-\ell^{-1})\ell^{-h}P_h,\qquad (1-\ell^{-2})c_{2h+1}=\ell^{-h-1}(P_h-P_{h+1}). \] These identities telescope to give $C_j$ for $j\ge2$. The value $C_1=1/\ell$ follows from $\mathcal B_{\ell,A}(L,L)=1$. In particular $c_1=\ell^{-1}-s_1/(\ell^2-1)$. \subsection{Pairings and orthogonality} Write $F_e=\mathcal B_{\ell,A}(G_e,G_e)$ and $B_{mn}=\mathcal B_{\ell,A}(W_m,W_n)$. Summation by parts of $c_0+\sum_{j\ge1}c_jv_e(j)^2$ gives \begin{equation}\label{eq:all-full-diag} F_0=1,\qquad F_e=\ell+3+(\ell+1)^2\sum_{j=2}^{e}\ell^{j-2}s_{\lfloor j/2\rfloor} \quad(e\ge1). \end{equation} For the new pairings set $b_n=(\ell^2-1)\ell^{n-3}$ for $n\ge3$, and \[ d_0=1,\qquad d_1=\ell-1,\qquad d_2=\ell^2-\ell-1,\qquad d_n=(\ell-1)b_n\quad(n\ge3). \] The diagonal is \begin{equation}\label{eq:all-new-diag} \begin{aligned} B_{00}&=1,\qquad B_{11}=\ell-1,\qquad B_{22}=\ell+s_1(\ell^2-2\ell-1),\\ B_{nn}&=b_n\bigl(s_{\lfloor(n-1)/2\rfloor} +(\ell-2)s_{\lfloor n/2\rfloor}\bigr) &&(n\ge3). \end{aligned} \end{equation} The mixed entries for $mm$. At $n=4$ the factor $s_2-s_1$ is $1$ or $-1$ according to $A\bmod4$. At $n=6$ the factor $s_3-s_2$ is $2$ at $A\equiv1\bmod8$, $-2$ at $5$, and zero at $3,7$. An equal-exponent entry at $2$ is positive through $n=4$, is positive at $n=5,6$ exactly for $A\equiv1\bmod4$, and at $n\ge7$ exactly for $A\equiv1\bmod8$. These are all the possible zeros of a factor in the product. For a fixed list of levels, the constants are independent of $A$ at odd primes occurring only to the first power. They depend only on the Legendre symbol at the other odd primes. At $2$ they are independent of $A$ when the largest exponent is at most $3$, are determined by $A\bmod4$ when it is $4$ or $5$, and by $A\bmod8$ for larger exponents. The relative-density-one sets in finer classes can be combined into sets in these coarser classes, since the number of finer classes is finite. \section{Dependencies of the main proof}\label{sec:dependencies} \textbf{Main trace theorem.} Section~6 of the article gives the proof order. The count identity uses Diaconis--Khare--Saloff-Coste, Propositions~4.1--4.2. Lemmas~3.2--3.4 use the Deuring, Gekeler and Zagier formulas, Burgess with parameter~$3$, and Petrow--Young, Theorem~1.1. S5.1--S5.3 use Heath--Brown's fourth moment~\cite[Theorem~2]{HeathBrownReal} and the additive large sieve~\cite[Theorem~1 and Lemma~1]{MontgomeryVaughan}. S5.4 adds the discriminant functional equation and the rational-function Weil bound. Theorem~6.1 uses Siegel--Walfisz and the multiplicative large sieve. \textbf{Applications.} Proposition~6.3 uses the short-interval bound of David--Koukoulopoulos--Smith \cite[Theorem~1.3]{DavidKoukoulopoulosSmith}. Lemma~6.8 adapts their progression argument for Proposition~6.9 \cite[Theorems~3.2 and~4.2, Corollary~3.3, \S5.2]{DavidKoukoulopoulosSmith}. Theorems~6.5, 6.11 and~6.12 use local factors and oldform inversion, with Kaplan--Petrow \cite[Theorem~10, (43)--(44)]{KaplanPetrow}. Their Lemmas~2--4 and Theorems~2--3 give the weights in Section~4. \textbf{Variance and prime means.} Theorem~\ref{thm:level-one-variance} and Corollary~\ref{cor:sharp-variance} use the same fourth moment and sieves, plus the zero-density bound~\cite[(1.2)]{KoukoulopoulosShortAP}. Corollary~\ref{prop:prime-mean-second} uses Alp\"oge's Dirichlet critical-line theorem~\cite{AlpogeAnnouncement,SutherlandVerification}. Proposition~7.1 and the strengthened S1 bounds use its quadratic case. \section{Variance across primes at level one}\label{sec:level-one-variance} Choose the local unit residues independently and uniformly in the Haar model. We compute its variance by character completion and transfer it to the primes using bounds grouped by conductor divisibility. Put $x_X=\sqrt{\lambda}\,X^{-\delta/2}$. For $B$ uniform on the units modulo $\ell^k$ set $Y_{\ell,k}(B)=(1-\ell^{-2})^{-2}|S(1,B;\ell^k)|^2/\ell^k$. Define the common arithmetic factor and the kernel integral by \begin{equation}\label{eq:variance-constant} \mathfrak A=\prod_\ell (1-\ell^{-1})^2 \left(\frac1{1-\ell^{-5}} +\sum_{k\ge1}\ell^{-k}\mathbb E_B[Y_{\ell,k}(B)^2]\right), \qquad I(H)=\int_0^\infty v^4H(v)^2\,dv . \end{equation} Let $W(v)=2\int_0^1\sigma(y)e^{-64\pi^2y(1-y)v^2}\,dy$ and put $J_\delta=\int_1^2 v^{-\delta/2}\,dv$. \begin{theorem}\label{thm:level-one-variance} Fix $\lambda>0$ and $0<\delta\le1/4$. Put $T_p=\lfloor\lambda p^{1-\delta}\rfloor$, $c_p=\lambda p^{-\delta}$ and $x_p=\sqrt{c_p}$, and write $\E_X$ for the uniform average over primes $Xj\ge2$ the lifts modulo $\ell^{j-1}$ cancel since $2u-r$ is a unit. For $j=10$, \begin{equation} \sum_{w\mid f_\chi}\frac{f_\chi}{\varphi(f_\chi)} |\widehat{(x\partial_x)^jG_{x,D}}(\chi)|^2 \ll_{j,\varepsilon,\lambda,\delta} V(x)w^{-1+\varepsilon}. \label{eq:variance-divisibility} \end{equation} Here $f_\chi$ is the primitive conductor. For the centered difference of two cutoffs, if $D\ge B$ and $Z=xB\ge2$, then \begin{equation} \sum_\chi \frac{f_\chi}{\varphi(f_\chi)} |\widehat{(x\partial_x)^j(G_{x,D}-G_{x,B})}(\chi)|^2 \ll_{j,\lambda,\delta} V(x)/Z. \label{eq:variance-band} \end{equation} Split the conductor into $q$ from non-real local characters and $s$ from real nontrivial ones, with at most three choices at 2 and one at each odd prime. The local support gives $d=rm$, $(m,r)=1$, where $r=\kappa q t$, with $\kappa=1$ for odd $q$ and $2$ otherwise. The integer $t$ has the prime support of $s$ and is divisible by $s$. The Chinese remainder theorem gives the cofactor twist $\overline{\chi_q}^{\,2}(m)$, with unit phases for fixed $a,r$. The non-real coefficients cost $O(q^{-1/2}a_q)$ with $a_q=q/\varphi(q)$. The product $\alpha_t$ of the real local bounds satisfies \[ \sum_t\frac{\alpha_t}{\sqrt t}\ll_\epsilon s^{-1+\epsilon}. \] The local sum is $O(\ell^{-1}(1+O(\ell^{-1/2})))$ at each odd prime and bounded at 2. For a weight of supremum and variation at most $W_0$ on $[N,2N)$, the vector of sums against $\bar\chi_q^2$, weighted by the non-real coefficients, has norm \[ \ll \sqrt{a_q}\,W_0\left[\sqrt N+ 2^{\omega(q)/2}\min(N/\sqrt q,\sqrt q)\right]. \] For short sums count $n^2=n'^2\bmod q$. Besides the $O(N)$ diagonal pairs, assign every odd prime power to $n-n'$ or $n+n'$ and, at 2, assign $2^{v_2(q)-1}$ to the factor with larger valuation. The assigned moduli have product at least $q/2$, giving $O(N^2/q)$ pairs per assignment. For long sums each unit class gives the same integral divided by $q$ up to $O(W_0)$. The integral cancels since $\chi_q^2$ is nonprincipal. Apply Parseval to the errors, with at most $2^{\omega(q)+1}$ preimages of a square. Multiplying the orthogonality factor $\sqrt{\varphi(q)}$ by $q^{-1/2}a_q$ gives the norm for $N\ge1/2$. For $m\asymp M$, the weight $m^{-3}W(a/(xrm))$ and its variation are $O(M^{-3}\min(1,(xrM/a)^3))$. Expand $g=1*h$ and impose coprimality to $as$ by M\"obius inversion. The character imposes coprimality to $q$. Writing $m=un$ gives $N\asymp M/u$ at total cost $\tau(as)\sum_m|h(m)|$. Apply the vector bound and use \[ S(z)=\sum_{a\ge1}\tau(a)\min(1,(z/a)^3) \ll \begin{cases}z^3&z\le1,\\ z\log(2z)&z\ge1.\end{cases} \] Write $v=xr$. The first row term, without $\sqrt{a_q}\alpha_t\tau(s)$, is bounded by \[ x^{-2}r^{-3}\sum_M M^{-5/2}S(vM) \ll \sqrt{x/r}\begin{cases}1&v\le1,\\v^{-3/2}\log(2v)&v>1.\end{cases} \] The second term, also with $2^{\omega(q)/2}$ omitted, is \[ x^{-2}r^{-3}\sum_M M^{-3}S(vM)\min(M/\sqrt q,\sqrt q) \ll (r\sqrt q)^{-1}. \] All $M$-sums are dyadic from 1. For the last bound, use $M/\sqrt q$ and split at $1/v$. If $vq\le1$, splitting at both $q$ and $1/v$ gives the alternative bound $\ll x\sqrt q(1+\log(1/(vq)))$. Assign the prime powers of $w$ to $w_q\mid q$ or $w_s\mid s$. For $q\asymp U$ restricted by $w_q\mid q$, use \[ \sum a_q^2\ll_\varepsilon U w_q^{-1+\varepsilon},\qquad \sum 2^{\omega(q)}a_q^2 \ll_\varepsilon U w_q^{-1+\varepsilon}\log(2U). \] Write $q=w_qv$, use submultiplicativity and expand $a_v^2$ over squarefree divisors with local coefficients $O(1/\ell)$. For the second bound use $2^{\omega(v)}\le\tau(v)$ and sum over multiples of each divisor. The first squared row contributes $O((x/t)\log(2D))$. Split the second at $q=(xt)^{-1/2}$ to obtain $O((x/t)\log(2/x))$. Both retain $w_q^{-1+\varepsilon}$. Taking the triangle inequality in $t$ before squaring over $s$ bounds the remaining summands by $\tau(s)^2(s/\varphi(s))s^{-2+\varepsilon'}$. Thus $w_s\mid s$ gives $w_s^{-2+\varepsilon}$, and smaller intermediate exponents absorb the $2^{\omega(w)}$ assignments. For the band $B1$. For a nonprincipal real character, $g=1*h$ and M\"obius inversion give a linear summatory term for $g(m)1_{(m,as)=1}$ with error $O(\tau(as))$. After $d=rm$ the integral cutoff is independent of $r$, so $\sum_k A_{\ell,k}(\chi_\ell)\ell^{-k}=0$ cancels the integrals, including those with $r>D$. For $rm\le D$, the better of the partial summation error $O(\tau(s)x\log(2+1/(xr)))$ and the bound $O(1/r)$ on the sum and integral gives $O(\tau(s)\sqrt{x/r})$. On a band with $r\le B$, partial summation costs $O(\tau(s)xZ^{-2}\log(2Z))$, summing the variation over $m\gg B/r$. For $r>B$, use $\sum_a|W(a/(xd))|\ll xd$ and integrate $m^{-2}$ over $m>B/r$ to bound the sum and integral by $O((Zr)^{-1})$. Both cases give $O(\tau(s)\sqrt{x/r}\,Z^{-1/2})$, also for derivative weights. The same real-support sum proves \eqref{eq:variance-divisibility} and \eqref{eq:variance-band}. \subsection{The leading Haar variance} Write $F_{H,x}$ for the profile with kernel $H$ in place of $W$. For the Gaussian and sharp kernels we prove \begin{equation}\label{eq:haar-variance-constant} \operatorname{Var}_A F_{H,x}\sim \tfrac12\mathfrak A I(H)x\log(1/x). \end{equation} First take $H$ smooth with compact support in $(0,\infty)$ and put $L=1/x$. Haar Parseval expresses the variance as a sum over nonprincipal characters. The purely real characters contribute $O_H(x)$ by the cancellation of the full local sums above. \paragraph{Completing the cofactor sums.} For $q>1$, $\chi_q^2$ is primitive of conductor $q'=q$ if $q$ is odd and $q/2$ otherwise: squaring preserves the odd exponents and lowers the dyadic exponent $j\ge4$ by one. For a smooth weight at scale $N$ with scaled derivatives $O(W_0)$, Poisson summation has dual length $q'/N$, prefactor of modulus $N/\sqrt{q'}$, and zero constant term. Apply the same square-congruence count to both sums. For $N\ll q$ this gives \[ \left(\sum_{\chi_q} \left|C_q(\chi_q)\sum_n w(n)\chi_q^2(n)\right|^2\right)^{1/2} \ll \sqrt{a_q}W_0 \left(\sqrt N+2^{\omega(q)/2}\min(N/\sqrt q,1)\right), \] Here $C_q(\chi_q)$ is the product of the non-real coefficients. The dual characters $\overline{\chi_q}^{\,2}$ use the count modulo $q$ after separating signs and summing rapidly decaying dyadic tails. Since $2^{\omega(q)/2}\ll q^{1/4}$, the norm is $O(\sqrt{a_q}W_0\sqrt N)$, with an extra $(q/N)^A$ for $N\ge q$ by rapid decay. With $d=\kappa qtm$ as above, let $\alpha_s(t)$ be the product of the actual real local coefficients. Up to a phase independent of $a,t,m$, the full Fourier coefficient is \[ C_q(\chi_q)x^{-2} \sum_{\substack{a,t,m\\(a,qtm)=1,\ (m,qs)=1}} \frac{\alpha_s(t)g(m)}{(\kappa qtm)^3} H\bigl(a/(x\kappa qtm)\bigr)\chi_q^2(a/(tm)). \] Here $(q,s)=1$, and the unit-square phases are as in the cofactor bound above. For fixed $a,t$, its divisor expansion again costs $\tau(as)\sum|h|$, with row lengths at most $M\asymp La/(\kappa qt)$. The smooth row bound gives a norm \[ \ll_H \sqrt{a_q}\,|\alpha_s(t)|\tau(as) \sqrt{x/(\kappa qt)}\,a^{-5/2}. \] Since $q\ll_H La/t$ and $\sum_{q\asymp Y}a_q/q\ll1$, the real-support bound and $\sum_a\tau(a)a^{-5/2}\sqrt{\log(2a)}<\infty$ allow fixed truncations of $a,s,t$ at arbitrarily small cost in units of $\sqrt{x\log L}$. The same estimate on multiples of $2^J$ bounds their contribution by $O_H(2^{-J/2}\sqrt{x\log L})$. The ranges $L^{1/2-\eta}0$ set $\kappa=\gamma+\eta_1$, $d_*=\delta/2+2\gamma+\eta_1$, $\beta_*=\delta+2\gamma+2\eta_1$ and $\omega_*=\delta/2+2\kappa+\eta_1$. Use the class-number cutoff $B=X^{\beta_*}$, denominator split $D_0=X^{d_*}$ and angular cutoff $W_0=X^{\omega_*}$, with $R\le2X^\kappa$. Choose $\eta_1$ to preserve the strict margins at $\eta_1=0$ and $\varepsilon$ still smaller. At $\delta=1/4$ take $\gamma=1/16$, $u=\eta_1=1/1024$ and $\vartheta=1/128$. On each band $w\asymp W$, use $D_0=X^{1/4-\vartheta}$ if $W\le X^{1/2-\vartheta}$ and $D_0=X^{1/4+\vartheta}$ otherwise. The remaining parameters stay as above. With $w=2\sqrt p\sin\phi$ and $s=2\sqrt p\cos\phi$, use $\mathcal D_h$ from \eqref{eq:odd-heat} with complex $h$. The bilinear square retains $e^{-h(m+1)^2}$ and the first-sine term $e^{-h}(Z_B-\gamma_B(0))^2$. The absolute square uses $\Re h$. The two transforms to compare are \begin{equation} M_p(z)=T^{-1}\sum_{\substack{k\ge4\\ k\ {\rm even}}} |\tau_k(p)|^2 e^{-z(k-1)^2/T}, \qquad M^{\rm diag}_{p}(z)=c_p^{-1}\int_0^1\sigma(y) \sum_{\beta\ne0}|\gamma_{A_p}(\beta)|^2 e^{-z b(y)\beta^2/c_p}\,dy , \label{eq:sharp-complex-heat} \end{equation} Here $b(y)=64\pi^2y(1-y)$, so $M^{\rm diag}_p(1)=F_{x_p}(A_p)$. At $T=K^2$ this transform defines the sharp model in S9. \paragraph{Edge} Poisson summation for the complex Gaussian gives \[ |G_h(\theta)|\le R^{1/2}G_{R^2/T}(\theta) \] with a positive real Gaussian on the right. For $wD_0\gg H$, Parseval as in Lemma~\ref{lem:profile-above-endpoint} costs $O(d/H)$ per denominator, including $H<1$. The lengths in the large sieve sum to $O_\delta(W^2+R(1+B^2))$. The angular factor $W/p$ and the prime average therefore give for the normalized high squared norm \[ \mathbb E_X\frac{\|\mathrm{high}\|^2_{\rm ang,\ band}}{c_p} \ll X^\varepsilon \frac{W^2+R(1+B^2)}{X D_0\sqrt{c_p}} . \] The low--high product in prime $L^2$ costs the square root of this bound times $O(X^\epsilon)$. For the high square add $L_B^{1/2}$ using its pointwise bound. The high diagonal costs $O(X^\varepsilon/(D_0\sqrt{c_p}))$. At $\delta=1/4$ the high mean is $O(X^{-1/8-\vartheta+\varepsilon})$ in both ranges of $W$. In the lower range use $R(1+B^2)/X\ll X^{-3/16+5u}\ll X^{-2\vartheta}$. Since $L_B\ll X^{2u}$, the high terms cost $O(X^{-1/16-\vartheta/2+u+\varepsilon})$ in prime $L^2$. For the low mixed terms, use $R$ in the lower range and $1+\sqrt R\sqrt X/W$ in the upper range. The exponents are $-1/16-\vartheta+u$ and at most $-3/32+2\vartheta+u/2$, respectively. Both are strictly below $-1/16$. Summing the low norms, high norms and angular errors bounds the normalized squared norm of $\mathcal D_h$ in prime $L^2$ by $O(X^\varepsilon)$. In the open ranges this follows from the pointwise bound. \paragraph{Tail, normalization and the final error} For $u\ge0$, $|e^{-zu}|=e^{-u}$ on $\Re z=1$. Thus the squared diagonal error $O(B^{-1}\log^4 X)$ and first-sine squared error $O(X^\epsilon B/p)$ from Lemma~\ref{lem:profile-above-endpoint} apply. After removing the first sine, the real heat kernel bound $O(\sqrt X)$ for the trace sum gives normalized squared tail $O(X^{-1/2}\sum_t|F(t)-F_B(t)|^2/c_p)$ by Cauchy--Schwarz. The Mellin estimate in Lemma~\ref{lem:averaged-tail} gives $O_\varepsilon(X^\varepsilon A(p)/(Bc_p))$. Jensen and the same discriminant multiplicity and fourth moment give $\mathbb E_X A(p)^2\ll_\varepsilon X^\varepsilon$. With the $L^2$ bound for the truncated squared norm, the tail cross term costs $O_\varepsilon(X^\varepsilon(Bc_p)^{-1/2})$. Corollary~4.3 and $|\tau_k(p)|\ll k$ give $M_p(z)$ with hyperbolic error $O(p^{-3/2}/T)$. The table bounds the exponents in the $L^2$ error at $\eta_1=0$, apart from $X^\varepsilon$. \[ \begin{array}{l|c} &\text{exponent at }\eta_1=0\\ \hline \text{high denominators, with cross terms}&-\gamma\\ \text{mixed low denominators}&-1/2+\delta+3\gamma\\ \text{class-number and Fourier tails}&-\gamma\\ \text{Taylor, first term}&-1/4+\delta/4+\gamma/2\\ \text{Taylor, second term}&-1/2+\delta+5\gamma/2\\ \text{edge and discarded diagonal}& \max(-1/2+\delta/2,\,-1+3\delta/2+4\gamma,\,-3/2+5\delta/2+6\gamma)\\ \text{first-sine mass and zero mode}& \max(-1+2\delta+2\gamma,\,-1+3\delta/2+\gamma) \end{array} \] The positive increments in $d_*$ and $\beta_*$ make the first and third rows strictly smaller than $-\gamma$. Every other row has a strict margin for $\gamma=\delta/4$ at $\delta<1/4$, and for $\gamma=\delta/2$ at $\delta<1/6$. In both cases the limiting inequality is $\delta+4\gamma<1/2$ from the low mixed term. At $\delta=1/4$ the band estimates above replace the first two rows. There $(Bc_p)^{-1/2}\asymp X^{-1/16-u}$, and the remaining angular and mass errors retain strict margins even with the factor $L_B^{1/2}$. Indeed, their exponents at $u=0$ are at most $-3/32$, and they increase by at most $10u$. Thus in all these ranges, for some $\xi>0$, \begin{equation} \sup_{|\Im z|\le X^\kappa,\ \Re z=1} \|M_p(z)-M^{\rm diag}_p(z)\|_2\ll_{\delta,\lambda} X^{-\gamma-\xi}. \label{eq:sharp-complex-bound} \end{equation} For the estimate at $z=1$ set $R=1$ and $\kappa=0$ throughout. With $\gamma=\delta/2$, the low mixed term has exponent $-1/2+2\delta$ before the small increments, and $B/\sqrt T=o(1)$. Both requirements and the other strict margins hold for $0<\delta<1/5$. \subsection{Comparison with the count statistic} For $0<\delta<1/4$ the same real-parameter bounds also give \begin{equation} \|Y_p-F_{x_p}(A_p)\|_{L^2(\mathbb E_X)} \ll_{\delta,\lambda,\varepsilon} X^\varepsilon \left(X^{-\delta/2}+X^{-1/8+\delta/4}+X^{-3/16+\delta/2}\right). \label{eq:variance-count-approximation} \end{equation} Set $R=1$, $W_0=\sqrt T$, $D_0=X^{1/4}$ and $B=X^{3/8}$ in the heat estimates. The edge contributes the first term, and the high denominators and the tail contribute $(D_0\sqrt{c_p})^{-1/2}$ and $(Bc_p)^{-1/2}$, up to $X^\varepsilon$. The low mixed term $D_0/\sqrt T$, the Taylor error after Cauchy--Schwarz and normalization, and the first-sine and zero-mode errors are smaller. Corollary~4.3 and Lemma~\ref{lem:profile-above-endpoint} give relative error $O(T^{-1/2}\log^3 X)$ between the binomial and heat multipliers up to degree $\sqrt T\log X$. Rounding $T$ costs less, and $|\tau_k(p)|\ll k$ controls the remaining tail. The same comparison works for the Gaussian trace sum with $T_p$ in place of $T$. Both $L^2$ errors are $O_\varepsilon(X^\varepsilon T^{-1/2})$: \eqref{eq:sharp-complex-bound} bounds $\|M_p(1)\|_2$ by $O_\varepsilon(X^\varepsilon)$ since Weil's inequality gives $F_{x_p}(A_p)\ll\log^3(2/x_p)$, splitting at $d=1/x_p$ with numerator weight sum $O(\min((x_pd)^3,x_pd))$. Thus the count error is $o(X^{-\delta/4})$ for $\delta<1/4$ by \eqref{eq:variance-count-approximation}, and at $\delta=1/4$ by \eqref{eq:sharp-complex-bound} at $z=1$. For $\delta<1/5$ the real estimate with $\gamma=\delta/2$ gives $o(X^{-\delta/2})$. \subsection{A prime mean-square bound} For primitive characters of conductor $f\le X^\theta$ with fixed $0<\theta<1/2$, put $D=X^\theta$. Then \begin{equation} \mathbb E_X\left|\sum_\chi a_\chi\chi(p)\right|^2 \ll_\theta \sum_\chi \frac{f_\chi}{\varphi(f_\chi)}|a_\chi|^2 . \label{eq:variance-prime-sieve} \end{equation} Take $R=X^\beta$ with $0<2\beta<1-2\theta$ and majorize the prime indicator on $(X,2X]$ by $(\sum_{d\mid n}\lambda_d)^2$, with $\lambda_d=\mu(d)\log(R/d)/\log R$ for $d\le R$ and zero otherwise. Set $n=[d,e]n'$ in the expansion. For $r=[d,e]$, characters with $(r,f)>1$ vanish and the others acquire phases $\chi(r)$. Gauss expansion gives additive frequencies spaced at least $D^{-2}$ apart and diagonal $(\varphi(f)/f)\sum_{\chi\bmod f}^{*}|a_\chi|^2$ by orthogonality. The Montgomery--Vaughan mean-square estimate gives $X/r$ times the diagonal with absolute error $O(D^2\sum_\chi|a_\chi|^2)$, allowing signed sieve coefficients at total error $O(D^2R^2\sum_\chi|a_\chi|^2)$. For each fixed $f$, the diagonal sieve factor is \[ \sum_{(de,f)=1}\frac{\lambda_d\lambda_e}{[d,e]} =\sum_{(\ell,f)=1}\varphi(\ell) \left(\sum_{\ell\mid d,\ (d,f)=1}\frac{\lambda_d}{d}\right)^2 \ll \left(\frac f{\varphi(f)}\right)^2/\log R . \] Only squarefree $\ell$ contribute. With $d=\ell u$ and $m=\ell f$, use \[ \sum_{\substack{u\le Y\\(u,m)=1}}\frac{\mu(u)}{u}\log(Y/u) \ll m/\varphi(m). \] For $m=1$, use the harmonic convolution $\sum_{u\le Y}\mu(u)H_{\lfloor Y/u\rfloor}/u=1$. Replacing the logarithm by $H_{\lfloor Y/u\rfloor}-\gamma$ costs $O(1)$. The identity $\sum_{u\le Y}\mu(u)\lfloor Y/u\rfloor=1$ also gives $\sum_{u\le Y}\mu(u)/u=O(1)$. Convolve with the indicator of integers supported on primes of $m$ for the coprime version. Hence the inner sum is $O((f/\varphi(f))/(\varphi(\ell)\log R))$. Sum $\varphi(\ell)^{-1}$ to get $O(\log(2R))$, multiply by the diagonal factor $\varphi(f)/f$ and divide by the prime count. Since $D^2R^2\le X^{1-\xi}$ for some $\xi>0$, the sieve error saves a power, proving \eqref{eq:variance-prime-sieve}. \subsection{Averaging the centered moments over primes} Put $B=X^{\delta/2+1/1000}$, $D=X^{1/4}$ and $G_x=G_{x,B}$. Equations \eqref{eq:variance-prime-sieve} and \eqref{eq:variance-band} bound the centered band $B0$, \begin{equation} \|S_p-F^\#_{x_p}(A_p)\|_{L^2(\mathbb E_X)} \ll_\delta X^{-\delta/4-\xi_\delta}. \label{eq:sharp-variance-comparison} \end{equation} Consequently \begin{equation} \operatorname{Var}_X S_p =\E_X\operatorname{Var}_A F^\#_{x_p}(A) +o\bigl(x_X\log(2/x_X)\bigr) \sim \frac{\delta}{4}J_\delta\,\mathfrak A\,I(W_\#) X^{-\delta/2}\log X . \label{eq:sharp-variance-order} \end{equation} \end{corollary} \subsection{Recovering the sharp weight cutoff} Let $\nu_p$ put mass $|\tau_k(p)|^2/K^2$ at $u=(k-1)^2/K^2$ and let $\mu_p$ have Laplace transform $M^{\rm diag}_p(z)$ at $T=K^2$. The real heat bound controls the masses of the positive tilted measures $e^{-u}\,d\nu_p$ and $e^{-u}\,d\mu_p$ in prime $L^2$ by $O_\varepsilon(X^\varepsilon)$, and hence their Fourier transforms. For $0<\eta<1/4$, the boundary kernel is $W_\#(v/\sqrt{1+\eta})-W_\#(v/\sqrt{1-\eta})$. Solving the quadratic inequality in $y$ shows that the kernel vanishes below $v_0\sqrt{1-\eta}$, where $v_0=1/(4\pi)$. It is $O(\sqrt\eta)$ for $|v-v_0|\ll\eta$ and $O(\eta/\sqrt h)$ at bounded $v$ with $|v-v_0|\asymp h\gg\eta$. At large $v$, the intervals have length $O(\eta/v^2)$ and density $O(1/v)$. For fixed numerator $a$ and $x=x_p$, a bounded band of width $h$ in $v=a/(xd)$ contains $O((a/x)h+1)$ denominators $d\asymp a/x$. The dyadic bands contribute $O(\eta a/x+\sqrt\eta)$. Weight by $x^{-2}d^{-3+\varepsilon}$ and sum over $a$ to obtain $O_\varepsilon(x^{-\varepsilon}(\eta+x\sqrt\eta))$. The large-$v$ sum with kernel $O(\eta(xd/a)^3)$ over $d\ll a/x$ and $a$ is $O_\varepsilon(x^{-\varepsilon}\eta)$. Thus $\mu_p([1-\eta,1+\eta])\ll_\varepsilon X^\varepsilon(\eta+x_p\sqrt\eta)$. Choose $\gamma0$. Taking $\gamma=\delta/4$ proves \eqref{eq:sharp-variance-comparison}. \subsection{Variance of the sharp profile} The sharp kernel is nonincreasing and $O(\min(1,v^{-3}))$. Its dyadic supremum and variation bounds give \eqref{eq:haar-variance-constant} with $H=W_\#$. Its integral can also be evaluated. Under $\sigma(y)\,dy$ the variable $q=2\sqrt{y(1-y)}$ has density $4q^2/(\pi\sqrt{1-q^2})$. Integrate $v^4$ up to $1/(4\pi\max(q,q'))$ for two independent copies, and set $q=\sin\theta$ on the larger variable. This gives \begin{equation} I(W_\#)=\frac{1}{80\pi^7} \int_0^{\pi/2}(\theta-\sin\theta\cos\theta)\csc^3\theta\,d\theta =\frac{G+1/2}{80\pi^7}, \label{eq:sharp-haar-variance} \end{equation} where $G$ is Catalan's constant. For the last equality, integration by parts reduces the integral to $1-\int_0^{\pi/2}\sin^2\theta\,\log\tan(\theta/2)\,d\theta$. The integral of $\log\tan(\theta/2)$ is $-2G$, and its integral against $\cos 2\theta$ is $-1$ by integration by parts. The Mellin transform of the sharp kernel is $\widehat W_\#(s)=\frac2s\int_0^1\sigma(y)b(y)^{-s/2}\,dy$ for $0<\Re s<3$. In particular $\widehat W_\#(2)=1/(8\pi^2)$, as for $W$. The mean calculation below gives $\mathbb E_A F_x^\#=1/48+O(x)$. The prime moment proof uses logarithmic derivatives. To obtain them, smooth $W_\#$ in $\log v$. Its only derivative singularity is at $v_0=1/(4\pi)$. For $u=\log(v/v_0)>0$, \[ \frac{d}{du}W_\#(v_0 e^u)=-\frac8{\pi}\frac{e^{-3u}}{\sqrt{1-e^{-2u}}}, \] and the derivative vanishes for $u<0$. For $|h|<1/4$, the supremum and dyadic variation of $W_\#(v e^h)-W_\#(v)$ are $O(\sqrt{|h|}\min(1,v^{-3}))$. Integrate the $O(u^{-1/2})$ derivative up to $2|h|$, and use $O(|h|u^{-3/2})$ for its difference beyond that point. Away from the singularity the derivatives decay exponentially at infinity. Let $\rho_{\eta_0}$ be a positive smooth bump of mass one supported on $|h|\le\eta_0=(\log X)^{-C_0}$. Set \[ W_{\eta_0}(v)= \frac{\int W_\#(v e^h)\rho_{\eta_0}(h)\,dh} {\int e^{-2h}\rho_{\eta_0}(h)\,dh}. \] This preserves the Mellin value at 2. The dyadic supremum and variation of the difference are $O(\sqrt{\eta_0}\min(1,v^{-3}))$. Differentiation of the bump costs a fixed power of $\log X$. The estimates \eqref{eq:variance-divisibility} and \eqref{eq:variance-band} use only the supremum and variation bounds. The centered prime-moment comparison of S8 therefore applies for the same $B,D$: the tail estimates save powers, the conductor decay absorbs any logarithmic derivative loss above a sufficiently large power of $\log X$, and Siegel--Walfisz absorbs it below that cutoff. The smoothed Haar mean is $1/48+O(x)$ as it averages the Haar means at $xe^{-h}$ with normalized weights $e^{-2h}\rho_{\eta_0}(h)$. The translation and Fourier energy bounds give Haar squared norm $O(\eta_0 x\log(2/x))$ for the centered difference. In both profiles the supremum of the tail above $D=X^{1/4}$ is $O(x^{-1}D^{-1}\log^3 X)=o(\sqrt{V(x_X)})$. Freeze $x$ at the left endpoint of each interval of length $\asymp X^{1-b_*}$, with $\delta/20$, using the power saving in the tail. The dual multiplicative large sieve costs $O(X^{1-b_*}+D^2)$ per interval. Since $D^23$, the centered difference is $o(\sqrt{V(x_X)})$ in prime $L^2$. The mean difference is $O(x)=o(\sqrt{V(x_X)})$. The variance comparison passes to the sharp profile and then to $S_p$ by \eqref{eq:sharp-variance-comparison}, proving \eqref{eq:sharp-variance-order}. \subsection{Second terms for the mean} The sharp Haar mean has the expansion \begin{equation}\label{eq:sharp-haar-mean} \mathbb E_A F^\#_x(A)=\frac1{48}-\frac{x}{1728}+o(x). \end{equation} Put $P(z)=z^{-3}W_\#(1/z)$, so $P(0)=1/(24\pi^4)$ by the density calculation. The square-root cusp leaves $P$ absolutely continuous with integrable derivative. As $j\downarrow0$, \[ \sum_{d\ge1} P(jd)=j^{-1}\int_0^\infty P(z)\,dz-\tfrac12P(0)+o(1). \] The remainder is the integral of $P'$ against a bounded, mean-zero sawtooth of period $j$. It is uniformly bounded and tends to zero by $L^1$ approximation by step functions. Dropping coprimality and replacing $Y_{a,d}$ by $1$ gives \[ F^0(x)=\sum_{a\ge1}\frac{x}{a^3}\sum_{d\ge1}P(xd/a) =\zeta(2)\int_0^\infty P(z)\,dz -\tfrac12 x\zeta(3)P(0)+o(x). \] The residual after subtracting the constant is $O(x)$ for all $x>0$. To restore coprimality and $g(d)$, expand the Euler product of the Gaussian mean as $\mathcal G(s)=\sum_{u,v}c_{u,v}u^{-s}v^{s-3}$. The local expansion there converges absolutely with the weights at $s=2$ and $s=3$. Multiplying the numerator and denominator series gives $\mathbb E_A F^\#_x=\sum_{u,v}c_{u,v}u^{-2}v^{-1}F^0(xv/u)$. Dominated convergence at the linear term uses the convergence at $s=3$. The two coefficients are therefore multiplied by $\mathcal G(2)=1$ and $\mathcal G(3)=\zeta(2)^2/\zeta(3)$, respectively. Since $\int P=\widehat W_\#(2)=1/(8\pi^2)$, this gives \eqref{eq:sharp-haar-mean}. \begin{corollary}[Second terms for the prime means]\label{prop:prime-mean-second} With the normalization of Corollary~\ref{cor:sharp-variance}, for $0<\delta<1/6$, \[ \mathbb E_X S_p=\frac1{48}-\frac{J_\delta}{1728}X^{-\delta/2} +o(X^{-\delta/2}). \] With the normalization of Theorem~\ref{thm:level-one-variance}, for $0<\delta<1/5$ and fixed $\lambda>0$, \[ \mathbb E_X Y_p=\frac1{48}-\frac{\sqrt{\pi\lambda}\,J_\delta}{2304} X^{-\delta/2}+o(X^{-\delta/2}). \] \end{corollary} \begin{proof} Take $\gamma=\delta/2$ in the sharp cutoff recovery and the real heat comparison. Both errors are $o(x_X)$ in prime $L^2$ in the stated ranges. Truncate at $D=X^\theta$ with $\delta<\theta<1/4$, at cost $O(x_X^{-1}D^{-1}\log^3 X)=o(x_X)$. At denominator $d$ the nonprincipal coefficients have $\ell^1$ norm and total variation as $x$ ranges over the prime interval bounded by \[ \ll \tau(d)^2\sqrt d\,\min(x_X,(d^2 x_X)^{-1}). \] Indeed the local product $Y_{a,d}$ is $O(\tau(d)^2)$ by Weil's bound, so Parseval bounds its absolute character sum by $O(\sqrt d\,\tau(d)^2)$. For each $a$, the kernel is monotone in $x$, with supremum $O(\min(1,(x_Xd/a)^3))$. Summing these bounds with the factor $x^{-2}d^{-3}$ gives the assertion, also for variation. Summing over $d$ costs $O(x_X^{-1/2}\log^C X)$. For $p>X>D$, a character modulo $d\le D$ agrees at $p$ with its primitive inducing character of conductor $f\mid d$. Alp\"oge's Dirichlet theorem~\cite{AlpogeAnnouncement,SutherlandVerification} puts the zeros in the explicit formula for a nonprincipal primitive character on $\Re s=1/2$. The zero count gives $\sum_{n\le u}\Lambda(n)\chi(n)\ll X^{1/2}\log^2(fX)$ for $X\le u\le2X$. Remove prime powers and use partial summation to bound unweighted prime sums on subintervals by $O(X^{1/2}\log^C X)$. With the coefficient variation above the prime average error is $O(X^{-1/2}x_X^{-1/2}\log^C X)=o(x_X)$ for $\delta<2/3$. The principal coefficients give the Haar means. The prime number theorem averages $p^{-\delta/2}$ to $J_\delta X^{-\delta/2}(1+o(1))$. \end{proof} Nonprincipal coefficients can have the size of the second term. For an odd prime $\ell$ and fixed $t>0$, the quadratic character $\chi_\ell$ satisfies $\ell^2\widehat F_{H,t/\ell^2}(\chi_\ell) \to\mathbb E_A F_{H,t}(A)-1/48$. Indeed the local exponents $1$ and $2$ give the means at scales $t/\ell$ and $t$, multiplied by $-h_\ell/(\ell(\ell-1))$ and $h_\ell/\ell^2$, respectively, with $\ell$ omitted from the numerator and cofactor. At scale $y=t/\ell$ the omissions cost $O(y^{-1}\ell^{-2}+\ell^{-2})$, and at scale $t$ they tend to zero by dominated convergence. The higher exponents $k\ge3$ contribute $O_t(\ell^{-4})$ by the bound $O(1/y)$ for the mean at scale $y=t\ell^{k-2}$. The article's \hyperlink{ai-declaration}{AI Declaration} covers the arguments, numerical checks and writing in this supplement.