Reference request for the explicit formula for $\sum_{n\leq x} \Lambda(n)n^{-s}$ Denote by $\Lambda(n)$ th e von Mangoldt function, which is equal to $\log p$ if $p\geq 2$ is a prime, and $0$ otherwise. Let $\rho$ denote a complex zero of the Riemann $\zeta$-function. If i recall well, i once heard sometime ago that
$$\sum_{n\leq x} \Lambda(n)n^{-s} = -\frac{\zeta'}{\zeta}(s) + \frac{x^{1-s}}{1-s} - \sum_{|Im \rho| \leq x} \frac{x^{\rho-s}}{\rho-s} + O(\log^{2}x)$$ for $s\neq 1, s\neq \rho$ and $s\neq -2k, k\in \mathbb{N}$.
Does anyone have a reference for this result ?
 A: I don't know a reference off-hand, but here is a sketch of the proof (the details need to be checked carefully, and I have not done it). One can start from
$$\sum_{n\leq x}\frac{\Lambda(n)}{n^s}=\frac{1}{2\pi i}\int_{(\sigma)}-\frac{\zeta'(z)}{\zeta(z)}\cdot\frac{x^{z-s}}{z-s}\,dz,\qquad\sigma>\max(1,\mathrm{Re}\,s),$$
which is a variant of Theorem 5.1 in Montgomery-Vaughan: Multiplicative number theory I, and can be proved in the same way. As in the theorem, the RHS is understood as a Cauchy principal value, while in case of $x\in\mathbb{N}$ the term corresponding to $n=x$ in the LHS is counted with weight $1/2$.
The integrand is meromorphic with simple poles at $z=s$, $z=1$, and $z=\rho$. The corresponding residues are $-\zeta'(s)/\zeta(s)$, $x^{1-s}/(1-s)$, and $-m_\rho\cdot x^{\rho-s}/(\rho-s)$, where $m_\rho$ is the multiplicity of $\rho$. So one can derive the OP's display by performing the following steps:

*

*Truncate the integral on the RHS to $|\mathrm{Im}\,z|\leq x$ and estimate the error introduced. Perturb $x$ slightly if it is very close to some $\mathrm{Im}\,\rho$.

*Extend the truncated contour (which is a vertical line segment) to a rectangle containing the points $s=1$ and $s=0$, hence all the $\rho$'s with $|\mathrm{Im}\,\rho|\leq x$. By the Residue Theorem, the integral weighted by $1/(2\pi i)$ equals the sum of corresponding residues listed above.

*Estimate the contribution of the horizontal line segments of the rectangular contour, as well as of the vertical line segment to the left of $s=0$.

*The LHS equals the sum of residues listed in item 2, up to the error terms listed in items 1 and 3.

P.S. See also Terry Tao's valuable remarks below the original post.
A: The non-truncated version of this estimate is due to E. Landau, see page 353 of his book "Handbuch der Lehre von der Verteilung der Primzahlen", Teubner, Berlin, 1909. It states that for $s \neq 1$ for which $\zeta(s) \neq 0$ one has
$$(\star)\, {\sum_{n \le x}}'\frac{\Lambda(n)}{n^s} = \frac{x^{1-s}}{1-s}-\frac{\zeta'}{\zeta}(s)-\sum_{\rho}\frac{x^{\rho-s}}{\rho-s} + \sum_{k=1}^{\infty} \frac{x^{-2k-s}}{2k+s},$$
where the $\prime$ in the sum indicates that the last term is counted with weight $1/2$ if $x$ is a positive integer. Here the sum is over non-trivial zeros of $\zeta$, as usual.
This is also given as Exercise 4 in Chapter 12, section 1 of "Multiplicative Number Theory I" by Montgomery--Vaughan.
One should also say that $(\star)$ holds for $s=1$ as well, if one interprets $x^{1-s}/(1-s) - \zeta'(s)/\zeta(s)$ as its limit at $s=1$, which is $\log x -\gamma$.
A truncated version has been used many times in the literature (e.g. Lemma 6 of the paper "On integers free of large prime factors" by A. Hildebrand and G. Tenenbaum, Trans. Am. Math. Soc. 296, 265-290, 1986) and is known to experts. Apart from the blog post Terry Tao mentioned in the comments, and the proof sketch given in GH from MO's answer, a similar proof can also be found in the appendix of the arXiv preprint 2211.08973. It states that uniformly for $\Re s \ge 0$, $x \ge 4$ and $T \ge 2 +3 |\Im s|$ we have
$${\sum_{n \le x}}'\frac{\Lambda(n)}{n^s} = \frac{x^{1-s}}{1-s}-\frac{\zeta'}{\zeta}(s)-\sum_{|\Im(\rho-s)|\le T}\frac{x^{\rho-s}}{\rho-s} + \sum_{k=1}^{\infty} \frac{x^{-2k-s}}{2k+s} + R(x,T)$$
if $\zeta(s)\neq 0$, where $R$ satisfies the bound
$$ R(x,T) \ll (\log x) (x-1)^{-\Re s}\min\left\{ 1, \frac{x}{T\langle x \rangle}\right\} + \frac{\log^2 (xT)}{T}\left( 2^{\Re s } x^{1-\Re s}+\frac{2^{-\Re s}}{\log x}\right)$$
with an absolute implied constant. For $s=0$ this recovers the usual explicit formula (Theorem 12.5 from Montgomery--Vaughan), and its proof is the same. Taking $T \to \infty$ recovers $(\star)$. Here $\langle x \rangle$ is as in the statement of Theorem 12.5: it's the distance of $x$ to the nearest prime power not equal to $x$.
