Riemann's explicit formula for $\pi(x)$ Riemann's explicit formula
$J(x)=\mathrm{Li}(x)-\sum_{\Im\varrho>0}\left(\mathrm{Li}(x^\varrho)+\mathrm{Li}(x^{1-\varrho})\right)+\int_x^\infty\frac{\mathrm{d}t}{t(t^2-1)\log t}-\log2,$
where $\varrho$ are the non-trivial zeta zeros, is an expression for $J(x)$, the prime counting function that goes up by $1/k$ for every $k$th power of a prime. For theoretical purposes, this is fine since $J(x)=\Theta(\pi(x))$ and we can recover $\pi(x)$ by Möbius inversion
$\pi(x)=\sum_{n\ge1}\frac{\mu(n)}{n}J(x^{1/n}).$
This is the reason why Riemann's suggestion
$R(x)=\sum_{n\ge1}\frac{\mu(n)}{n}\mathrm{Li}(x^{1/n})$
is a good candidate for an approximation to $\pi(x)$, and indeed performs well empirically (though it is not really superior by any general measure).
My question is: Can we plug the explicit formula for $\mathrm{Li}(x)$ into the inversion formula for $\pi(x)$ and evaluate term-wise? This would lead to
$\pi(x)=R(x)-\sum_{\varrho}R(x^\varrho)+\sum_{n\ge1}\frac{\mu(n)}{n}\int_{x^{1/n}}^\infty\frac{\mathrm{d}t}{t(t^2-1)\log t}-\log2\sum_{n\ge1}\frac{\mu(n)}{n}.$
The sum $\sum\frac{\mu(n)}{n}$ actually evaluates to $0$, so the last term would vanish. But since the sum over the zeta zeros converges only conditionally, I am not sure if swapping the order of summation in the second term would be justified and correct.
What's more, the lower bound $x^{1/n}$ for the integral converges to $1$ (for a fixed $x$), where the integrand has a pole, hence the integral would blow up to infinity (quicker than the $1/n$ can fix), and so this sum would not converge (as far as I can see and my calculations support).
Do I make a mistake in my logic, or is term-wise evaluation indeed not allowed here?
Another approach is of course to argue that the inversion sum is actually finite, since $J(x)=0$ for $x<2$ by construction, so we won't run into the convergence problem (but will neither have the convenience that the $\log2$ term vanishes). Would we just adjust the definition of $R(x)$ and the argument would go through? (I would still like to know what goes wrong in my initial train of thoughts with the infinite sum.)
I couldn't find a reference for this question, so I hope someone can help me with that.
 A: I believe Riemann's explicit formula can also be written as follows.
(1) $\quad\Pi(x)=li(x)-\sum\limits_\rho Ei(\log\,(x)\,\rho)-\log(2)-\sum\limits_{n=1}^\infty Ei(-2\,n\,\log(x))$
The end of the following Wolfram MathWorld article seems to imply an explicit formula for $\pi(x)$ derived from the explicit formula for $J(x)$ has never been proven to converge.
Riemann Prime Counting Function

There are several other functions relevant to the derivation of an explicit formula for $\pi(x)$ such as the following two functions where $M(x)$ is the Mertens function and $Q(x)$ is the summatory square-free function.
(2) $\quad M(x)=\sum\limits_{n=1}^x \mu(n)\,,\qquad \frac{1}{\zeta(s)}=\sum\limits_{n=1}^\infty\frac{\mu(n)}{n^s}$
(3) $\quad Q(x)=\sum\limits_{n=1}^x\left|\mu(n)\right|\,,\qquad \frac{\zeta(s)}{\zeta(2\,s)}=\sum\limits_{n=1}^\infty\frac{\left|\mu(n)\right|}{n^s}$

I've read the explicit formulas for $M(x)$ and $Q(x)$ are as follows but I'm not sure whether these formulas truly converge.
(4) $\quad M_o(x)=\sum\limits_\rho\frac{x^{\rho}}{\rho\,\zeta'(\rho)}-2+\sum\limits_{n=1}^N\frac{x^{-2\,n}}{(-2\,n)\,\zeta'(-2\,n)}\,,\quad N\to\infty$
(5) $\quad Q_o(x)=\frac{6\,x}{\pi^2}+\sum\limits_\rho\frac{x^{\frac{\rho}{2}}\,\zeta\left(\frac{\rho}{2}\right)}{\rho\,\zeta'\rho)}+1+\sum\limits_{n=1}^N\frac{x^{-n}\,\zeta(-n)}{(-2\,n)\,\zeta'(-2\,n)}\,,\quad N\to\infty$

The explicit formulas defined in (4) and (5) above are illustrated in the following two plots in orange and the corresponding reference functions defined in (2) and (3) above are illustrated in blue. Both plots are evaluated over the first 200 pairs of zeta zeros and the sums over $n$ are also evaluated with the upper limit $N=200$. The red discrete portions of the plots illustrate the evaluations of the explicit formulas at integer values of $x$.


$\text{Figure (1): Illustration of $M_o(x)$}$


$\text{Figure (2): Illustration of $Q_o(x)$}$

Note $M_o(x)$ and $Q_o(x)$ illustrated in figures (1) and (2) above seem to converge for $x>b$ and $x>a$ respectively where $0<a<b<1$, so this avoids the problem of a pole at $x=1$.

The fundamental prime counting function $\pi(x)$ is related to $M(x)$ and $Q(x)$ as follows where $\nu(n)$ is the number of distinct prime factors in $n$ and $\Omega(n)$ is the number of prime factors in $n$ counting multiplicities.
(6) $\quad\pi(x)=\sum\limits_{n=1}^x\nu(n)\,M\left(\frac{x}{n}\right)$
(7) $\quad\pi(x)=-\sum\limits_{n=1}^x(-1)^{\Omega(n)}\,\nu(n)\,Q\left(\frac{x}{n}\right)$

The relationships illustrated above suggest the following explicit formulas for $\pi(x)$.
(8) $\quad\pi_o(x)=\sum\limits_{n=1}^x\nu(n)\,M_o\left(\frac{x}{n}\right)$
(9) $\quad\pi_o(x)=-\sum\limits_{n=1}^x(-1)^{\Omega(n)}\,\nu(n)\,Q_o\left(\frac{x}{n}\right)$

The following two plots illustrate the $\pi_o(x)$ explicit formulas defined in (8) and (9) above. The explicit formulas are illustrated in orange and the reference function $\pi(x)$ is illustrated in blue. Both plots are evaluated over the first 200 pairs of zeta zeros and the sums over $n$ in the two underlying explicit formulas are also evaluated with the upper limit $N=200$. The red discrete portions of the plots illustrate the evaluations of the explicit formulas at integer values of $x$.


$\text{Figure (3): Illustration of $\pi_o(x)$ Derived from $M_o(x)$}$


$\text{Figure (4): Illustration of $\pi_o(x)$ Derived from $Q_o(x)$}$

Note the two $\pi_o(x)$ explicit formulas illustrated in figures (3) and (4) above both seem to converge fairly well at integer values of $x$, but exhibit spikes just prior to integer values of $x$ for which $\pi(x)$ doesn't take a step. I've noticed the widths of these spikes seems to get narrower as evaluation limits are increased, but I haven't notice much of a change in the maximum amplitudes of these spikes as evaluation limits are increased.
