# Approximation for $\inf\{r>0,(n-r,n+r)\in\mathbb{P}^{2}\}$ by minimizing a distance

Under Goldbach's conjecture, let $$r_{0}(n) : =\inf\{r>0,(n-r,n+r)\in\mathbb{P}^{2}\}$$ and $$k_{0}(n) : =\pi(n+r_{0}(n))-\pi(n-r_{0}(n))$$. The PNT implies that one can expect to have $$\dfrac{2r_{0}(n)-1}{k_{0}(n)}\sim\log n$$.

As for all $$n>1$$ one has $$\tau(n)\geq 2$$, the equality occurring exactly whenever $$n$$ is prime, a very good approximation (actually, a tight upper bound) of $$k_{0}(n)$$ is given by the function $$S_{r_{0}(n)}(n)$$ where $$S_{r}(n) : =\left(\sum_{m=n-r}^{n+r}\dfrac{2^m}{\tau(m)^m}\right)-\frac{1}{2}$$.

Can one prove that $$r_{0}(n)$$ is the positive integer $$r$$ that minimizes the quantity $$\vert S_{r}(n)-\dfrac{2r-1}{\log n}\vert$$? If yes, can one get an upper bound for $$r_{0}(n)$$ in terms of $$n$$?

Certainly not, if the twin primes conjecture is true. When $$n$$ is large and $$n-1$$ and $$n+1$$ are both primes, then $$S_1(n)$$ is nearly exactly $$\frac32$$ and $$(2\cdot1-1)/\log n$$ is nearly $$0$$, and $$r=2$$ will already yield a smaller value of $$|S_r(n) - (2r-1)/\log n|$$ than $$r=1$$ (we lose $$2/\log n$$ but gain at most $$2\cdot(1/2)^{n-2}$$ in passing from $$r=1$$ to $$r=2$$).