Rational-phase Type II estimate (source code)

= Rational-phase Type II estimate
{title2=$|S|\ll(Nq^{-1/2}+NX^{-1/2}+\sqrt{Nq})\log^5(2N)$}

Suppose $|a_u|\le\tau(u)$, $|b_d|\le\log(2N)$, $u,d>X\ge1$, $ud\le N$, and $|\theta-a/q|\le q^{-2}$ with $(a,q)=1$. A <dyadic decomposition> reduces $S=\sum a_ub_de(\theta ud)$ to blocks $u\asymp U,d\asymp D$. The <Cauchy-Schwarz inequality>, <divisor-square summatory bound> and the <reciprocal fractional-part sum near a rational> give
$$
|S_{U,D}|^2\ll UD\left(U+\frac{UD}{q}+q+D\right)\log^6(2N).
$$
The condition $ud\le N$ makes the allowed $u$ values for each pair $d_1,d_2$ an interval, so the <exponential geometric sum bound> applies despite the hyperbolic cutoff. Since $UD\le N$ and $U,D\gg X$, take square roots and sum the $O(\log^2(2N))$ blocks to get the displayed estimate.