I am trying to deduce an upper bound for $\sum_\limits{p\equiv a \pmod q, p\leq x}\frac{1}{p}$ where $p$ is a prime and $(a,q)=1$. Using Theorem 1 of Carl Pomerance's article on amicable numbers (which uses simple partial summation), one straightaway obtains, for $x\ge3$ and an absolute constant $A>0$, $$\sum_\limits{p\equiv a \pmod q, p\leq x}\frac{1}{p}<\frac{3}{2}+\frac{\log\log x}{\phi(q)}+\frac{\log q}{\phi(q)}+\frac{A+1}{q\phi(q)}+\frac{A}{q^2\phi(q)}.$$ But this error term doesn't suit my needs since I want the minor terms to be in the form $E(x,q)$. So, one can probably derive a better estimate using the Large-Sieve inequality as stated in Theorem 4.2 of Montgomery's book on multiplicative number theory but this gives an even worse estimate of the form $O\left(\frac{\sqrt{x}}{\sqrt{\log x}}\right)$ since I guess, the sum $\sum\limits_{n}|a_n|^2$ is convergent. But the large sieve inequality is supposed to give a better or maybe an optimal bound of the form $\frac{2\log\log x}{\phi(q)}+E(x,q)$ if we choose suitable (smooth) weight functions to get small Fourier coefficients.

But I am unable to see what could be those weight functions and how to modify the large sieve inequality accordingly. On the other hand, since this seems to be such a well-known mathematical expression, does there exist any previous work that deals with this using the large sieve inequality? If yes, then could somebody refer it to me?

independentof $a$ and $q$. One certainly cannot replace $A$ by a function tending to 0 with $x$, since there is genuinely a constant term in the asymptotic expansion of the sum. $\endgroup$1more comment