Prove that $\sum_{n\leq x , gcd(3,n)=1} \frac{ \tau(n)}{n} = \frac{ 2(\log x)^2} {9} +O(\log x)$ This question is from my number theory assignment and I was not able to solve it. I have been following  Analytic Number Theory by Dekonick and Luca.

Let $\tau(n)$ be the number of divisors of n. Show that $\sum_{n\leq x , gcd(3,n)=1} \frac{ \tau(n)}{n} = \frac{ 2(\log x)^2} {9}  +O(\log x)$.

As $\tau(n) =\sum_{d|n} 1$, gcd(3,n)=1 means that n of the form 3m+1, 3m+2  ($m\in \mathbb{Z}$).
I can't change n to n=qd and then writing $\sum_{n\leq x} d(n) = \sum_{q,d , qd \leq x} 1$ because summation is only over 3n+1 , 3n+2.
So, Can you please tell how should I approach this problem ?
Thanks!
 A: It would be interesting if we consider the following generalized problem:
$$
F(x)=\sum_{\substack{n\le x\\(n,q)=1}}{\tau(n)\over n}
$$
To approach this, we consider studying the Dirichlet series associated to $F(x)$:
\begin{aligned}
\hat F(s)
&=\sum_{\substack{n\ge1\\(n,q)=1}}{\tau(n)\over n^s}=\prod_{p\nmid q}\left(1-{1\over p^s}\right)^{-2} \\
&=\zeta^2(s)\prod_{p|q}\left(1-{1\over p^s}\right)^2
\end{aligned}
This indicates that if we define
$$
f(n)=
\begin{cases}
\tau(n)/n & (n,q)=1 \\
0 & \text{otherwise}
\end{cases}
$$
and
$$
G(s)=\sum_{n\ge1}{g(n)\over n^s}=\prod_{p|q}\left(1-{1\over p^{s+1}}\right)^2
$$
Then we have
$$
f(n)=\sum_{n=ab}g(a){\tau(b)\over b}
$$
and
$$
F(x)=\sum_{n\le x}f(n)=\sum_{a\le x}g(a)\sum_{b\le x/a}{\tau(b)\over b}
$$
This means our task gets transformed into evaluating the inner sum. For convenience, set $z=x/a$, so that Stieltjes integration gives
\begin{aligned}
\sum_{b\le z}{\tau(b)\over b}
&=\sum_{m\le z}\frac1m\sum_{n\le z/m}\frac1n=\sum_{m\le z}\frac1m\left[\log\frac zm+\mathcal O(1)\right] \\
&=\sum_{m\le z}{\log z\over m}-\sum_{m\le z}{\log m\over m}+\mathcal O(\log z) \\
&=\frac12(\log z)^2+\mathcal O(\log z) \\
&=\frac12(\log x)^2+\mathcal O\left\{\log x(\log a)^2\right\}
\end{aligned}
Plugging this result back in, we get
$$
F(x)=\frac12(\log x)^2\sum_{a\le x}g(a)+\mathcal O\left\{\sum_{a\le x}|g(a)|(\log a)^2\log x\right\}
$$
Because for every fixed $q$, $G(s)$ converges absolutely everywhere. Therefore using the identity $G(1)=\varphi(q)^2/q^2$, we see that for every fixed $q>0$, there is
$$
\sum_{\substack{n\le x\\(n,q)=1}}{\tau(n)\over n}={\varphi(q)^2\over2q^2}(\log x)^2+\mathcal O(\log x)
$$
Plugging in $q=3$ gives exactly what the OP asked for.
