Let $A,B$ be two positive numbers, I wonder how to show the following estimate
$$\sum_{A\le p \le A+B, (p,q)=1} 1 = \frac{B\varphi(q)}{q}+\ O(q^{\epsilon})$$
for any $\epsilon > 0$ and positive integer $q$.
The formula looks intuitively quite true, since $\frac{\varphi(q)}{q}$ is like the "frequency" of number of integers coprime to $q$ and $B$ is just the length of the interval. But I have no idea how to give the error term. $O(q^{\epsilon})$ may or may not be optimal, I don't know.
If the proof is well-known but too long, please feel free to let me know the reference. (The problem might be just in thr book of Apostol but I can't find it)
The standard trick of writing the indicator function of $(p,q)=1$ as $e((p,q)) = \sum_{d\mid (p,q)} \mu(d)$ and then switching the order of summation works here, as already covered in this answer: https://math.stackexchange.com/a/3158036/30402
The error term is bounded by $d(q)$, which is well-known to be $O_\epsilon(q^\epsilon)$ for every $\epsilon>0$ (some references here). More precisely, it is bounded above by something of size $\exp((\ln 2 + o(1)) \log q / \log \log q)$. Not to say that this is the best possible error term, just the best one afforded by this method.