# Inequality with sum involving minimums

I am working through lemma 2.2 of the Hardy-Littlewood Circle Method: Second Edition by R.C. Vaughan and I am having some trouble with a step in his proof of the following lemma:

Suppose that $X$, $Y$, and $\alpha$ are real numbers with $X,Y\geq 1$, and $\lvert\alpha-\frac{a}q\rvert \leq q^{-2}$ with $(a,q)=1$. Then, $$\sum_{x\leq X} \min\left(XYx^{-1}, \lvert\lvert\alpha x\rvert\rvert^{-1}\right) \ll XY\left(\frac1q+\frac1Y+\frac{q}{XY}\right)\log(2Xq)$$ Where we take $\lvert\lvert\beta\rvert\rvert=\min_{y\in\mathbb{Z}}\lvert \beta-y\rvert$.

The proof opens by defining $S=\sum_{x\leq X} \min\left(XYx^{-1}, \lvert\lvert\alpha x\rvert\rvert^{-1}\right)$, and then states immediately that "Clearly" $$S\leq \sum_{0\leq j\leq X/q}\sum_{r=1}^q \min\left(\frac{XY}{qj+r}, \lvert\lvert\alpha(qj+r)\rvert\rvert^{-1}\right)$$ But, I have no clue how we arrived at this step. I know that the $\lvert\alpha-a/q\rvert\leq q^{-2}$ looks like Dirichlet's theorem for Diophantine approximation, but I don't see quite how to apply it, or if it is even being used at this point in the proof. Can anyone provide a hint for this step or suggest some readings that provide a bit more detail on this proof?

This step is just extending the sum by a few nonnegative terms. If we define

$$f(x) = \min \bigl(XYx^{-1}, \lVert \alpha x\rVert^{-1}\bigr)$$

and write $X = m\cdot q + \rho$ with $0 \leqslant \rho < q$, then

$$\sum_{x \leqslant X} f(x) = \sum_{x = 1}^{mq + \lfloor\rho\rfloor} f(x)$$

and

$$\sum_{0 \leqslant j \leqslant X/q} \sum_{r = 1}^{q} f(qj + r) = \sum_{j = 0}^{m} \sum_{r = 1}^{q} f(qj+r) = \sum_{x = 1}^{(m+1)q} f(x)\,.$$

Since $f(x) \geqslant 0$ for all $x > 0$ and the second sum contains more terms than the first (strictly more, by $\lfloor \rho\rfloor \leqslant q-1 < q$) we have the "clear" inequality. It is indeed clear if you know what to look at, but not so much if you don't.