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:
- Replaced $\zeta(s)$ with a finite summation using the upper bound $n(\ln n+\ln\ln n)$.
- 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