# Rewrite $\sum_{p\leq \sqrt x}\frac{x}{p\log(x/p)}$ using Abel's summation formula

My problem is to show that $$\sum_{p\leq \sqrt x}\frac{x}{p\log(x/p)}=x\int_{2}^{\sqrt{x}}\frac{1}{u\log(x/u)\log u}\,\mathrm{d}u+O(x/\log x)$$ using Abel's summation formula and PNT. It is understood that $p$ is prime here. Letting $\phi(n)=\frac{x}{n\log(x/n)}$, we have $$\sum_{p\leq \sqrt x}\frac{x}{p\log(x/p)}=\pi(\sqrt x)\phi(\sqrt x)-\int_{2}^{\sqrt{x}}\pi(t)\phi'(t)\,\mathrm{d}t,$$ but determining $\phi'(t)$, the integral becomes too big.

It's not super nice, but it's not so bad, actually. Write $\phi(t) = \psi_1(t)\cdot \psi_2(t)$ with

$$\psi_1(t) = \frac{x}{t}\quad\text{and}\quad \psi_2(t) = \frac{1}{\log (x/t)} = \frac{1}{\log x - \log t}.$$

Then we have

$$\psi_1'(t) = - \frac{x}{t^2}\quad\text{and}\quad \psi_2'(t) = -\frac{1}{(\log x - \log t)^2}\cdot \biggl(-\frac{1}{t}\biggr) = \frac{1}{t(\log (x/t))^2},$$

thus

\begin{align} \phi'(t) &= \psi_1'(t)\psi_2(t) + \psi_1(t)\psi_2'(t) \\ &= -\frac{x}{t^2\bigl(\log (x/t)\bigr)} + \frac{x}{t^2\bigl(\log (x/t)\bigr)^2}. \end{align}

For $t \leqslant \sqrt{x}$, the second term is in modulus smaller than the first by a factor between $\frac{1}{\log x}$ and $\frac{1}{\log \sqrt{x}} = \frac{2}{\log x}$, so in the integral the first term is the dominant one, and the second can [a priori, only probably, we need to check that this is the case] be subsumed in the error term.

Using $\pi(t) = \frac{t}{\log t} + O\bigl(\frac{t}{(\log t)^2}\bigr)$ we first get

$$\pi(\sqrt{x})\phi(\sqrt{x}) = \frac{\sqrt{x}}{\log \sqrt{x}}\cdot\frac{x}{\sqrt{x}\log (x/\sqrt{x})}\cdot\Bigl(1 + O\bigl((\log x)^{-1}\bigr)\Bigr) \in O\biggl(\frac{x}{(\log x)^2}\biggr),$$

so this can be subsumed in the error term. As the main contribution to the integral we have

$$-\int_2^{\sqrt{x}} \pi(t)\psi_1'(t)\psi_2(t)\,dt = x\int_2^{\sqrt{x}} \frac{dt}{t(\log t)\bigl(\log(x/t)\bigr)} + x\int_2^{\sqrt{x}} O\biggl(\frac{1}{(\log t)^2}\biggr)\frac{dt}{t\bigl(\log (x/t)\bigr)},$$

where the first term is exactly the integral we want, and the second is smaller due to the additional $\log t$ factor in the denominator. With $\frac{1}{2}\log x \leqslant \log \frac{x}{t} \leqslant \log x$ for $1 \leqslant t \leqslant \sqrt{x}$, we can estimate the second integral by a multiple of

$$\frac{x}{\log x} \int_2^{\sqrt{x}} \frac{dt}{t(\log t)^2},$$

and since $\int_2^{\infty} \frac{dt}{t(\log t)^2} < +\infty$, that is $O(x/\log x)$. For the remaining

$$-\int_2^{\sqrt{x}} \pi(t)\psi_1(t)\psi_2'(t)\,dt,$$

we again pull out $\frac{1}{(\log (x/t))^2}$ and use $\pi(t) \in O(t/\log t)$ to get

$$\Biggl\lvert\int_2^{\sqrt{x}} \pi(t)\psi_1(t)\psi_2'(t)\,dt\Biggr\rvert \leqslant C\cdot\frac{x}{(\log x)^2} \int_2^{\sqrt{x}} \frac{dt}{t(\log t)} \leqslant \tilde{C} \cdot\frac{x\log \log x}{(\log x)^2},$$

so that belongs to $o(x/\log x)$.

Altogether, we have seen that indeed

$$\sum_{p \leqslant \sqrt{x}} \frac{x}{p\log (x/p)} = x\int_2^{\sqrt{x}} \frac{dt}{t(\log t)\bigl(\log (x/t)\bigr)} + O\biggl(\frac{x}{\log x}\biggr).$$

(Note: that yields $\pi_2(x) \sim \frac{x\log \log x}{\log x}$, where $\pi_2(x)$ is the number of semiprimes not exceeding $x$.)

Taking $\phi\left(z\right)=1/\left(z\log\left(x/z\right)\right)$ in the Abel's formula we have $$S=x\sum_{p\leq\sqrt{x}}\frac{1}{p\log\left(x/p\right)}=\frac{2\pi\left(\sqrt{x}\right)}{\log\left(x\right)}-x\int_{2}^{\sqrt{x}}\frac{\pi\left(t\right)\left(1-\log\left(x/t\right)\right)}{t^{2}\log^{2}\left(x/t\right)}dt$$ $$=\frac{2\pi\left(\sqrt{x}\right)}{\log\left(x\right)}-x\int_{2}^{\sqrt{x}}\frac{\pi\left(t\right)}{t^{2}\log^{2}\left(x/t\right)}dt+x\int_{2}^{\sqrt{x}}\frac{\pi\left(t\right)}{t^{2}\log\left(x/t\right)}dt.$$ Now using the estimation $$\pi\left(z\right)=O\left(\frac{z}{\log^{2}\left(z\right)}\right)$$ and the obvious inequality $$\frac{1}{\log\left(x/t\right)}\leq\frac{2}{\log\left(x\right)},\, t\in\left[2,\sqrt{x}\right]\tag{1}$$ we get $$\int_{2}^{\sqrt{x}}\frac{\pi\left(t\right)}{t^{2}\log^{2}\left(x/t\right)}dt=O\left(\int_{2}^{\sqrt{x}}\frac{dt}{t\log^{2}\left(x/t\right)\log\left(t\right)}\right)$$ $$=O\left(\frac{1}{\log^{2}\left(x\right)}\int_{2}^{\sqrt{x}}\frac{dt}{t\log\left(t\right)}\right)=O\left(\frac{\log\left(\log\left(\sqrt{x}\right)\right)}{\log^{2}\left(x\right)}\right).$$ Using the PNT in the form $$\pi\left(z\right)=\frac{z}{\log\left(z\right)}+O\left(\frac{z}{\log^{2}\left(z\right)}\right)$$ in the other integral we get $$\int_{2}^{\sqrt{x}}\frac{\pi\left(t\right)}{t^{2}\log\left(x/t\right)}dt.=\int_{2}^{\sqrt{x}}\frac{1}{t\log\left(x/t\right)\log\left(t\right)}dt+O\left(\int_{2}^{\sqrt{x}}\frac{1}{t\log\left(x/t\right)\log^{2}\left(t\right)}dt\right)$$ and using again $(1)$ we have $$\int_{2}^{\sqrt{x}}\frac{1}{t\log\left(x/t\right)\log^{2}\left(t\right)}dt=O\left(\frac{1}{\log\left(x\right)}\right)$$ and finally $$\frac{2\pi\left(\sqrt{x}\right)}{\log\left(x\right)}=O\left(\frac{\sqrt{x}}{\log^{2}\left(x\right)}\right)$$ hence $$x\sum_{p\leq\sqrt{x}}\frac{1}{p\log\left(x/p\right)}=\int_{2}^{\sqrt{x}}\frac{1}{t\log\left(x/t\right)\log\left(t\right)}dt+O\left(\frac{x}{\log\left(x\right)}\right)$$ as wanted.