Reciprocal fractional-part sum near a rational (source code)

= Reciprocal fractional-part sum near a rational

If $(a,q)=1$, $|\alpha-a/q|\leq q^{-2}$, and $M,R\geq2$, then uniformly in $m_0$,
$$
\sum_{m_0\leq m<m_0+M}\min(R,\|\alpha m\|^{-1})
\ll(\log q)\left(\frac{MR}{q}+M+R+q\right).
$$
Split the interval into blocks of length at most $q/2$. Within a block the points $\alpha m$ are $\gg1/q$-separated modulo one; ordering their distances from the nearest integer gives $O(R+q\log q)$ per block.