Reworking $\sum_{n \leq x} \frac{1}{n^s}$, where $n$ is relatively prime to some fixed $k$

For a fixed integer $k \geq 1$ and real $s>0$ I want to rework the partial sums

$$\sum_{\substack{ n \leq x \\ \text{gcd}(k,n) = 1 }} \frac{1}{n^s}$$

in such a way that I can find an asymptotic formula for them. I've tried to express the $\text{gcd}(k,n) = 1$ condition in various ways involving $\mu$; for example, $$\sum_{\substack{ n \leq x \\ \text{gcd}(k,n) = 1 }} \frac{1}{n^s} = \sum_{n\leq x}\frac{1}{n^s}\sum_{d | \text{gcd}(k,n)} \mu(d),$$

since $\sum_{d | \text{gcd}(k,n)} \mu(d)$ is equal to 1 if $k$ and $n$ are relatively prime, and 0 if they aren't. But I can't see where to go from here; the difficulty seems to be that $k$ isn't an index of the summation.

(This is exercise 3.12 in Apostol's Introduction to Analytic Number Theory.)


What follows is too much material for a comment. I would like to point out that we can also get the aymptotics from the Mellin-Perron formula where the difficulty lies in estimating a remainder integral which does not converge absolutely.

Let the prime factorization of $k$ be given by $$k = \prod_q q^v.$$ Then we have by inspection that the Euler product of $$L(t) = \sum_{n\ge 1, \; (k,n) = 1} \frac{1}{n^{s+t}}$$ is given by $$L(t) = \prod_p \frac{1}{1-p^{-s-t}} \prod_q (1-q^{-s-t}) = \zeta(s+t) \prod_q (1-q^{-s-t}).$$

Now recall the Mellin-Perron formula which says that $$\sum_{n=1}^x \lambda_n = \frac{1}{2} \lambda_x + \frac{1}{2\pi i} \int_{c-i\infty}^{c+i\infty} L(t) x^t \frac{dt}{t} \quad\text{where}\quad L(t) = \sum_{n\ge 1} \frac{\lambda_n}{n^t}$$ with $c$ in the half-plane of convergence of $L(t)$ i.e. $\Re(s+t)>1$ or $t>1-s.$ Intersect this with the half-plane of convergence of the Heaviside step function which is $\langle 0, \infty\rangle$ to find that $c=1/2$ is admissible.

Here $\lambda_n = [[(k,n) = 1]] \times \frac{1}{n^s}.$

Observe that when $s>0$ there is a pole at $t = 1 - s$. Suppose $s$ is an integer. There are two cases, $s=1$ or $s>1.$

First case, $s=1$. Then we have a double pole at $t$ zero and $$\mathrm{Res}_{t=0} \left( L(t) \frac{x^t}{t} \right) = (\gamma + \log x) \prod_q (1 - q^{-1}) = \frac{\varphi(k)}{k} (\gamma + \log x)$$ and we immediately have $$\sum_{n=1}^x \lambda_n = \frac{\varphi(k)}{k} (\gamma + \log x) + \frac{1}{2} [[(k, x)=1]] \frac{1}{x^s} + \frac{1}{2\pi i} \int_{-1/2-i\infty}^{-1/2+i\infty} L(t) x^t \frac{dt}{t}.$$

Second case, $s>1.$ Now the pole at $t$ zero becomes a simple pole and $$\mathrm{Res}_{t=0} \left( L(t) \frac{x^t}{t} \right) = \zeta(s) \prod_q (1 - q^{-s})$$ giving for the sum the expansion $$\sum_{n=1}^x \lambda_n = \zeta(s) \prod_q (1 - q^{-s}) + \frac{1}{2} [[(k, x)=1]] \frac{1}{x^s} + \frac{1}{2\pi i} \int_{-1/2-i\infty}^{-1/2+i\infty} L(t) x^t \frac{dt}{t}.$$

Remark. Obviously the difficulty here lies in estimating the remainder integrals. The term $\zeta(s+t)$ is $O(1)$ on the line $\Re(t) = -1/2$ when $s>1$ but does not converge absolutely and when $s=1$ it is right on the critical line.

Addendum Mon Nov 24 23:34:28 CET 2014. Here is an approach that is more in line with what a number theory textbook exercise would likely ask for.

As was pointed out in the first response we can use the following straightforward simplification: $$\sum_{n=1, \; (k,n)=1}^x \frac{1}{n^s} = \sum_{n=1}^x \frac{1}{n^s} \sum_{d|(k,n)} \mu(d) \\ = \sum_{d|k} \mu(d) \sum_{g=1}^{\lfloor x/d \rfloor} \frac{1}{(gd)^s} = \sum_{d|k} \frac{\mu(d)}{d^s} \sum_{g=1}^{\lfloor x/d \rfloor} \frac{1}{g^s}.$$

We once more have two cases.

First case, $s=1.$ We get from the asymptotic $H_n \sim \log n + \gamma$ the value $$\sum_{d|k} \frac{\mu(d)}{d} (\log(x/d) + \gamma) = \log x \prod_q \left(1-\frac{1}{q}\right) + \sum_{d|k} \frac{\mu(d)}{d} (\gamma - \log d).$$

Therefore the dominant term plus the next one are given by $$\frac{\varphi(k)}{k} \log x + \sum_{d|k} \frac{\mu(d)}{d} (\gamma - \log d)$$ where we have determined the constant that does not depend on $x.$

Interestingly enough the constant from Mellin-Perron was not correct which indicates that there is a contribution from the remainder integral that we were not able to evaluate.

The next term in the asymptotics of $H_n$ is $\frac{1}{2n}$ and the error in going from $\log\lfloor w\rfloor$ to $\log w$ is of order $1/w$ which indicates that the next term is $\mathcal{O}(1/x)$ as noted by the first responder.

Second case, $s>1.$

The dominant term here is $\zeta(s)$ and we obtain $$\zeta(s) \sum_{d|k} \frac{\mu(d)}{d^s} = \zeta(s) \prod_q \left(1-\frac{1}{q^s}\right)$$ which matches the asymptotic from Mellin-Perron.


You have the right start. You might have the idea by now that your initial goal will be to reverse the order of summation. I will let $(k,n)$ denote $\gcd(k,n)$.

Claim: $\displaystyle \sum_{\substack{n \leq x \\ (n,k) = 1}} f(n) = \sum_{d \mid k} \mu(d) \sum_{l \leq x/d} f(ld)$

Proof: As you've noticed, $$ \sum_{\substack{n \leq x \\ (n,k) = 1}} f(n) = \sum_{n \leq x} \sum_{d \mid (n,k)} \mu(d) f(n).$$

Now we want to reverse the order of summation. For each divisor $d$ of $k$, we sum over multiples of $d$ that are less than or equal to $x$. So thinking of $n = ld$, we want to include only those $l$ such that $ld \leq x$, or rather $l \leq x/d$. Putting these together allows us to complete the reversal, getting $$ \sum_{d \mid k} \mu(d) \sum_{l \leq x/d} f(ld),$$ and proving the claim. $\diamondsuit$

For us, this means that $$\sum_{\substack{n \leq x \\ (n,k) = 1}} \frac{1}{n^s} = \sum_{d \mid k} \frac{\mu(d)}{d^s} \sum_{l \leq x/d} \frac{1}{l^s}.$$

Now the analysis is somewhat straightforward. When $s = 1$, you can use your knowledge of $\displaystyle \sum_{n \leq y} \frac{1}{n}$ to get the desired asymptotic $$ \frac{\varphi(k)}{k}(\log x + \gamma) + C_k + O\left( \tfrac{1}{x} \right),$$ where $\gamma$ is the Euler-Mascheroni constant and $C_k$ is a constant depending on $k$ which can be given explicitly.

When $s \neq 1$, then you use your knowledge of $\displaystyle \sum_{n \leq y} \frac{1}{n^s}$ to produce a similar asymptotic.