What is the error term in Mertens' first theorem for arithmetic progressions?

I am asking this question here, since my comment on this post on Math Overflow got no responses.

I need an explicit (computable) bound on the $O(1)$ term in the following asymptotic formula: $$\sum_{\substack{p\le x \\p\equiv a\;(\text{mod} \; q)}}\frac{\log(p)}{p}=\frac{\log(x)}{\phi(q)}+O(1),$$ where $\gcd(a,q)=1$. Specifically for the cases $q=4$ and $a\in\{1,2\}$. However, using the prime number theorem for arithmetic progressions, I have not been able to get the error better than $O(\log(\log(n)))$. This is what I have done so far:

let $\pi(x;q,a)$ denote the number of primes less than or equal to $x$ that are congruent to $a$ modulo $q$. By Abel's summation formula, we have \begin{equation} \sum_{\substack{p\le x \\ p\equiv a (\text{mod}\; q)}}\frac{\log(p)}{p}=\frac{\log(x)}{x}\pi(x;q,a)+\int_{2}^{x}\frac{\log(t)-1}{t^2}\pi(t;q,a)dt \hspace{8mm}(1)\end{equation} Let $\theta(x;q,a):=\sum_{\substack{p\le x \\ p\equiv a (\text{mod}\; q)}}\log(p)$. Then \begin{align*} \pi(x;q,a)=\frac{\theta(x;q,a)}{\log(x)}+\int_{2}^{x}\frac{\theta(t;q,a)}{t\log^2(t)}dt \end{align*} by the result on page 142 here. Therefore: \begin{align*} \frac{\log(x)}{x}\pi(x;q,a)=\frac{\theta(x;q,a)}{x}+\frac{\log(x)}{x}\int_{2}^{x}\frac{\theta(t;q,a)}{t\log^2(t)}dt. \end{align*} The term $\tfrac{\theta(x;q,a)}{x}=\frac{1}{\phi(q)}+o(1)$, while $$\frac{\log(x)}{x}\int_{2}^{x}\frac{\theta(t;q,a)}{t\log^2(t)}dt=\frac{\log(x)}{x}O(\frac{x}{\log^2(x)})=O(\frac{1}{\log(x)})=o(1).$$ Thus, it remains to consider the integral in $(1)$. We have \begin{align*} \int_{2}^{x}\frac{\log(t)-1}{t^2}&\pi(t;q,a)dt=\int_{2}^{x}\frac{\log(t)}{t^2}\pi(t;q,a)dt-\int_{2}^{x}\frac{\pi(t;q,a)}{t^2}dt. \hspace{6mm} (2) \end{align*} Let $\varepsilon$ be defined by $\tfrac{\log(t)\pi(t;q,a)}{t}=\frac{1}{\phi(q)}+\varepsilon(t)$. Then the first integral in the right hand side of $(2)$ can be written as \begin{align*} \int_{2}^{x}\frac{\log(t)\pi(t;q,a)}{t^2}dt=&\int_{2}^{x}\frac{1}{t}\cdot \frac{\log(t)\pi(t;q,a)}{t}dt=\int_{2}^{x}\frac{1}{t}\cdot (\frac{1}{\phi(q)}+\varepsilon(t))dt\\[1mm] =&\frac{\log(x/2)}{\phi(q)}+\int_{2}^x\frac{\varepsilon(t)}{t}dt. \end{align*} The second integral in the right hand side of $(2)$ can be written as \begin{align*} \int_{2}^{x}\frac{\pi(t;q,a)}{t^2}dt=&\int_{2}^{x}\frac{1}{t\log(t)}\cdot \frac{\log(t)\pi(t;q,a)}{t}dt\\ =& \int_{2}^{x}\frac{1}{t\log(t)}\cdot (\frac{1}{\phi(q)}+\varepsilon(t))dt\\ =&\frac{\log(\log(x))-\log(\log(2))}{\phi(q)}+\int_{2}^x\frac{\varepsilon(t)}{t\log(t)}dt. \end{align*} Thus, we have: \begin{align*} \sum_{\substack{p\le x \\ p\equiv q (\text{mod}\; q)}}\frac{\log(p)}{p}=\frac{1}{\phi(q)}+\frac{\log(x/2)}{\phi(q)}-\frac{\log(\tfrac{\log(x)}{\log(2)})}{\phi(q)}+\int_{2}^x\frac{\varepsilon(t)}{t}dt-\int_{2}^x\frac{\varepsilon(t)}{t\log(t)}dt+o(1) \end{align*} Thanks to the result on page 6 here, if $1\le q\le 1200$ is an integer, and $a$ is coprime to $q$, then $$\frac{x}{\phi(q)\log(x)}<\pi(x;q,a)<\frac{x}{\phi(q)\log(x)}(1+\frac{5}{3\log(x)})$$ for all $x\ge 50q^2$. Consequently, $$0<\varepsilon(x)<\frac{5}{2\phi(q)\log(x)}$$ for $x \ge 50q^2$. For our purposes we have $q=4$, so the bound holds for $x\ge 800$. Assuming $x\ge 800$, we then have \begin{align*} \int_{2}^x\frac{\varepsilon(t)}{t}dt=\int_{2}^{800}\frac{\varepsilon(t)}{t}dt+\int_{800}^x\frac{\varepsilon(t)}{t}dt, \end{align*} where \begin{align*} 0<\int_{800}^x\frac{\varepsilon(t)}{t}dt<\frac{5}{2\phi(q)}\int_{800}^x\frac{1}{t\log(t)}dt=\tfrac{5}{2\phi(q)}\log(\log(x))-\tfrac{5}{2\phi(q)}\log(\log(800)). \end{align*} Moreover, \begin{align*} \int_{2}^x\frac{\varepsilon(t)}{t\log(t)}dt=&\int_{2}^{800}\frac{\varepsilon(t)}{t\log(t)}dt+\int_{800}^x\frac{\varepsilon(t)}{t\log(t)}dt, \end{align*} where \begin{align*} 0<\int_{800}^x\frac{\varepsilon(t)dt}{t\log(t)}<\frac{5}{2\phi(q)}\int_{800}^x\frac{dt}{t\log^2(t)}=\frac{5}{1600\phi(q)\log(800)}-\frac{5}{2\phi(q)\log(x)}. \end{align*} As a conclusion, I get that \begin{align*} \sum_{\substack{p\le x \\ p\equiv a (\text{mod}\; q)}}\frac{\log(p)}{p}=const.-\frac{\log(\frac{\log(x)}{\log(2)})}{\phi(q)}+\frac{\log(x)}{\phi(q)}+\int_{800}^x\frac{\varepsilon(t)}{t}dt-\int_{800}^x\frac{\varepsilon(t)}{t\log(t)}dt+o(1). \end{align*} However, for the error term(the stuff between $conts.$ and $o(1)$, call it $r(x)$), the best I get is \begin{align*}\frac{5}{2\phi(q)\log(x)}-\frac{5}{1600\phi(q)\log(800)}-\frac{\log(\frac{\log(x)}{\log(2)})}{\phi(q)}<r(x)<\frac{2\log(\log(x))}{3\phi(q)}+\frac{\log(\log(2))}{\phi(1)},\end{align*} which I cannot see is better than $O(\log(\log(x)))$.

It have tried using the Siegel–Walfisz theorem, but so far been unsuccessful. I know the constant in the theorem is not effectively computable, so I don't see how I can get the bound explicit using the theorem.


If $k=\mathcal{O}(\log^\alpha x)$, then by the Siegel–Walfisz theorem $$ \theta (x;k,\ell ) = \frac{x}{{\phi (k)}} + \mathcal{O}(xe^{ - c(\alpha )\sqrt {\log x} } ). $$ Thus, by partial summation, \begin{align*} \sum_{\substack{p\le x \\p\equiv \ell \,(\text{mod} \, k)}}\frac{\log p }{p} & = \frac{{\theta (x;k,\ell )}}{x} + \int_1^x {\frac{{\theta (t;k,\ell )}}{{t^2 }}dt} \\ & = \frac{{\theta (x;k,\ell )}}{x} + \frac{1}{{\phi (k)}}\int_1^x {\frac{{dt}}{t}} + \int_1^{ + \infty } {\frac{1}{{t^2 }}\left[ {\theta (t;k,\ell ) - \frac{t}{{\phi (k)}}} \right]dt} \\ &\quad\; - \int_x^{ + \infty } {\frac{1}{{t^2 }}\left[ {\theta (t;k,\ell ) - \frac{t}{{\phi (k)}}} \right]dt} \\ & = \frac{{\log x}}{{\phi (k)}} + \frac{1}{{\phi (k)}} + \int_1^{ + \infty } {\frac{1}{{t^2 }}\left[ {\theta (t;k,\ell ) - \frac{t}{{\phi (k)}}} \right]dt} \\ & \quad\; - \mathcal{O}(1)\int_x^{ + \infty } {\frac{1}{t}e^{ - c(\alpha )\sqrt {\log t} } dt} + \mathcal{O}(e^{ - c(\alpha )\sqrt {\log x} } ) \\ & = \frac{{\log x}}{{\phi (k)}} + \frac{1}{{\phi (k)}} + \int_1^{ + \infty } {\frac{1}{{t^2 }}\left[ {\theta (t;k,\ell ) - \frac{t}{{\phi (k)}}} \right]dt} + o(1). \end{align*} The error term may be improved from $o(1)$ to $$ \mathcal{O}(\sqrt {\log x} \,e^{ - c(\alpha )\sqrt {\log x} } )=\mathcal{O}(e^{ - d(\alpha )\sqrt {\log x} } ). $$


We have \[ \text { something you know }=\sum _{n\leq x}\log n=\sum _{d\leq x}\Lambda (d)\sum _{n\leq x\atop {d|n}}1=\text { main term }-\sum _{d\leq x}\Lambda (d)\left \{ \frac {x}{d}\right \} \approx ...-\sum _{p\leq x}\log p\left \{ \frac {x}{p}\right \} \]

and an asymptotic for this last sum is classical, although I don't know a reference. I assume it amounts to the PNT.

Perhaps you could look for a reference and see what changes you need to do when looking at arithmetic progressions. I believe it would be as reuns says above that it's the PNT for AP.