1 Introduction

In 1976, Schoenfeld [4,  Corollary 1] proved that under assumption of the Riemann hypothesis,

$$\begin{aligned} |\pi (x)-li(x)|<\frac{\sqrt{x}}{8\pi }\log x, \end{aligned}$$
(1.1)

for \(x\ge 2657\). Although a complete proof of the Riemann hypothesis remains out of reach, partial results can be used to prove (1.1) for a finite range. In this direction, we prove that (1.1) holds provided \(x\ge 2657\) and

$$\begin{aligned} \frac{9.06}{\log \log x}\sqrt{\frac{x}{\log x}}\le T. \end{aligned}$$
(1.2)

Here, T is the largest known value such that the Riemann hypothesis is true for all zeros \(\rho \) with \(\Im (\rho )\in (0,T]\). A recent computation by Platt and Trudgian [11] allows us to take \(T=3\cdot 10^{12}\). Substituting this T into (1.2) tells us that (1.1) holds for all \(2657\le x\le 1.101\cdot 10^{26}\).

These results improve on earlier work by Büthe [5,  Theorem 2], who proved that (1.1) holds provided \(x\ge 2657\) and

$$\begin{aligned} 4.92\sqrt{\frac{x}{\log x}}\le T. \end{aligned}$$
(1.3)

In particular, provided \(T\ge 46\), (1.2) holds for a wider range of x than (1.3). So by comparison, one only obtains \(x\le 2.169\cdot 10^{25}\) using (1.3) with \(T=3\cdot 10^{12}\).

To prove (1.2) we use Büthe’s original method with an additional iterative argument and several other optimisations. Similar to Büthe, we prove corresponding bounds for the prime counting functions \(\theta (x)\), \(\psi (x)\) and \(\Pi (x)\).

In Section 2, we list all the definitions and lemmas that we will use from [5]. In Section 3, we prove the main result. Then, in Section 4 we discuss possible improvements and variations. For instance, we show (Theorem 4.1) that the weaker bound \(|\pi (x)-li(x)|<\sqrt{x}\log x\) holds for \(2\le x\le 2.165\cdot 10^{30}\). Finally, in Section 5, we discuss an application to an inequality of Ramanujan.

2 Notation and setup

Throughout this paper, we work with the normalised prime counting functions

(2.1)

where \(\sum ^*\) indicates that the last term in the sum is multiplied by 1/2 when x is an integer. However, we note that our main results (Theorem 3.2 and Theorem 4.1), will also hold for the standard (unnormalised) prime counting functions. Our main focus will be on the function \(\psi (x)\) since the other functions in (2.1) can be related to \(\psi (x)\) by simple bounding and partial summation arguments.

Following [5,  Section 2], we define

$$\begin{aligned} \ell _{c,\varepsilon }(\xi )=\frac{c}{\sinh (c)}\frac{\sin (\sqrt{(\xi \varepsilon )^2-c^2})}{\sqrt{(\xi \varepsilon )^2-c^2}},\quad a_{c,\varepsilon }(\rho )=\frac{1}{\ell _{c,\varepsilon }(i/2)}\ell _{c,\varepsilon }\left( \frac{\rho }{i}-\frac{1}{2i}\right) \end{aligned}$$

for \(c,\varepsilon >0\). We will also make use of the auxiliary function \(\psi _{c,\varepsilon }(x)\) defined on page 2484 of [5]. Notably, \(\psi _{c,\varepsilon }(x)\) is a continuous approximation to \(\psi (x)\). Moreover, for \(x\ge 10\) and \(0<\varepsilon \le 10^{-4}\), we have [6,  Proposition 2]

$$\begin{aligned} x-\psi _{c,\varepsilon }(x)=\sum _{\rho }\frac{a_{c,\varepsilon }(\rho )}{\rho }x^\rho +\Theta (2). \end{aligned}$$
(2.2)

Here, \(\Theta (2)\) indicates a constant with absolute value less than 2, and the sum is taken over all the non-trivial zeros of the Riemann zeta-function and computed as

$$\begin{aligned} \lim _{T\rightarrow \infty }\sum _{|\Im (\rho )|<T}\frac{a_{c,\varepsilon }(\rho )}{\rho }x^\rho . \end{aligned}$$

To obtain an expression for \(|\psi (x)-x|\), we thus need bounds on \(\sum _{\rho }\frac{a_{c,\varepsilon }(\rho )}{\rho }x^\rho \) and \(|\psi (x)-\psi _{c,\varepsilon }(x)|\). We will make use of the following collection of lemmas taken from [5] with slight modifications.

Lemma 2.1

([5], Proposition 3) Let \(x>1\), \(\varepsilon \le 10^{-3}\) and \(c\ge 3\). Then

$$\begin{aligned} \sum _{|\Im (\rho )|>\frac{c}{\varepsilon }}\left| a_{c,\varepsilon }(\rho )\frac{x^\rho }{\rho }\right| \le 0.16\frac{x+1}{\sinh (c)}e^{0.71\sqrt{c\varepsilon }}\log (3c)\log \left( \frac{c}{\varepsilon }\right) . \end{aligned}$$

Moreover, if \(a\in (0,1)\) with \(a\frac{c}{e}\ge 10^3\), and the Riemann hypothesis holds for all zeros \(\rho \) with \(\Im (\rho )\in (0,\frac{c}{\varepsilon }]\), then

$$\begin{aligned} \sum _{a\frac{c}{\varepsilon }<|\Im (\rho )|\le \frac{c}{\varepsilon }}\left| a_{c,\varepsilon }(\rho )\frac{x^\rho }{\rho }\right| \le \frac{1+11c\varepsilon }{\pi ca^2}\log \left( \frac{c}{\varepsilon }\right) \frac{\cosh (c\sqrt{1-a^2})}{\sinh (c)}\sqrt{x}. \end{aligned}$$

Lemma 2.2

([5], Lemma 3) If \(t_2\ge 5000\) then

$$\begin{aligned} \sum _{0<|\Im (\rho )|\le t_2}\frac{1}{|\Im (\rho )|}\le \frac{1}{2\pi }\log ^2\left( \frac{t_2}{2\pi }\right) . \end{aligned}$$

Lemma 2.3

([5], Proposition 4) Let \(x>100\), \(\varepsilon <10^{-2}\) and

$$\begin{aligned} B_0=\frac{I_1(c)}{2\sinh (c)}\varepsilon xe^{-\varepsilon }>1, \end{aligned}$$

where

$$\begin{aligned} I_1(x)=\sum _{n=0}^\infty \frac{(x/2)^{2n+1}}{n!\Gamma (n+2)} \end{aligned}$$

is a modified Bessel function of the first kind. We then have

$$\begin{aligned} |\psi (x)-\psi _{c,\varepsilon }(x)|\le e^{2\varepsilon }\log (e^{\varepsilon }x)\left[ \frac{\varepsilon x}{\log B_0}\frac{I_1(c)}{\sinh (c)}+2.01\varepsilon \sqrt{x}+\frac{1}{2}\log \log (2x^2)\right] . \end{aligned}$$

Lemma 2.4

([5], Proposition 5) For \(c_0>0\) let

$$\begin{aligned} D(c_0)=\sqrt{\frac{\pi c_0}{2}}\frac{I_1(c_0)}{\sinh (c_0)}. \end{aligned}$$

Then

$$\begin{aligned} \frac{D(c_0)}{\sqrt{2\pi c}}\le \frac{I_1(c)}{2\sinh (c)}\le \frac{1}{\sqrt{2\pi c}} \end{aligned}$$

holds for all \(c\ge c_0\).

In particular, note that for Lemma 2.3, we have taken the case \(\alpha =0\) in [5], Proposition 4. Moreover, we remark that Brent, Platt, and Trudgian [3], Lemma 8 recently showed that Lemma 2.2 holds more generally for \(t_2\ge 4\pi e\).

3 Proof of the main result

We begin by stating the bounds obtained using Büthe’s result [5], Theorem 2 and Platt and Trudgian’s computation [11].

Proposition 3.1

The following estimates hold:

$$\begin{aligned} |\psi (x)-x|&<\frac{\sqrt{x}}{8\pi }\log ^2(x),&\text {for }59\le x\le 2.169\cdot 10^{25},\nonumber \\ |\theta (x)-x|&<\frac{\sqrt{x}}{8\pi }\log ^2(x),&\text {for }599\le x\le 2.169\cdot 10^{25},\nonumber \\ |\psi (x)-x|&<\frac{\sqrt{x}}{8\pi }\log x(\log x-3),&\text {for }5000\le x\le 2.169\cdot 10^{25}, \end{aligned}$$
(3.1)
$$\begin{aligned} |\theta (x)-x|&<\frac{\sqrt{x}}{8\pi }\log x(\log x-2),&\text {for }5000\le x\le 2.169\cdot 10^{25}, \nonumber \\ |\Pi (x)-li(x)|&<\frac{\sqrt{x}}{8\pi }\log x,&\text {for }59\le x\le 2.169\cdot 10^{25},\nonumber \\ |\pi (x)-li(x)|&<\frac{\sqrt{x}}{8\pi }\log x,&\text {for }2657\le x\le 2.169\cdot 10^{25}. \end{aligned}$$
(3.2)

Proof

The \(2.169\cdot 10^{25}\) comes from substituting \(T=3\cdot 10^{12}\) [11] into [5,  Theorem 2]. Note that (3.1) and (3.2) do not appear in the statement of Büthe’s theorem but are established as intermediary steps in the proof. \(\square \)

We now prove the main result of this paper.

Theorem 3.2

Let \(T>0\) be such that the Riemann hypothesis holds for zeros \(\rho \) with \(0<\Im (\rho )\le T\). Then, under the condition \(\frac{9.06}{\log \log x}\sqrt{\frac{x}{\log x}}\le T\), the following estimates hold:

$$\begin{aligned} |\psi (x)-x|&<\frac{\sqrt{x}}{8\pi }\log ^2x,&\text {for }x\ge 59, \end{aligned}$$
(3.3)
$$\begin{aligned} |\theta (x)-x|&<\frac{\sqrt{x}}{8\pi }\log ^2x,&\text {for }x\ge 599,\end{aligned}$$
(3.4)
$$\begin{aligned} |\Pi (x)-li(x)|&<\frac{\sqrt{x}}{8\pi }\log x,&\text {for }x\ge 59,\end{aligned}$$
(3.5)
$$\begin{aligned} |\pi (x)-li(x)|&<\frac{\sqrt{x}}{8\pi }\log x,&\text {for }x\ge 2657. \end{aligned}$$
(3.6)

Proof

Throughout this proof we will label specific constants A, B, C, D ,and E. This is done to make it clear where optimisations are being made and to allow us to perform an iterative argument.

Now, by Proposition 3.1, it suffices to consider \(x>A\) where \(A=2.169\cdot 10^{25}\). We also initially restrict ourselves to x such that

$$\begin{aligned} \frac{B}{\log \log x}\sqrt{\frac{x}{\log x}}\le T, \end{aligned}$$
(3.7)

where \(B=9.65\) and later reduce the value of B. We first prove the bound

$$\begin{aligned} |\psi (x)-x|<\frac{\sqrt{x}}{8\pi }\log x(\log x-C),\quad \text {for }x>A, \end{aligned}$$
(3.8)

where \(C=2.44\). Next, we define

$$\begin{aligned} c(x)=\frac{1}{2}\log x+D,\qquad \varepsilon (x)=\frac{\log ^{3/2}x\log \log x}{E\sqrt{x}}, \end{aligned}$$
(3.9)

where \(D=6\) and \(E=16\). To simplify notation we write \(c=c(x)\) and \(\varepsilon =\varepsilon (x)\). Note that for these choices of D and E, we have \(c>35\), \(\varepsilon <4.9\cdot 10^{-11}\) and

$$\begin{aligned} \frac{c}{\varepsilon }\le \left( \frac{1}{2}E+\frac{DE}{\log A}\right) \frac{1}{\log \log x}\sqrt{\frac{x}{\log x}}\le \frac{B}{\log \log x}\sqrt{\frac{x}{\log x}}\le T. \end{aligned}$$

Hence, we may assume \(\Re (\rho )=\frac{1}{2}\) for zeros \(\rho \) with \(|\Im (\rho )|\le \frac{c}{\varepsilon }\).

Now, recall from (2.2) that

$$\begin{aligned} x-\psi _{c,\varepsilon }(x)=\sum _{\rho }\frac{a_{c,\varepsilon }(\rho )}{\rho }x^\rho +\Theta (2). \end{aligned}$$

To prove (3.8) we split \(\sum _{\rho }\frac{a_{c,\varepsilon }(\rho )}{\rho }x^\rho \) into three parts and then bound \(|\psi (x)-\psi _{c,\varepsilon }(x)|\). For \(|\Im (\rho )|>c/\varepsilon \), Lemma 2.1 gives

$$\begin{aligned} \sum _{|\Im (\rho )|>\frac{c}{\varepsilon }}\left| a_{c,\varepsilon }(\rho )\frac{x^{\rho }}{\rho }\right|&\le 0.16\frac{x+1}{\sinh (c)}e^{0.71\sqrt{c\varepsilon }}\log (3c)\log \left( \frac{c}{\varepsilon }\right) \nonumber \\&\le {\mathcal {E}}_1(x), \end{aligned}$$
(3.10)

where

$$\begin{aligned} {\mathcal {E}}_1(x)=0.000032\sqrt{x}\log x\log \log x. \end{aligned}$$

The inequality in (3.10) follows by noticing that for \(x>A\)

$$\begin{aligned} \left( \frac{x+1}{\sinh (c)}\right) /\sqrt{x},\ e^{0.71\sqrt{c\varepsilon }} \text { and } \log (3c)/\log \log x \end{aligned}$$

are all decreasing functions and \(\log (\frac{c}{\varepsilon })/\log x\le \frac{1}{2}\). Substituting \(x=A\) into

$$\begin{aligned} \frac{0.16\frac{x+1}{\sinh (c)}e^{0.71\sqrt{c\varepsilon }}\log (3c)}{\sqrt{x}\log x}\times \frac{1}{2} \end{aligned}$$

then gives \(0.0000316\ldots \le 0.000032\).

When \(\frac{\sqrt{2c}}{\varepsilon }<\Im (\rho )<\frac{c}{\varepsilon }\) we use the second part of Lemma 2.1 with \(a=\sqrt{\frac{2}{c}}\) to obtain

$$\begin{aligned} \sum _{\frac{\sqrt{2c}}{\varepsilon }<|\Im (\rho )|\le \frac{c}{\varepsilon }}\left| a_{c,\varepsilon }(\rho )\frac{x^{\rho }}{\rho }\right|&\le \frac{1+11c\varepsilon }{2\pi }\log \left( \frac{c}{\varepsilon }\right) \frac{\cosh (c\sqrt{1-a^2})}{\sinh (c)}\sqrt{x} \end{aligned}$$
(3.11)
$$\begin{aligned}&\le {\mathcal {E}}_2(x), \end{aligned}$$
(3.12)

where

$$\begin{aligned} {\mathcal {E}}_2(x)=0.0293\sqrt{x}\log x. \end{aligned}$$

For the inequality in (3.12), we note that similarly to before \(\frac{1+11c\varepsilon }{2\pi }\) is decreasing and \(\log \left( \frac{c}{\varepsilon }\right) /\log x\le \frac{1}{2}\) for \(x>A\). Then,

$$\begin{aligned} \frac{\cosh (c\sqrt{1-a^2})}{\sinh (c)}&=\frac{e^{\sqrt{\frac{1}{2}\log x+D}\sqrt{\frac{1}{2}\log x+D-2}}+e^{-\sqrt{\frac{1}{2}\log x+D}\sqrt{\frac{1}{2}\log x+D-2}}}{e^{\frac{1}{2}\log x+D}-e^{-\frac{1}{2}\log x-D}}\\&\le \frac{e^{\frac{1}{2}\log x+D-1}+e^{-\sqrt{\frac{1}{2}\log x+D}\sqrt{\frac{1}{2}\log x+D-2}}}{e^{\frac{1}{2}\log x+D}}\\&=\frac{1}{e}+\frac{1}{e^{\sqrt{\frac{1}{2}\log x+D}\sqrt{\frac{1}{2}\log x+D-2}+\frac{1}{2}\log x+D}}, \end{aligned}$$

which is also decreasing. Substituting \(x=A\) into

$$\begin{aligned} \frac{1}{2}\cdot \frac{1+11c\varepsilon }{2\pi }\cdot \left( \frac{1}{e}+\frac{1}{\exp \left( \sqrt{\frac{1}{2}\log x+D}\sqrt{\frac{1}{2}\log x+D-2}+\frac{1}{2}\log x+D\right) }\right) , \end{aligned}$$

then gives \(0.0292\ldots \le 0.0293\).

Next, we consider the range \(0<|\Im (\rho )|\le \frac{\sqrt{2c}}{\varepsilon }\). Note that

$$\begin{aligned} a_{c,\varepsilon }(\rho )&=\frac{\sqrt{\varepsilon ^2/4+c^2}}{\sinh (\sqrt{\varepsilon ^2/4+c^2})}\times \frac{\sin (\sqrt{\Im (\rho )^2\varepsilon ^2-c^2})}{\sqrt{\Im (\rho )^2\varepsilon ^2-c^2}}\nonumber \\&=\frac{\sqrt{\varepsilon ^2/4+c^2}}{\sinh (\sqrt{\varepsilon ^2/4+c^2})}\times \frac{\sinh (\sqrt{c^2-\Im (\rho )^2\varepsilon ^2})}{\sqrt{c^2-\Im (\rho )^2\varepsilon ^2}} \end{aligned}$$
(3.13)
$$\begin{aligned}&\le \frac{c}{\sinh (c)}\times \frac{\sinh (c)}{c}=1. \end{aligned}$$
(3.14)

In particular, (3.13) follows since \(|\Im (\rho )|\le \frac{c}{\varepsilon }\le T\) and (3.14) follows since \(\frac{x}{\sinh (x)}\) is decreasing for \(x>0\). Hence \(|a_{c,\varepsilon }(\rho )/\rho |\le 1/|\Im (\rho )|\) and so Lemma 2.2 gives

$$\begin{aligned} \sum _{0<|\Im (\rho )|\le \frac{\sqrt{2c}}{\varepsilon }}\left| a_{c,\varepsilon }(\rho )\frac{x^{\rho }}{\rho }\right|&\le \frac{\sqrt{x}}{2\pi }\log \left( \frac{\sqrt{2c}}{2\pi \varepsilon }\right) ^2\nonumber \\&=\frac{\sqrt{x}}{2\pi }\log \left( \frac{E\sqrt{x}\sqrt{\log x+2D}}{2\pi \log ^{3/2} x\log \log x}\right) ^2\nonumber \\&\le \frac{\sqrt{x}}{2\pi }\log \left( \frac{E\sqrt{x}\sqrt{\log x+2D\frac{\log x}{\log (A)}}}{2\pi \log ^{3/2}x\log \log x}\right) ^2\nonumber \\&\le \frac{\sqrt{x}}{2\pi }\left( \frac{1}{2}\log x+\log (2.8)-\log \log x-\log \log \log x\right) ^2\nonumber \\&\le \frac{\sqrt{x}}{8\pi }\log ^2x+{\mathcal {E}}_3(x), \end{aligned}$$
(3.15)

where

$$\begin{aligned} {\mathcal {E}}_3(x):=\frac{\sqrt{x}}{2\pi }\left( \frac{1}{2}\log x+\log (2.8)-\log \log x-\log \log \log x\right) ^2-\frac{\sqrt{x}}{8\pi }\log ^2x. \end{aligned}$$

We now bound \(|\psi (x)-\psi _{c,\varepsilon }(x)|\). By Lemma 2.4

$$\begin{aligned} \frac{0.98}{\sqrt{2\pi c}}\le \frac{I_1(c)}{2\sinh (c)}\le \frac{1}{\sqrt{2\pi c}}. \end{aligned}$$
(3.16)

Combining (3.16) and Lemma 2.3 with our definition (3.9) of \(\varepsilon \) then gives

$$\begin{aligned} |\psi (x)-\psi _{c,\varepsilon }(x)|&\le \frac{2.0001\sqrt{x}\log ^{5/2}x\log \log x}{E\sqrt{\pi (\log x+2D)}}\log \left( \frac{0.97\sqrt{x}\log ^{3/2}x\log \log x}{E\sqrt{\pi (\log x+2D)}}\right) ^{-1}\nonumber \\&\quad +\frac{2.02}{E}\log ^{5/2}x\log \log x+0.51\log x\log \log (2x^2). \end{aligned}$$
(3.17)

Since \(x>A=2.169\cdot 10^{25}\), we have

$$\begin{aligned} \log \left( \frac{0.97\sqrt{x}\log ^{3/2} x\log \log x}{E\sqrt{\pi (\log x+2D)}}\right) \ge \log (\sqrt{x})=\frac{1}{2}\log x. \end{aligned}$$

Hence, dividing the first summand in (3.17) by \(\sqrt{x}\frac{\log ^{3/2}x\log \log x}{\sqrt{\log x+2D}}\) gives

$$\begin{aligned} \frac{2.0001\log x}{E\sqrt{\pi }}\log \left( \frac{0.97\sqrt{x}\log ^{3/2}x\log \log x}{E\sqrt{\pi (\log x+2D)}}\right) ^{-1}&\le \frac{2.0001\log x}{E\sqrt{\pi }}\times \frac{2}{\log x}\\&=0.141\ldots \le 0.142. \end{aligned}$$

So if we define

$$\begin{aligned} {\mathcal {E}}_4(x)=0.142\sqrt{x}\frac{\log ^{3/2}x\log \log x}{\sqrt{\log x+2D}} \end{aligned}$$

and

$$\begin{aligned} {\mathcal {E}}_5(x):=\frac{2.02}{E}\log ^{5/2}x\log \log x+0.51\log x\log \log (2x^2)+2 \end{aligned}$$

then

$$\begin{aligned} |\psi (x)-\psi _{c,\varepsilon }(x)|\le {\mathcal {E}}_4(x)+{\mathcal {E}}_5(x). \end{aligned}$$
(3.18)

Thus, by (2.2), (3.10), (3.12), (3.15) and (3.18)

$$\begin{aligned} |\psi (x)-x|\le \frac{\sqrt{x}}{8\pi }\log ^2x+{\mathcal {E}}_1(x)+{\mathcal {E}}_2(x)+{\mathcal {E}}_3(x)+{\mathcal {E}}_4(x)+{\mathcal {E}}_5(x). \end{aligned}$$

Now consider the function

$$\begin{aligned} {\mathcal {E}}(x)=\frac{1}{\sqrt{x}\log x}({\mathcal {E}}_1(x)+{\mathcal {E}}_2(x)+{\mathcal {E}}_3(x)+{\mathcal {E}}_4(x)+{\mathcal {E}}_5(x)). \end{aligned}$$

Differentiating \({\mathcal {E}}(x)\) with respect to \(y=\log x\) we see that \({\mathcal {E}}(x)\) is decreasing for \(x>A\). Moreover, \({\mathcal {E}}(A)=-0.0976\ldots <-\frac{C}{8\pi }=-0.0970\ldots \). This proves (3.8). Letting \(T=3\cdot 10^{12}\) in (3.7) and using Proposition 3.1 then gives

$$\begin{aligned} |\psi (x)-x|<\frac{\sqrt{x}}{8\pi }\log x(\log x-C)\quad \text {for }5000\le x\le 9.68\cdot 10^{25}. \end{aligned}$$
(3.19)

From (3.19), we also obtain

$$\begin{aligned} |\theta (x)-x|<\frac{\sqrt{x}}{8\pi }\log x(\log x-2)\quad \text {for }5000\le x\le 9.68\cdot 10^{25}. \end{aligned}$$
(3.20)

To see this, we use recent estimates by Broadbent et al. [4,  Corollary 5.1] for \(\psi (x)-\theta (x)\). NamelyFootnote 1

$$\begin{aligned} \psi (x)-\theta (x)<a_1x^{1/2}+a_2x^{1/3}, \end{aligned}$$

where for \(x\ge e^{50}\approx 5.18\cdot 10^{21}\), we can take \(a_1=1+1.93378\cdot 10^{-8}\) and \(a_2=1.01718\). In particular, for \(x>A\) we have \(\psi (x)-\theta (x)\le (C-2)\frac{\sqrt{x}}{8\pi }\log x\). Hence (3.20) holds for \(A<x\le 9.68\cdot 10^{25}\) since

$$\begin{aligned} |\theta (x)-x|\le \psi (x)-\theta (x)+|\psi (x)-x|. \end{aligned}$$

For the remaining values of x, we use Proposition 3.1.

We now repeat the entire proof with

$$\begin{aligned} (A,B,C,D,E)=(9.68\cdot 10^{25},9.34,2.43,5,16). \end{aligned}$$

The error terms then update to (with more precision added this time):

$$\begin{aligned} {\mathcal {E}}_1(x)&=0.0000839\sqrt{x}\log x\log \log x,\\ {\mathcal {E}}_2(x)&=0.02928\sqrt{x}\log x,\\ {\mathcal {E}}_3(x)&=\frac{\sqrt{x}}{2\pi }\left( \frac{1}{2}\log x+\log (2.751)-\log \log x-\log \log \log x\right) ^2-\frac{\sqrt{x}}{8\pi }\log ^2x,\\ {\mathcal {E}}_4(x)&=0.1411\sqrt{x}\frac{\log ^{3/2}x\log \log x}{\sqrt{\log x+10}},\\ {\mathcal {E}}_5(x)&=0.12625\log ^{5/2}x\log \log x+0.51\log x\log \log (2x^2)+2,\\ {\mathcal {E}}(A)&=-0.0967\ldots \end{aligned}$$

and we get

$$\begin{aligned} |\psi (x)-x|<\frac{\sqrt{x}}{8\pi }\log x(\log x-C)\quad \text {for }5000\le x\le 1.03\cdot 10^{26},\\ |\theta (x)-x|<\frac{\sqrt{x}}{8\pi }\log x(\log x-2)\quad \text {for }5000\le x\le 1.03\cdot 10^{26}. \end{aligned}$$

Iterating again with

$$\begin{aligned} (A,B,C,D,E)=(1.03\cdot 10^{26},9.08,2.42,2.4,16.8) \end{aligned}$$

followed by

$$\begin{aligned} (A,B,C,D,E)=(1.096\cdot 10^{26},9.06,2.42,2.34,16.8) \end{aligned}$$

we get

$$\begin{aligned} |\psi (x)-x|<\frac{\sqrt{x}}{8\pi }\log x(\log x-C), \end{aligned}$$
(3.21)
$$\begin{aligned} |\theta (x)-x|<\frac{\sqrt{x}}{8\pi }\log x(\log x-2) \end{aligned}$$
(3.22)

for \(x\ge 5000\) and \(\frac{9.06}{\log \log x}\sqrt{\frac{x}{\log x}}\le T\). Combining (3.21) and (3.22) with Proposition 3.1 proves (3.3) and (3.4). Certainly, one could perform further iterations but this would produce a minimal improvement.

Now, using integration by parts

$$\begin{aligned} li(x)-li(a)=\frac{x}{\log x}+\int _a^x\frac{\mathrm {d}t}{\log ^2t}-\frac{a}{\log a} \end{aligned}$$

so that by partial summation

$$\begin{aligned} \pi (x)-\pi (a)=li(x)-li(a)-\frac{x-\theta (x)}{\log x}+\frac{a-\theta (a)}{\log a}-\int _a^x\frac{t-\theta (t)}{t\log ^2t}\mathrm {d}t. \end{aligned}$$

Hence, for \(5000\le x\) and \(\frac{9.06}{\log \log x}\sqrt{\frac{x}{\log x}}\le T\),

$$\begin{aligned} |\pi (x)-li(x)|&\le \frac{\sqrt{x}}{8\pi }(\log x-2)+\left| \pi (5000)-li(5000)-\frac{\theta (5000)-5000}{\log (5000)}\right| \\&\quad +\frac{\sqrt{x}}{4\pi }-\frac{\sqrt{5000}}{4\pi }\\&=\frac{\sqrt{x}}{8\pi }\log x+4.91...-\frac{\sqrt{5000}}{4\pi }\\&=\frac{\sqrt{x}}{8\pi }\log x+4.91...-5.62...\\&<\frac{\sqrt{x}}{8\pi }\log x. \end{aligned}$$

Making use of (3.21) as opposed to (3.22) then gives \(|\Pi (x)-li(x)|<\frac{\sqrt{x}}{8\pi }\log x\). Combined with Proposition 3.1, we obtain (3.5) and (3.6), thereby completing the proof of the theorem. \(\square \)

Setting \(T=3\cdot 10^{12}\) we obtain the following result.

Corollary 3.3

The bounds (3.3)-(3.6) hold for \(x\le 1.101\cdot 10^{26}\).

4 Possible improvements and variations

4.1 Improvements for larger T

The constant 9.06 appearing in (1.2) can be lowered if the Riemann hypothesis were verified to a higher height. This is because a higher value of T means that the bounds (3.3)–(3.6) hold for larger values of x, thereby giving sharper error terms in the proof of Theorem 3.2. Table 1 lists improvements that one would get by increasing T to \(10^{13}\), \(10^{14}\), and \(10^{15}\). The values in the table were computed using the same iterative method as in the proof of Theorem 3.2.

Table 1 Value of K such that (3.3)–(3.6) hold for \(\frac{K}{\log \log x}\sqrt{\frac{x}{\log x}}\le T\) when \(T\ge T_0\). Here, \(x_{\text {max}}\) is the largest value of x for which this inequality holds when \(T=T_0\)

4.2 Weakening the constant

Using the methods in Section 3, we can obtain weaker bounds that hold for larger ranges of x. Here, the main idea is to alter the definition of \({\mathcal {E}}_3(x)\) and thereby change the leading term in (3.15). Doing this with the constant changed from \(1/8\pi \) to a selection of larger values, we obtained the following result.

Theorem 4.1

Let \(T>0\) be such that the Riemann hypothesis holds for zeros \(\rho \) with \(0<\Im (\rho )\le T\). Then, for corresponding values of a and K in Table 2, the following estimates hold:

$$\begin{aligned} |\psi (x)-x|&<a\sqrt{x}\log ^2x&\text {for }x\ge 3, \end{aligned}$$
(4.1)
$$\begin{aligned} |\theta (x)-x|&<a\sqrt{x}\log ^2x&\text {for }x\ge 3,\end{aligned}$$
(4.2)
$$\begin{aligned} |\Pi (x)-li(x)|&<a\sqrt{x}\log x&\text {for }x\ge 2,\end{aligned}$$
(4.3)
$$\begin{aligned} |\pi (x)-li(x)|&<a\sqrt{x}\log x&\text {for }x\ge 2, \end{aligned}$$
(4.4)

provided \(K\sqrt{\frac{x}{\log ^3x}}\le T\).

Proof

Let \((a,K)=(1,1.19)\). For other values of a and K, the method of proof is essentially identical. We use the same general reasoning as in the proof of Theorem 3.2. Hence, we only describe the small modifications required in this setting.

Table 2 Corresponding values of a and K for Theorem 4.1. The value \(x_{\text {max}}\) is the largest x for which the inequalities (4.1)–(4.4) hold upon setting \(T=3\cdot 10^{12}\)

Firstly, the minimum values for x appearing in (4.1)–(4.4) were obtained by checking each expression manually up to the minimum values appearing in (3.3)–(3.6). We then let

$$\begin{aligned} c(x)=\frac{1}{2}\log x+D,\qquad \varepsilon (x)=\frac{\log ^{5/2}x}{E\sqrt{x}}, \end{aligned}$$
(4.5)

initially setting \(D=0\) and \(E=2.4\). Each of the error terms \({\mathcal {E}}_1(x),\ldots ,{\mathcal {E}}_5(x)\) changed slightly due to the new choice of \(\varepsilon (x)\) in (4.5). The main difference occurred with \({\mathcal {E}}_3(x)\) and \({\mathcal {E}}_4(x)\), now given by

$$\begin{aligned} {\mathcal {E}}_3(x)&:=\frac{\sqrt{x}}{2\pi }\left( \frac{1}{2}\log x+\log (\alpha )-2\log \log x\right) ^2-a\sqrt{x}\log ^2x,\\ {\mathcal {E}}_4(x)&:=\beta \sqrt{x}\log ^2x \end{aligned}$$

for some computable constants \(\alpha \) and \(\beta \). In particular, this definition of \({\mathcal {E}}_3(x)\) gives

$$\begin{aligned} \sum _{0<|\Im (\rho )|\le \frac{\sqrt{2c}}{\varepsilon }}\left| a_{c,\varepsilon }(\rho )\frac{x^{\rho }}{\rho }\right| \le a\sqrt{x}\log ^2x+{\mathcal {E}}_3(x). \end{aligned}$$

For the iterative process we started with \(A=1.101\cdot 10^{26}\) (as per Corollary 3.3), \(B=1.2\), \(C=2.017\), \(D=0\) and \(E=2.4\). Here, B was such that the inequalities (4.1)–(4.4) held for \(B\sqrt{\frac{x}{\log (x)^3}}\le T\) and C was such that

$$\begin{aligned} |\psi (x)-x|<a\sqrt{x}\log x(\log x-C), \end{aligned}$$

held for each x in this range. For the second iteration we used

$$\begin{aligned} (A,B,C,D,E)=(2.128\cdot 10^{30},1.19,2.015,0,2.38), \end{aligned}$$

which gave the desired result. \(\square \)

Remark

In the above proof, we fixed \(D=0\). A small improvement is possible if we allowed D to be negative. However, this requires reworking several inequalities from the proof of Theorem 3.2 so we decided not to do so here.

5 An inequality of Ramanujan

In one of his notebooks, Ramanujan proved that the inequality

$$\begin{aligned} \pi (x)^2<\frac{ex}{\log x}\pi \left( \frac{x}{e}\right) \end{aligned}$$
(5.1)

holds for sufficiently large x (see [2], pp 112–114). Several authors ( [1, 8, 9, 12]) have attempted to make (5.1) completely explicit. It is widely believed that the last integer counterexample occurs at \(x=38,358,837,682\). In fact, this follows under assumption of the Riemann hypothesis [8,  Theorem 1.3].

The best unconditional result is due to Platt and Trudgian [12,  Theorem 2]. In particular, they show that (5.1) holds for both \(38,358,837,683\le x\le \exp (58)\) and \(x\ge \exp (3915)\). Our bounds on \(\pi (x)\) allow for a significant improvement on the first of these results. To demonstrate this, we use a simple (but computationally intensive) method to verify (5.1), obtaining the following result.

Theorem 5.1

For \(38,358,837,683\le x\le \exp (103)\), Ramanujan’s inequality (5.1) holds unconditionally.

Proof

For \(38,358,837,682<x\le \exp (43)\), the theorem follows from [1], Theorem 3. Platt and Trudgian also prove (5.1) for \(\exp (43)<x\le \exp (58)\) but the author thought it would be instructive to re-establish their result.

So, let \(x>\exp (43)\) and write \(z=\log x\). Then (5.1) is equivalent to

$$\begin{aligned} \frac{e^{z+1}}{z}\pi (e^{z-1})-\pi (e^z)^2>0. \end{aligned}$$
(5.2)

Set \(a=1/8\pi \). By Theorem 3.2 we have that \(|\pi (x)-li(x)|<a\sqrt{x}\log x\) for \(\exp (43)<x\le \exp (59)\). Thus, (5.2) is true in this range provided

$$\begin{aligned} \frac{e^{z+1}}{z}li(e^{z-1})-\frac{a(z-1)}{ z}e^{\frac{3z+1}{2}}-\left( li(e^z)+aze^{z/2}\right) ^2>0 \end{aligned}$$
(5.3)

for \(43<z\le 59\). We write

$$\begin{aligned} f(z)=\frac{e^{z+1}}{z}li(e^{z-1}),\quad g(z)=\frac{a(z-1)}{ z}e^{\frac{3z+1}{2}}+\left( li(e^z)+aze^{z/2}\right) ^2 \end{aligned}$$

so that (5.3) is equivalent to \(f(z)-g(z)>0\). Note that f(z) and g(z) are both increasing for \(z>1\). Hence, if \(f(z_0)>g(z_0+\delta )\) for some \(z_0>1\) and \(\delta >0\), then \(f(z)>g(z)\) for every \(z\in (z_0,z_0+\delta )\). We thus performed a “brute force" verification by setting \(\delta =5\cdot 10^{-8}\) and showing that

$$\begin{aligned} f(43)-g(43+\delta )>0,\ f(43+\delta )-g(43+2\delta )>0,\ \ldots ,\ f(59-\delta )-g(59)>0. \end{aligned}$$

This was achieved using a short algorithm written in Python. The computations took just under a day on a 2.4GHz laptop.

We then repeated the above argument using Theorem 4.1 with \(a=1\) and a smaller \(\delta =2.5\cdot 10^{-8}\). This proved (5.1) for \(\exp (59)<x\le \exp (69)\). Continuing in this fashion for each value of a in Table 2 we see that (5.1) holds in the range \(\exp (43)<x\le \exp (103)\) as desired. \(\square \)

Certainly one could extend Table 2 and the computations in the above proof. However this would require a large amount of computation time. Thus, to improve on Theorem 5.1 the author suggests switching to a more sophisticated and less computational method. For instance, one could attempt to modify the arguments in [1,  Section 6] or [12,  Section 5].

6 Future work

There are several ways in which one could expand on the work in this paper, for instance:

  1. (1)

    One could produce a wider range of weakened bounds similar to those in Theorem 4.1. For example, one could provide a more general expression for K as a function of a.

  2. (2)

    One could produce analogous results for primes in arithmetic progressions. To do this, one would need to rework the results in this paper and [5] using computations of zeros of Dirichlet L-functions (e.g. [10]) and the explicit formula for \(\psi (x,\chi )\) [7,  Chapter 19]. Then, if desired, one could also consider other types of L-functions.

  3. (3)

    As discussed in Section 5, it is possible to improve Theorem 5.1 with some work. It would be interesting to optimise the results of this paper and those in [12] to see how close one could get to making Ramanujan’s inequality completely explicit.