TITLE: Sum of log p/p for p equivalent to l mod D
QUESTION [12 upvotes]: It's fairly classical that for $D>1$ and $(D,l)=1$ one has
$$\sum_{\stackrel{p\leq x}{p\equiv l\; (mod \; D)}}\frac{\log p}{p} = \frac{\log x}{\phi(D)} + \textrm{O}(1)$$
where if I understand correctly the dependence on $D$ in the $\textrm{O(1)}$ is captured by something like
$$\frac{1}{\phi(D)}\sum_{\textrm{non-principal} \; \chi}\frac{-L'(1,\chi)}{L(1,\chi)}$$
which is $\ll_{\epsilon}D^{\epsilon}$ for any $\epsilon>0$.  If this is correct, suppose I am interested in the sum
$$\sum_{\stackrel{p\leq x}{\left(\frac{-D}{p}\right)=1}}\frac{\log p}{p}$$
where $\left(\frac{-D}{p}\right)$ is the Legendre symbol.  There are $\phi(D)/2$ residue classes mod $D$ that $p$ can lie in, and so then this is just my previous sum $\phi(D)/2$ times, and I get that it's $1/2 \log x +\textrm{O}(1)$, where the dependence on $D$ in $\textrm{O}(1)$ is now something like $\textrm{O}(D^{1+\epsilon})$.  Is this the best one can do?  I was hoping I could get it to be $\textrm{O}(D^{\epsilon})$ but if that's not even correct perhaps I should stop trying.

REPLY [15 votes]: You're right that your proposed method for estimating the new sum, while correct, gives a worse error bound than we can obtain otherwise. Rather than quoting the classical result itself, I suggest going back to the proof of that classical result and modifying it to address the new sum.
Somewhat more precisely: the Legendre symbol $\big( \frac{-D}p \big)$, or rather its multiplicative generalization the Jacobi symbol $\big( \frac{-D}n \big)$, is a Dirichlet character (mod $D$)—call it $\chi_1(n)$. The sum you are interested in is just
$$
\sum_{p\le x} \frac{\log p}p \bigg( \frac{1+\chi_1(p)}2 \bigg).
$$
(Not exactly, since this expression counts primes dividing $D$ with weight $1/2$, but that's easily dealt with.) Therefore you're left with needing to understand $\sum_{p\le x} (\log p)/p$ (no problem) and $\sum_{p\le x} (\chi_1(p)\log p)/p$. The latter sum is going to be $O(1)$ in the same way that the error term in the classical problem is $O(1)$; it is going to be related to $-L'(1,\chi_1)/L(1,\chi_1)$. So in fact you don't have all the different $-L'(1,\chi)/L(1,\chi)$ error terms to deal with, only the single one where $\chi=\chi_1$.