\section{Triangle counts at almost every scale}\label{sec:metric} Fix an irrational number $\theta>1$. For $t\ge0$ put \[ L(t)=\#\{(i,j)\in\Z_{\ge0}^2:i+\theta j\le t\}, \qquad d(t)=L(t)-\frac{t^2}{2\theta}-\frac{1+\theta^{-1}}2t . \] The error for integer dilates of the triangle with defining coefficients $u=1/\lambda$, $v=\theta/\lambda$ is $d(n\lambda)$. The condition $\theta>1$ fixes an ordering of the two axes. \begin{theorem}\label{thm:main} There is an absolute constant $c>0$ with the following property. Fix $0<\delta<1/6$. For Lebesgue-almost every $\lambda>0$, for both signs $\sigma\in\{-1,1\}$, and for every sufficiently large dyadic integer $N=2^j$, \[ \#\{N\le n<2N:\ \sigma d(n\lambda)> c\delta\log N\} \gg_{\theta,\lambda,\delta} N^{1-\delta}. \] If $\theta$ has bounded partial quotients, $d(t)=O_\theta(\log(2+t))$ for all real $t\ge0$. \end{theorem} Hardy and Littlewood studied the real-parameter count and obtained its logarithmic upper bound for bounded partial quotients \cite{hl}. In their work on symplectic staircases, Cristofaro-Gardiner, Holm, Mandini and Pires asked for logarithmic excursions at integer dilations for triangles satisfying the hypotheses of Conjecture~6.14 as stated in Appendix~\ref{sec:scales} \cite[Conjecture 6.14]{cg}. Theorem~\ref{thm:main} gives those excursions for almost every choice of scale at each such slope, with a quantitative frequency bound. The assignment of scale remains important for applying the question to an individual symplectic domain. \begin{corollary}\label{cor:dim} The set of scales $\lambda>0$ satisfying either of the conditions \[\limsup_{n\to\infty} \frac{d(n\lambda)}{\log n}\le0,\qquad \liminf_{n\to\infty}\frac{d(n\lambda)}{\log n}\ge0\] has Hausdorff dimension at most $5/6$. \end{corollary} \subsection{A positive measure of excursions at real dilates} Let $w(x)=\{x\}-1/2$ on $\T=\R/\Z$, and set $S_h(x)=\sum_{r=0}^{h-1}w(x+r\theta)$ for $h\ge1$. Writing $t=\theta(M+z)$, $M\in\Z_{\ge0}$, $0\le z<1$, and summing horizontal rows gives \begin{equation}\label{eq:rows} d(t)=\frac{1+(\theta-1)z-\theta z^2}{2}-S_{M+1}(\theta z). \end{equation} Indeed, $L(t)=\sum_{r=0}^M(1+\lfloor\theta(r+z)\rfloor)$. The first term on the right of \eqref{eq:rows} is uniformly bounded. \begin{lemma}\label{lem:real} There is an absolute $b>0$ such that, for fixed $\delta\in(0,1)$ and any compact scale interval $K=[a,A]\subset(0,\infty)$, \[ \meas\{t\in[5\lambda N/4,7\lambda N/4]: \sigma d(t)\ge b\delta\log N\} \gg_{K,\theta}N^{1-\delta} \] for $N$ sufficiently large, uniformly in $\lambda\in K$ and $\sigma\in\{-1,1\}$. \end{lemma} \begin{proof} Set $H=\lfloor N^\delta\rfloor$. Apply Schmidt's Theorem~1 \cite{schmidt} to the sequence $0,\{\theta\},\{2\theta\},\ldots$. For some $1\le m\le H$ and some $y\in[0,1]$ the discrepancy of the first $m$ points in $[0,y)$ exceeds $c_0\log H$ in absolute value, with an absolute $c_0>0$. This discrepancy, with its sign, is $S_m(-y)-S_m(0)$. It follows that $|S_m(x_0)|\ge c_0\log H/2$ at some $x_0$. For $s\ge0$ one has $S_m(x+s)\le S_m(x)+ms$. Thus, throughout an interval $J$ of length $1/(2m)$, one has $|S_m(x)|\ge c_0\log H/2-1$. Use the interval to the left of $x_0$ at a positive value and to the right at a negative value. Put $B=c_0\log H/8$. For all sufficiently large $N$ the preceding bound is greater than $2B$. The identity \[ S_{h+m}(x)-S_h(x+m\theta)=S_m(x) \] implies \[ \meas\{|S_{h+m}|>B\}+\meas\{|S_h|>B\}\ge |J|\ge1/(2H) \] for every $h\ge1$, using normalized measure on $\T$. Reflection $x\mapsto -x-(h-1)\theta$ negates $S_h(x)$ off a finite set, so each sign has half the measure of the absolute-value event. Let $\mathcal H$ be the consecutive positive integers $h$ such that $[\theta(h-1),\theta h]\subset[5\lambda N/4,7\lambda N/4]$. Since $m=o(N)$, at least $c_{K,\theta}N$ indices $h$ satisfy $h,h+m\in\mathcal H$. Summing the measure bounds over these indices counts each row at most twice. Consequently \[ \sum_{h\in\mathcal H}\meas\{x:\sigma S_h(x)>B\} \gg_{K,\theta}N/H. \] For each $h$ keep the subinterval $0\le z<1/\theta$ of row $M=h-1$ in \eqref{eq:rows}. There $x=\theta z$ runs once through $[0,1)$ and $dt=dx$. Using the opposite sign for $S_h$ in \eqref{eq:rows} and absorbing the bounded quadratic term proves the assertion, for example with $b=c_0/32$. \end{proof} \subsection{Sampling at integer multiples} For functions on the real line define \[ D_N f(y)=\frac1N\sum_{N\le n<2N}f(y+\log(n/N)),\qquad A f(y)=\int_1^2 f(y+\log x)\,dx . \] A Fourier multiplier estimate allows these two operators to be compared even for functions whose features have width $N^{-2}$. \begin{lemma}\label{lem:sample} Fix $\psi\in C_c^\infty(\R)$, and set $\psi_N(y)=N^2\psi(N^2y)$. For integer $N\ge2$ and $f\in L^2(\R)$, \[ \|(D_N-A)(f*\psi_N)\|_2\ll_{\psi}N^{-1/6}\|f\|_2. \] \end{lemma} \begin{proof} Up to the sign of the frequency the multiplier of $D_N-A$ is \[ V_N(\xi)=N^{-1}\sum_{N\le n<2N}(n/N)^{i\xi} -\int_1^2 x^{i\xi}\,dx . \] We prove the weighted estimate \[ |V_N(\xi)|\ll N^{-1/6}(1+|\xi|/N^2)^{1/4}. \] For $|\xi|\le N^{1/2}$ a Riemann sum estimate gives $O((1+|\xi|)/N)$. The integral is $O(1/|\xi|)$ at larger frequencies. For $N^{1/2}\le|\xi|\le N^{5/3}$ the van der Corput second derivative estimate \cite[Theorem 2.2]{gk} bounds the normalized exponential sum by $O(\sqrt{|\xi|}/N+1/\sqrt{|\xi|})=O(N^{-1/6})$. For $|\xi|\ge N^{5/3}$ take $H=\lfloor N^{1/3}\rfloor$ and difference the sum with shifts $1\le h\le H$. The second derivative of the difference phase $\xi(\log(x+h)-\log x)$ has magnitude comparable to $h|\xi|/N^3$ on the overlap. The same estimate bounds each differenced sum, normalized by $N$, by \[ O\left(\sqrt{h|\xi|/N^3}+\sqrt{N/(h|\xi|)}\right) =O\left(N^{-1/3}(1+\sqrt{|\xi|/N^2})\right). \] The van der Corput differencing inequality \cite[Lemma 2.5]{gk} bounds the square of the original normalized sum by this last bound plus $O(H^{-1})$, giving the claimed weighted estimate. The factor $(1+|\xi|/N^2)^{1/4}$ is absorbed by the rapid decay of $\widehat\psi(\xi/N^2)$. Plancherel's theorem concludes the proof. \end{proof} \begin{proof}[Proof of Theorem~\ref{thm:main}] Work on $K=[a,A]\subset(0,\infty)$ and fix $\sigma=\pm1$. Let $f_N$ be the indicator of the following subset of the log-coordinate: \[ \{y:\ a/2\le e^y\le3A,\quad \sigma d(Ne^y)\ge b\delta\log N\}. \] Take a nonnegative smooth kernel $\psi$ of integral one supported in $[0,1]$ for $\sigma=1$ and in $[-1,0]$ for $\sigma=-1$, and write $g_N=f_N*\psi_N$. Then $0\le g_N\le1$ and $\|f_N\|_2=O_K(1)$. Lemma~\ref{lem:real} gives \begin{equation}\label{eq:lower} A g_N(\log\lambda)\ge c_K N^{-\delta}\qquad(\lambda\in K), \end{equation} where $c_K>0$ may also depend on $\theta$. Indeed for every $|s|\le N^{-2}$ the interval of $t=N\lambda e^{-s}x$, $1\le x\le2$, contains $[5\lambda N/4,7\lambda N/4]$ for all large $N$. Throughout this latter interval the cutoff $a/2\le t/N\le3A$ holds, and $dx=e^s dt/(N\lambda)$. There is a constant $C_{K,\theta}$ such that whenever $e^y\in[a,2A]$, \begin{equation}\label{eq:stable} g_N(y)>0\quad\Longrightarrow\quad \sigma d(Ne^y)\ge b\delta\log N-C_{K,\theta}. \end{equation} In fact there is $s$ in the support of $\psi_N$ with $\sigma d(Ne^{y-s})\ge b\delta\log N$. The two arguments differ by $O_K(1/N)$. The subtracted polynomial changes by $O_{K,\theta}(1)$, and monotonicity of $L$ gives the required direction for each sign. By Lemma~\ref{lem:sample}, \eqref{eq:lower} and Chebyshev's inequality, the set of $\lambda\in K$ on which $D_Ng_N(\log\lambda)5/6+\delta$. Hence $\dim_H(\limsup_N F_N)\le 5/6+\delta$. The set with $\limsup_n\sigma d(n\lambda)/\log n\le0$ lies in this limsup for every $\delta>0$. Let $\delta\downarrow0$, take the union of the two signs and exhaust $(0,\infty)$. \end{proof}