Can you derive a formula for the semiprime counting function from the prime number theorem?

Solution 1:

Asymptotically there are about $n\frac{\log\log n}{\log n}$ semiprimes up to $n$, almost all of which are squarefree.

There's also an exact formula if you know all the primes up to the square root of $n$: $$ -{\pi\left(\sqrt{n}\right)\choose 2}+\sum_{p^2\le n} \pi\left(\frac{n}{p}\right) $$ for all semiprimes, or $$ -{\pi\left(\sqrt{n}\right)\choose 2}-\pi\left(\sqrt{n}\right)+\sum_{p^2\le n} \pi\left(\frac{n}{p}\right) $$ for the squarefree semiprimes only.

Solution 2:

Yes, that can be done.

Redesignate the prime counting function as $p_1(x)$, which counts how many numbers between 0 and $x$ have one prime factor (provided $x$ is a nonnegative real number). Then, given $k \in \mathbb{Z}^+$, we have $$\pi_k(x) \sim \frac{x}{\log x} \frac{(\log \log x)^{k - 1}}{(k - 1)!}.$$ Setting $k = 2$ gives us $$\pi_2(x) \sim \frac{x \log \log x}{\log x}.$$ This comes from Landau's Handbuch der Lehre von der Verteilung der Primzahlen. It is way off at first, it says there are $-2$ semiprimes between 0 and 2.