0

Old vs New

I've been working on Predicting the next prime using only previous primes.

For example, given the primes $2,3,5,7,11,13,17,19,23$, this formula predicts the next prime $p_{10}=29$

$$ p_k = \left\lceil \left( 1 - \frac{1}{\zeta\left(k \cdot \ln(k \ln k)\right) \cdot \prod_{j=1}^{k-1} \left( 1 - p_j^{-k \cdot \ln(k \ln k)} \right)} \right)^{-\frac{1}{k \cdot \ln(k \ln k)}} \right\rceil $$

However, it's extremely slow in Python code, especially when computing the Riemann zeta function $\zeta(s)$.

To improve efficiency, here's the reworked version:

$$ p_k = \left\lceil \left( 1 - \frac{1}{\left( \sum_{n=1}^{\left\lceil k (\ln k + \ln \ln k) \right\rceil + 5} \frac{1}{n^{k \ln(k \ln k)}} \right) \cdot e^{\sum_{j=1}^{k-1} \ln\left( 1 - p_j^{-k \ln(k \ln k)} \right)}} \right)^{-\frac{1}{k \ln(k \ln k)}} \right\rceil $$

Changes

The differences between the old and new formulas are:

  1. Replaced $\zeta(s)$ with a finite summation using the upper bound $n(\ln n+\ln\ln n)$.
  2. Replaced the product $\prod$ with the summation $\sum$.

Justification

Luckily, there are some inequalities for the $n$th prime:

$$n (\ln n + \ln \ln n - 1) < p_n < n (\ln n + \ln \ln n) \quad \text{for } n > 6.$$

The lower bound is due to Dusart (1999) and the upper bound to Rosser (1941).

Using Rosser's upper bound, the finite summation retains the hidden prime structure.

Question

Can the upper bound $\left\lceil k (\ln k + \ln \ln k) \right\rceil + 5$ be tightened to reduce computation time?

References

https://en.wikipedia.org/wiki/Prime-counting_function

The kth prime is greater than k(ln k + ln ln k − 1) for k ≥ 2

Explicit bounds for some functions of prime numbers

vengy
  • 2,421
  • 1
    Dusart's and Rosser's bounds on $p_n$ has been improved by Christian Axler in 2018 which could improve your formula. Check out of Theorem 1.1 and 1.2 of https://arxiv.org/pdf/1706.03651 – Nilotpal Sinha Jan 12 '25 at 21:24

0 Answers0