Consider the following function, where below $r$ is a fixed real number, and $q$ is a positive integer
$$f(q) = \sum_{\substack{k = 1 \\ (k, q) = 1}}^{q} e^{\frac{2 \pi i k r}{q}}$$ I wished to determine the asymptotic behavior of this function as $q \rightarrow \infty$, for fixed $r$. When $r$ is an integer, I note that the above sum becomes the Ramanujan sum $c_q(r)$ which is $O(1)$ (since $|c_q(r)| \leq \sigma(r)$)
However for general $r$, it's not at all clear to me how to concretely bound this function, beyond the naive bound that $$f(q) \leq \phi(q)$$ I have a heuristic to think that $$f(q) = O(\sqrt{\phi(q)})$$ since we can think of $f(q)$ as a sum of $\phi(q)$ "random" exponential terms, which would have an expectation value of $O(\sqrt{\phi(q)})$. However, I am not sure how to make this argument rigorous.