TITLE: Squeezing $\pi(x)$ out of $\psi(x)$
QUESTION [5 upvotes]: Can $\pi(x)$ be written in terms of $\psi(x)$? I can only seem to approximate it:
$$
\pi(x)\approx\sum_{n=1}^{\infty}\left[\dfrac{\mu(n)}{n}\left(\dfrac{1}{\log(x^{1/n})}\left(\psi(x^{1/n})-x^{1/n}+\sqrt{\pi}\right)+\operatorname{li}(x^{1/n})-1\right)\right]
$$
Is there a relationship of equivalence between $\psi(x)$ and $\pi(x)$ (ie, an inversion formula), or can it only approximate it?
Out of interest I include the difference up to $10^5$ between the RHS and the LHS

and both together for very small $x$

REPLY [4 votes]: There is an easy relation between $\pi(x)$ and $\psi(x)$, namely
$$
\pi(x)=\frac{\psi(x)}{\log (x)}+O\left(\frac{x}{\log^2(x)}\right). 
$$
I am not sure if this is a  "better expression". There are very efficient formulas for computing $\pi(x)$, see for example here. There are similarities to your formula in section $4$.