# Can I calculate the product over the primes efficiently and with high precision?

I want to calculate the following product : $$\prod_{p\ prime\ ,\ p\le 10^{10}} 1-\frac{1}{p}$$

I know the approximation formula $$\frac{e^{-\gamma}}{\ln(10^{10})}$$ where $\gamma$ is the Euler-Mascheroni-constant. The result should be good to $12$ decimal digits.

Is there an efficient way (not brute force by determining all primes, which takes long with PARI/GP) to calculate this product with high precision ?

Call the product $P$, and take logs to get $\log(P)=\sum_{i=1}^n\log(1-1/p_i)=-\sum_{i=1}^n\frac{1}{p_i}-\frac{1}{2}\sum_{i=1}^n\frac{1}{p^2_i}+...\approx-\sum_{i=1}^n\frac{1}{p_i}-\gamma$
So to get a good approximation, use ever-better approximations of $\sum_{i=1}^n\frac{1}{p_i}$. As an example, the Meissel Merten constant is defined as $M:=\lim_{n\rightarrow\infty}\sum_{i=1}^n1/p_i-\ln\ln(n)\approx 0.26149$.
If you're still getting error, you can look into the error for finite sum approximations of $\gamma=\sum_{m=2}^\infty (-1)^m\frac{\zeta(m)}{m}$.
• I do not get good approximations this way for $n=\pi(10^6)$. Please work out examples, perhaps I missed something. Additionally, the sum requires also the primes because the convergence towards Merten's constant is very very slow. – Peter Apr 3 '18 at 21:46
• You can find a detailed discussion on how to better approximate $B$ to any accuracy here: pdfs.semanticscholar.org/0ff0/… – Alex R. Apr 3 '18 at 21:54