# show that $\pi_2(x)\sim o\left(\frac{x\log(\log(x))}{\log(x)}\right)$.

Let $\pi_2(x)$ the number of biprime number between $1$ and $x$, i.e. number of the form $pq$, $p$ or $p^2$ in $[1,x]$ with $p,q$ prime.

Show that $\pi_2(x)=\frac{1}{2}\sum_{p_1p_2\leq x}1+\mathcal O\left(\frac{x}{\log(x)}\right)$.

Done

Deduce that $\pi_2(x)=\sum_{p\leq \sqrt x}\pi\left(\frac{x}{p}\right)+\mathcal O\left(\frac{x}{\log(x)}\right)$

Using Dirichelet hyperbola, I get $$\frac{1}{2}\sum_{p_1p_2\leq x}=\sum_{p\leq \sqrt x}\pi\left(\frac{x}{p}\right)-\sum_{p_1p_2\leq \sqrt x}1=\sum_{p\leq \sqrt x}\pi\left(\frac{x}{p}\right)-\sum_{p\leq \sqrt x}\pi\left(\frac{\sqrt x}{p}\right).$$ Using Tchebychev, $$\sum_{p\leq \sqrt x}\pi\left(\frac{\sqrt x}{p}\right)=\mathcal O\left(\sqrt x\sum_{p\leq \sqrt x}\frac{1}{p\log(\sqrt x/p)}\right).$$ Question 1 : Now, how can I get $$\mathcal O\left(\sqrt x\sum_{p\leq \sqrt x}\frac{1}{p\log(\sqrt x/p)}\right)=\mathcal O\left(\frac{x}{\log(x)}\right)\ \ ?$$

Use theorem of prime number to show that $$\pi_2(x)=x\sum_{p\leq \sqrt{x}}\frac{1}{p\log(x/p)}+o\left(\frac{x\log(\log(x))}{\log(x)}\right).$$

Using theorem of prime number, $$\pi\left(\frac{x}{p}\right)=\frac{x}{p\log(x/p)}+o\left(\frac{x}{p\log(x/p)}\right),$$ so $$\sum_{p\leq \sqrt x}\pi\left(\frac{x}{p}\right)=x\sum_{p\leq \sqrt x}\frac{1}{p\log(x/p)}+\sum_{p\leq \sqrt x}o\left(\frac{x}{p\log(x/p)}\right).$$ Let $R(x,p)=o\left(\frac{x}{p\log(x/p)}\right)$. So, if $\varepsilon>0$, there is $M>0$ s.t. $$|R(x,p)|\leq \varepsilon\frac{x}{p\log(x/p)},$$ when $x>M$. In other word, $$\sum_{p\leq \sqrt x}|R(x,p)|\leq \varepsilon \sum_{p\leq \sqrt x}\frac{x}{p\log(x/p)}\leq \frac{2x}{\log(x)}\varepsilon\sum_{p\leq\sqrt x}\frac{1}{p}\underset{Mertens}{=}\varepsilon\frac{2x}{\log(x)}(\log(\log(\sqrt x))+\beta +\mathcal O(\frac{1}{\log(x)}).$$ Question 2 : It looks complicate... How can I conclude from here ?

In the work leading to question 1, you have a mistake. When you count the number of pairs $(p_1,p_2)$ of primes with $p_1\cdot p_2 \leqslant x$ using the hyperbola method, you count a) the pairs where $p_1 \leqslant \sqrt{x}$ (and $p_2 \leqslant x/p_1$), b) the pairs where $p_2 \leqslant \sqrt{x}$ (and $p_1 \leqslant x/p_2$), and then c) you subtract the number of doubly counted pairs, that is the number of pairs with $p_1 \leqslant \sqrt{x}$ and $p_2 \leqslant \sqrt{x}$, not the number of pairs where $p_1\cdot p_2 \leqslant \sqrt{x}$. Thus

$$\sum_{p_1p_2 \leqslant x} 1 = \sum_{p_1 \leqslant \sqrt{x}} \pi\biggl(\frac{x}{p_1}\biggr) + \sum_{p_2 \leqslant \sqrt{x}} \pi\biggl(\frac{x}{p_2}\biggr) - \pi(\sqrt{x})^2.$$

Now $\pi(\sqrt{x})^2$ is easily handled with the prime number theorem, since $\log \sqrt{x} = \frac{1}{2} \log x$, we have

$$\pi(\sqrt{x})^2 \sim \frac{4x}{(\log x)^2}.$$

The weaker but more than sufficient $\pi(\sqrt{x})^2 \in \mathcal{O}\bigl(\frac{x}{(\log x)^2}\bigr)$ follows from Chebyshev's bounds.

Since the number of pairs with $p_1 \cdot p_2 \leqslant \sqrt{x}$ is smaller than $\pi(\sqrt{x})^2$ (except for very small $x$), the error estimate of $\mathcal{O}\bigl(\frac{x}{\log x}\bigr)$ is also easily established for your sum:

$$\sum_{p \leqslant \sqrt{x}} \pi\biggl(\frac{\sqrt{x}}{p}\biggr) \leqslant \sum_{p \leqslant \sqrt{x}} \pi(\sqrt{x}) = \pi(\sqrt{x})^2.$$

However, once you replace $\pi(\sqrt{x}/p)$ with $\mathcal{O}\bigl(\frac{\sqrt{x}}{p\log (\sqrt{x}/p)}\bigr)$ in that sum, you cannot reach the desired bound any more, since the last term in the sum may blow up. If $x = q^2$ is the square of a prime, the last term is $\mathcal{O}\bigl(\frac{1}{0}\bigr)$, and that doesn't even make sense. If $x$ is not quite the square of a prime, but very close, the last term can still become arbitrarily large.

Thus, if we want to estimate a sum of terms with a factor $\log (u/p)$ in the denominator, we must make sure that $p$ stays significantly smaller than $u$ (how much smaller that must be depends on the situation).

With the above estimate, we have established that

$$\pi_2(x) = \sum_{p \leqslant \sqrt{x}} \pi\biggl(\frac{x}{p}\biggr) + \mathcal{O}\biggl(\frac{x}{\log x}\biggr).\tag{1}$$

We want to show that

$$\pi_2(x) = x\sum_{p\leqslant \sqrt{x}} \frac{1}{p\log \frac{x}{p}} + o\biggl(\frac{x\log \log x}{\log x}\biggr)\tag{2}$$

using the prime number theorem. Clearly the error term in $(1)$ belongs to $o\bigl(\frac{x\log \log x}{\log x}\bigr)$, so we need not care about that and can concentrate on

$$\sum_{p \leqslant \sqrt{x}} \pi\biggl(\frac{x}{p}\biggr).$$

You have done that essentially correctly.

There is a small mathematical problem, you say that for $\varepsilon > 0$ there is an $M$ such that [estimate] for $x > M$. But the argument of $\pi$ is $x/p$, so the prime number theorem just says that [estimate] holds for $x/p > K$. Now in our sum we have $p \leqslant \sqrt{x}$, so $x > K^2$ implies $x/p > K$, and your assertion is true, but the constraint on $p$ that makes it so should be mentioned.

Then there is a non-mathematical problem. You keep too much of Mertens' theorem, so that you don't see that you have already achieved your goal. Just using that (for $y > y_0$) there is a constant $C$ such that $\sum_{p \leqslant y} \frac{1}{p} \leqslant C\log \log y$, and $\log \log \sqrt{x} \leqslant \log \log x$, you get

$$\sum_{p \leqslant \sqrt{x}} \lvert R(x,p)\rvert \leqslant 2C\varepsilon \cdot \frac{x\log \log x}{\log x}\tag{\ast}$$

for $x > M$, which is what you want. If you don't see that yet, note that $(\ast)$ implies

$$\limsup_{x\to \infty} \frac{\log x}{x\log \log x}\sum_{p \leqslant \sqrt{x}} \lvert R(x,p)\rvert \leqslant 2C\varepsilon,$$

and since $\varepsilon > 0$ was arbitrary, this means

$$\lim_{x\to \infty} \frac{\log x}{x\log \log x}\sum_{p \leqslant \sqrt{x}} \lvert R(x,p)\rvert = 0,$$

i.e.

$$\sum_{p \leqslant \sqrt{x}} \lvert R(x,p)\rvert \in o\biggl(\frac{x\log \log x}{\log x}\biggr).$$