Upper bound for a higher dimensional Ramanujan sum Fix an integer vector $\mathbf m\in \mathbb Z^k$. Let $q$ be a positive integer.
Is there a "good" upper bound in terms of $q,\bf m$ for the exponential sum:
\[\sum_{\mathbf n} e\left(\frac{\langle m, n\rangle}{q}\right).\]
Here $\langle \cdot, \cdot \rangle$ is usual inner product and $e(z) = e^{2\pi i z}$. The sum is taken over all ${\mathbf n=(n_1,\cdots,n_k)}$ such that $1\le n_i\le q$ and $gcd(n_1,\cdots,n_k,q)=1$.
When $k=1$, this is the famous Ramanujan sum. I have tried searching relevant results, but could not find any useful reference for $k\ge 2$. Any answers or references are appreciated!
 A: Call this sum $c_q(m_1,\ldots,m_k)$. The indicator function of the condition $(n_1,\ldots,n_k,q) = 1$ can be written as the sum $\sum_{cd = (n_1,\ldots,n_k,q)} \mu(c)$, so that $d \mid q$, $c = \frac{q}{d}$, and $n_j \equiv 0 \pmod{c}$ for all $j \in \{1,\ldots,k\}$. It follows that $c_q(m_1,\ldots,m_k)$ may be written as
\[\sum_{cd = (n_1, \ldots, n_k,q)} \mu(c) \prod_{j = 1}^{k} \sum_{n_j = 1}^{q} e\left(\frac{n_j m_j}{q}\right)= \sum_{d \mid q} \mu\left(\frac{q}{d}\right) \prod_{j = 1}^{k} \sum_{\substack{n_j = 1 \\ n_j \equiv 0 \pmod{\frac{q}{d}}}}^{q} e\left(\frac{n_j m_j}{q}\right).
\]
Writing $n_j = \frac{q}{d} \ell_j$, the inner sum is
\[\sum_{\ell_j = 1}^{d} e\left(\frac{\ell_j m_j}{d}\right)
= \begin{cases}
d & \text{if $d \mid m_j$,} \\
0 & \text{otherwise.}
\end{cases}\]
So
\[c_q(m_1,\ldots,m_k) = \sum_{d \mid (m_1, \ldots, m_k, q)} \mu\left(\frac{q}{d}\right) d^k.\]
This is multiplicative as a function of $q$, so that
\[c_q(m_1,\ldots,m_k) = \prod_{p^r \parallel q} c_{p^r}(m_1,\ldots,m_k).\]
So we need only determine $c_q(m_1,\ldots,m_k)$ when $q = p^r$ is a prime power. Since
\[\mu(p^r) = \begin{cases}
1 & \text{if $r = 0$,} \\
-1 & \text{if $r = 1$,} \\
0 & \text{if $r \geq 2$,}
\end{cases}\]
we have that for $q = p$,
\[c_p(m_1,\ldots,m_k) = \begin{cases}
p^k - 1 & \text{if $p \mid (m_1,\ldots,m_k)$,} \\
-1 & \text{if $p \nmid (m_1,\ldots,m_k)$,}
\end{cases}\]
while for $q = p^r$ with $r \geq 2$,
\[c_{p^r}(m_1,\ldots,m_k) = \begin{cases}
p^{(r - 1)k} (p^k - 1) & \text{if $p^r \mid (m_1,\ldots,m_k)$,} \\
-p^{(r - 1)k} & \text{if $p^{r - 1} \parallel (m_1,\ldots,m_k)$,} \\
-1 & \text{if $p^{r - 1} \nmid (m_1,\ldots,m_k)$.}
\end{cases}\]
