Let $$N(T) = \#\{\rho \in \mathbb{C}: \zeta(\rho) = 0,\, \operatorname{Im} \rho \in (0,T]\}$$ denote the number of zeros of $\zeta(s)$, counting multiplicities, with imaginary part lying in the interval $(0,T]$, that is, with imaginary part greater than $0$ and less than or equal to $T$. For example, one has $N(50) = 10$, since there are exactly 10 zeros of $\zeta(s)$ with imaginary part lying in the interval $(0,50]$. The Riemann–von Mangoldt formula, conjectured by Riemann in 1859 and proved by von Mangoldt in 1905, states that $$N(T)={\frac {T}{2\pi }}\log {{\frac {T}{2\pi }}}{\frac {T}{2\pi }}+O(\log {T}) \qquad (T \to \infty),$$ or, equivalently, $$N(2 \pi T)=T \log TT+O(\log {T}) \qquad (T \to \infty).$$ I'm wondering if more is known. In particular, is there a known asymptotic expansion of $N(T)$ or $N(2 \pi T)$, or, perhaps even, an explicit formula? (Pardon if there is an obvious reference for this. I've been working in analytic number theory for only the last few years, and there are still some gaps in my knowledge that I'm trying to fill.)
4 Answers
As $T\to\infty$, we have $$ N(T) = \frac{T}{2\pi}\log\frac{T}{2\pi}\frac{T}{2\pi}+\frac{7}{8}+\frac{1}{\pi}\int_{\frac{1}{2}}^{\infty}\mathrm{Im}\Big(\frac{\zeta'}{\zeta}(\sigma+iT)\Big)d\sigma+O(T^{1}). $$ This is proved in Chapter 15 of Davenport's Multiplicative Number Theory. The error term $O(T^{1})$ is a truncation for the asymptotic expansions for the arctan and gamma functions. The contribution from the arctan function consists of lower order terms in a Taylor expansion, and the contribution from the gamma function consists of lower order terms in the Stirling expansion.
EDIT: Because of the apparent lack of clarity regarding "arg" in this result, I replaced "$\arg \zeta(1/2+iT)$" with the corresponding integral, which should not be ambiguous. I hope this helps.

$\begingroup$ Many thanks! I don't have that book. Can you give the whole expansion? And is that the principal branch of arg? $\endgroup$ Oct 30, 2021 at 8:27

$\begingroup$ I mean, is it possible to develop the $O(T^{1})$ term further? $\endgroup$ Oct 30, 2021 at 8:35

$\begingroup$ OK I found the book. What does his $\Delta$ mean in the explicit formula $\pi N(T) = \Delta_L \operatorname{Arg} \xi(s)$? I've searched and searched but can't find the definition of $\Delta$ anywhere. $\endgroup$ Oct 30, 2021 at 8:52

$\begingroup$ @JesseElliott As I said in my answer, if you look at the proof, the $O(T^{1})$ can be expanded further using the expansions for arctan (Taylor series) and gamma (lower order terms in Stirling's formula). $\endgroup$ Oct 30, 2021 at 17:57

$\begingroup$ @JesseElliott People often write $\Delta$ to denote "change". So when Davenport writes $2\pi N(T) = \Delta_R \arg\xi(s)$, the RHS means the change in argument of $\xi(s)$ as one traverses the rectangle $R$ (in the positive direction) with vertices $2$, $2+iT$, $1+iT$, and $1$. $\endgroup$ Oct 30, 2021 at 18:01
In addition to 2734364041's answer, this paper of Tim Trudgian may be useful: in particular, Trudgian shows that for all $T\geq e$,
$$\leftN(T)\frac{T}{2\pi}\log\left(\frac{T}{2\pi e}\right)\frac{7}{8}\right\leq 0.112\log T+0.278\log\log T+2.510+\frac{0.2}{T}$$
and also includes a useful discussion of all the terms that go into this result.

$\begingroup$ That other answer has a $T/(2\pi)$ term – did you leave one out of your formula? $\endgroup$ Oct 31, 2021 at 11:55

1$\begingroup$ Good pick up @GerryMyerson! I've fixed it now  there is a factor of e in the denominator of the argument of the log, which is equivalent. $\endgroup$ Oct 31, 2021 at 20:37

1$\begingroup$ A few months ago, a paper was released that managed to further improve the bound. arxiv.org/abs/2107.06506 $\endgroup$ Nov 5, 2021 at 23:53
You have also Guinand formula for $N(T)$, see, for example, in this answer https://mathoverflow.net/a/104570/7402
Not sure why my answer received negative votes. I think it's correct. Someone please point out my errors?
EDITED TO REFLECT @LUCIA'S COMMENTS: After digging through a bunch of references, I sorted out the answer I was looking for. For all $T > 0$ except at the points of discontinuity of $N(2\pi T)$, one has $$N(2 \pi T) =1+ \frac{1}{\pi} \theta(2\pi T) + \frac{1}{\pi}\operatorname{Arg}\zeta\left(\frac{1}{2}+2\pi i T\right)+2R(T),$$ where $\operatorname{Arg}$ is the principal branch of the argument, where $\theta(T)$ is the RiemannSiegel theta function, and where $R(T)$ is an integer that is $O(\log T)$. According to p. 98 of Davenport's book, you can get rid of the $R(T)$ integer term by replacing the principal value of $\arg \zeta(1/2+2 \pi i T)$ with the variation of $\arg \zeta(s)$ from $s = +\infty+2\pi iT$ to $1/2+2 \pi iT$ starting with value $0$, as long as $T$ is not $\frac{1}{2\pi}$ times an ordinate of a zero of $\zeta(s)$.
By a known asymptotic expansion of $\theta(t)$, one has the asymptotic relation \begin{align*} N(2 \pi T) & =T \log TT+\frac{7}{8}+\frac{1}{\pi}\operatorname{Arg}\zeta\left(\frac{1}{2}+2\pi i T\right)+2R(T)+O\left(\frac{1}{T}\right) \\ & = \int_1^T \log t \, dt \frac{1}{8}+\frac{1}{\pi}\operatorname{Arg}\zeta\left(\frac{1}{2}+2\pi i T\right)+2R(T)+O\left(\frac{1}{T}\right) \end{align*} and the asymptotic expansion \begin{align*} N(2 \pi T)  \frac{1}{\pi}\operatorname{Arg}\zeta\left(\frac{1}{2}+2\pi i T\right) \sim T \log T  T+ 2R(T) + \frac{7}{8}+\frac{1}{96 \pi^2 T}+ \frac{7}{11340\pi^4 T^3}+ \frac{31}{161280 \pi^6 T^5}+\cdots \end{align*} as $T \to \infty$, where the numerators and (1/2)denominators are as in OEIS Sequences A036282 and A114721, respectively. Here is a plot of the function $N(2\pi T)$ and its smooth approximation $1+\frac{1}{\pi}\theta(2\pi T)$.

2$\begingroup$ The argument here is defined by continuous variation along straight lines from $2$ to $2+iT$ to $1/2+it$. I don't know why you call this the principal branch. I would not rely on the arxiv paper by physicists, but please read Davenport carefully. $\endgroup$– LuciaNov 5, 2021 at 23:45

$\begingroup$ Davenport says also by continuous variation from $+\infty+iT$ to $1/2+iT$, which should be the same as $\operatorname{Arg}\zeta(1/2+iT)$ as long as $T$ isn't the imaginary part of a zero of $\zeta(T)$. Can you give a counterexample to this claim? Also, Davenport doesn't mention the RiemannSiegel theta function $\theta(t)$, so obviously he isn't the last word on the subject. Riemann never proved the asymptotic for $N(T)$, but that didn't detract from its being true. Obviously there's a lot more going on here than is noted in Davenport. $\endgroup$ Nov 6, 2021 at 0:18

3$\begingroup$ If I understand you correctly, you would be maintaining that $S(t) \le 1$  $S(t)$ is $1/\pi$ times the argument as usually defined in the literature. The growth of this quantity is notoriously slow. But look at arxiv.org/pdf/1607.00709.pdf which gives examples of large values of $S(t)$: at the moment the numerical values are only about $3.3$ or so. Of course it is well understood that this gets arbitrarily large. $\endgroup$– LuciaNov 6, 2021 at 4:06

1$\begingroup$ I might be remembering incorrectly, but $S(T)$ is typically defined by $\frac{S(T^+) + S(T^)}{2}$ whenever $T$ is the ordinate of a zero (including those that are not on the critical line). Hopefully this answers your question about how the argument jumps around zeroes (as it should)? $\endgroup$ Nov 6, 2021 at 7:53

1$\begingroup$ If there's no zero in between the horizontal lines, there's no obstruction to shifting the defining contour around. In particular, that means the branch of the logarithm you're on doesn't change. $\endgroup$ Nov 6, 2021 at 9:37