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 $? 



Approximation for $ \inf\{r>0,(n-r,n+r)\in\mathbb{P}^{2}\} $ by minimizing a distance
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$).


