# On the connection between sums of prime numbers and distribution of prime numbers

As an amateur mathematician, I have always been fascinated by the magic of prime numbers, and their apparently random distribution. I was utterly amazed when I found the following connection between sums of prime numbers and its distribution:

Theorem 1

Let us define the prime counting function up to a given natural number $$n$$ as $$\pi(n)$$, and the sum of consecutive prime numbers up to the integer part of the square root of a given natural number $$n$$ as $$S(n)=\sum_{p\leq\sqrt{n}}p$$. Then, we have that $$S(n)\sim\pi(n)$$.

Proof

By partial summation $$S(n)=(\left\lfloor \sqrt{n}\right\rfloor \pi(\sqrt{n}))-\sum_{m=2}^{\left\lfloor \sqrt{n}\right\rfloor -1}\pi(m)$$

Where $$\left\lfloor \sqrt{n}\right\rfloor$$ denotes the integer part of $$\sqrt{n}$$.

By the Prime Number Theorem with error term, there exists a constant $$C$$ such that $$\Big|\pi(x)-\frac{x}{\log x}\Big|\le C\frac{x}{\log^{2}x}\qquad\text{for }x\ge2$$

Therefore, substituting $$\pi(\sqrt{n})$$ and $$\pi(m)$$ by the application of the Prime Number Theorem, we get that $$S(n)=(\left\lfloor \sqrt{n}\right\rfloor \frac{\sqrt{n}}{\log(\sqrt{n})})-\sum_{m=2}^{\left\lfloor \sqrt{n}\right\rfloor -1}\frac{m}{\log(m)}+O\left(\frac{n}{\log^{2}(\sqrt{n})}\right)$$

Applying Riemman Sums theory, we get that $$\sum_{m=2}^{\left\lfloor \sqrt{n}\right\rfloor -1}\frac{m}{\log(m)}=\int_{2}^{\left\lfloor \sqrt{n}\right\rfloor }\frac{x}{\log\left(x\right)}dx+O\left(\frac{n}{\log^{2}(\sqrt{n})}\right)$$

Solving the integral by partial integration, we have that

$$\int_{2}^{\left\lfloor\sqrt{n}\right\rfloor}\frac{x}{\log\left(x\right)}dx=$$

$$=\frac{n}{2\ln\left(\left\lfloor\sqrt{n}\right\rfloor \right)}+O\left(\frac{n}{\log^{2}(\sqrt{n})}\right)$$

It is easy to see that $$\frac{n}{2\log\left(\left\lfloor \sqrt{n}\right\rfloor \right)}\sim\frac{n}{\log n}$$

Thus, $$\sum_{m=2}^{\left\lfloor \sqrt{n}\right\rfloor -1}\frac{m}{\log(m)}\sim\frac{n}{\log\left(n\right)}+O\left(\frac{n}{\log^{2}(\sqrt{n})}\right)$$

It can be seen that $$\left\lfloor \sqrt{n}\right\rfloor \frac{\sqrt{n}}{\log(\sqrt{n})}\sim\frac{n}{\log\left(\sqrt{n}\right)}=\frac{n}{\frac{1}{2}\log\left(n\right)}=\frac{2n}{\log\left(n\right)}$$

Substituting, we have that $$S(n)\sim\frac{2n}{\log\left(n\right)}-\frac{n}{\log\left(n\right)}+O\left(\frac{n}{\log^{2}(\sqrt{n})}\right)$$

As $$\frac{2n}{\log\left(n\right)}-\frac{n}{\log\left(n\right)}=\frac{n}{\log\left(n\right)}$$

Thus, $$S(n)\sim\frac{n}{\log\left(n\right)}$$

And subsequently, as by the Prime Number Theorem $$\pi(n)\sim\frac{n}{\log(n)}$$ it can be stated that $$S(n)\sim\pi(n)$$

After reaching this nice result, I wondered if it could happen that $$S(n)=\pi(n)$$, and found that the answer was YES. In fact, as I found that there were many cases such that $$S(n)=\pi(n)$$, I conjectured that this equality occured infinitely often. And thanks to GH from MO, the conjecture was proven here for $$n$$ being prime, and thus we can state that

Theorem 2

$$S(n)=\pi(n)$$ infinitely often

As the prime counting function up to some composite number equals the prime counting function up to the inmediate prior prime number, considering the set $$M=\{m_{1},m_{2},...,m_{k}\}$$ as the set of values of $$n$$ such that $$\pi\left(n\right)=S\left(n\right)$$ and $$n$$ is some prime number, if $$\pi\left(m_{k}\right)=S\left(m_{k}\right)$$, then, as $$\pi\left(m_{k}\right)=\pi\left(m_{k}+1\right)=\pi\left(m_{k}+2\right)=...=\pi\left(m_{k+1}-1\right)$$, it follows that all the composite numbers between $$m_{k}$$ and $$m_{k+1}$$ are intersection points.

A pending question to be solved is that he first value of $$n$$ with a concrete $$\pi\left(n\right)=S\left(n\right)$$ seems to be always a prime number. This conjecture assumes the truth of the following

Conjecture. It does not exist any squared prime number $$p_{k}^{2}$$ such that $$\pi\left(p_{k}^{2}\right)=S\left(p_{k}^{2}\right)$$ except of $$p_{1}=2$$. That is, $$\pi\left(p_{k}^{2}\right)\neq\sum_{i=1}^{k}p_{i}$$

The conjecture has been tested and found to be true for the first thousands of primes. As if $$\pi\left(p_{k}^{2}\right)=S\left(p_{k}^{2}\right)$$ then necessarily $$\pi\left(p_{n}\right)-S\left(p_{n}\right)=p_k$$, where $$p_n$$ is the prime number inmediately lesser than $$p_{k}^2$$, one way to prove the conjecture would be to improve the result proved by GH from MO $$\pi(x)-S(x)=\Omega_\pm(x^\frac{1}{2})$$ to $$\pi(x)-S(x)\leq{x^\frac{1}{2}}$$ for all $$x\in\mathbb{P}$$, or at least for those prime numbers inmediately lesser than $$p_{k}^{2}$$.

Now, many further questions regarding the connection between sums of prime numbers and its distribution remain unanswered, and honestly I do not really know how to deepen more on them. Do the two theorems exposed imply that the number of primes between $$p_{n}^{2}$$ and $$p_{n+1}^{2}$$ , on average, do not differ much from $$p_{n+1}$$? Does this connection add any new insight on the distribution of prime numbers, and it is worthy to be studied and exploited further to know more about the distribution of prime numbers? Is the result $$\pi(x)-S(x)\leq{x^\frac{1}{2}}$$ for all $$x\in\mathbb{P}$$, or at least for those prime numbers $$p_n$$ inmediately lesser than $$p_{k}^{2}$$ provable? Does it exist some counterexample?

The post that you quoted contains a proof that $$\pi(x)-S(x)=\Omega_\pm(x^c)\quad\text{for any}\quad c<3/4.$$ Equivalently, for any $$c<3/4$$ and any $$C>0$$, both $$\pi(x)-S(x)\leq Cx^c$$ and $$\pi(x)-S(x)\geq -Cx^c$$ are false.
• thanks for your contribution! However, if we have $f(x)=\pi(x)-S(x)$ and $g(x)=x^\frac{1}{2}$, and we state that $f(x)=\Omega_\pm(g(x)$, I understand it means that $\limsup_{x \to \infty} \frac{f(x)}{g(x)} > 0$ while $\liminf_{x \to \infty} \frac{f(x)}{g(x)} < 0$. Therefore, it could be the case that $\limsup_{x \to \infty} \frac{\pi(x)-S(x)}{x^\frac{1}{2}} < 1$ while $\liminf_{x \to \infty} \frac{\pi(x)-S(x)}{x^\frac{1}{2}} > -1$, which is compatible with both $\pi(x)-S(x)\leq{x^\frac{1}{2}}$ and $\pi(x)-S(x)\geq{-x^\frac{1}{2}}$. Or am I missing something? Jun 9 at 14:44
• @JuanMoreno: We have $\limsup\frac{\pi(x)-S(x)}{x^{2/3}}>0$, which is incompatible with $\pi(x)-S(x)\leq x^{1/2}$. Similarly, we have $\liminf\frac{\pi(x)-S(x)}{x^{2/3}}<0$, which is incompatible with $\pi(x)-S(x)\geq -x^{1/2}$ Jun 9 at 15:11
• For any $c<3/4$ we have $\limsup\frac{\pi(x)-S(x)}{x^c}>0>\liminf\frac{\pi(x)-S(x)}{x^c}$. In particular, we have this for $c=2/3$ , which contradicts your expectations. This is what I proved in my earlier post, I am sorry if that was not clear to you. Informally speaking, the difference of $\pi(x)$ and $S(x)$ is infinitely often as large as $x^{0.7499}$ (in both directions), and here you can replace $0.7499$ by anything less than $3/4$. Jun 9 at 16:33
• clear now, thanks for you explanation! Then it can be discarded to prove $\pi(x)-S(x)\leq{x^\frac{1}{2}}$ for all $x\in\mathbb{N}$. And it seems difficult to prove it for all $x\in\mathbb{P}$, or at least for those prime numbers $p_n$ inmediately lesser than $p_{k}^2$. What do you think about it? Or maybe there is another underlying reason for the conjecture to be true (or false!). Jun 9 at 17:31
• Using that, for large $x$, there is always prime in $[x,x+x^{3/5}]$, it follows from my earlier bounds that $\pi(x)-S(x)>x^{0.7499}$ holds for infinitely many primes $x$. Also, I don't think that investigating $\pi(x)-S(x)$ is an interesting research direction. Jun 9 at 17:41