TITLE: Deriving an asymptotic for $\pi(x)$ directly from $\log \zeta(s)$?
QUESTION [9 upvotes]: Denote by $\pi(x)$ the number of primes $p\leq x$. We generally give approximations for $\pi(x)$ by first approximating $\psi(x) = \sum_{n\leq x} \Lambda(n)$. Part of the reason is presumably that, if we apply Perron's formula directly, without going through $\psi(x)$, we end up with an expression for $\pi(x)$ in terms of an integral involving $\log \zeta(s)$. Here we see what the issue is: $\log \zeta(s)$ has a branch point at $s=1$, and that is unpleasant.
At the same time, it is not that unpleasant; you can do a little loop ("truncated Hankel contour") around $s=1$. Is there a standard reference where $\pi(x)$ is estimated in this way?

REPLY [2 votes]: When $T\le\sqrt x$ and $x=\frac12+\mathbb Z^+$, it is possible to show using Perron's formula that
$$
\pi(x)={1\over2\pi i}\int_{k-iT}^{k+iT}{x^s\over s}\log\zeta(s)\mathrm ds+\mathcal O\left(x\log x\over T\right)
$$
After applying certain analytic properties of $\zeta(s)$ in the critical strip, the task turns into evaluating the following residue integral:
$$
{1\over2\pi i}\oint_{(1+)}{x^s\over s}\log{1\over s-1}\mathrm ds
$$
where $(1+)$ represents any counterclockwise path containing $s=1$ but not $s=0$. A possible approach to handle the integral, inspired by Riemann (see chapter 1 of Edwards's 1974 classic Riemann's zeta function), is to introduce a new parameter $r$ to the problem:
$$
f(r)={1\over2\pi i}\oint_{(r+)}{x^s\over s}\log{1\over s/r-1}\mathrm ds
$$
Taking derivatives on both side gives $f'(r)=x^r/r$, and integrating back we get
$$
f(r)=\operatorname{li}(x^r)+\mathcal O(1)
$$
where $\operatorname{li}(x)$ is the logarithmic integral function. The reason why there is an O-term is because the sign of $\Im(r)$ will introduce certain $i\pi$ deviation to the final result. A full derivation of the PNT using this idea can be found here.