For a prime $p$, define $\delta(p)$ to be the smallest offset $d$ from which $p$ differs from a square: $p = r^2 \pm d$, for $d,r \in \mathbb{N}$. For example, \begin{eqnarray} \delta(151) & = & +7 \;:\; 151 = 12^2 + 7 \\ \delta(191) & = & -5 \;:\; 191 = 14^2 - 5 \\ \delta(2748971) & = & +7 \;:\; 2748971= 1658^2 + 7 \end{eqnarray} For a particular $\delta=d$ value, define $\Delta(n,d)$ to be the number of primes $p$ at most $n$ with $\delta(p) = +d$, minus the number with $\delta(p) = -d$. In other words, $\Delta$ records the cumulative prevalence of $+d$ offsets over $-d$. For example, $\Delta(139,5)=-2$ because there are two more $-5$'s than $+5$'s up to $n=139$: $$ \delta(31)=-5 \;,\; \delta(41)=+5 \;,\; \delta(59)=-5\;,\; \delta(139) =-5 \;. $$ The figure below shows $\Delta(p,5)$ and $\Delta(p,7)$ out to the $200000$-th prime $2750159$. The offset $+7$ occurs $161$ times more than the offset $-7$, and the reverse occurs for $|\delta|=5$: $-5$ is more common than $+5$.


Q. Is there a simple explanation for the different behaviors of offsets $5$ and $7$?

Obviously the question can be generalized to explaining the growth for any $|\delta|$.

I previously asked a version of this question on MSE, using somewhat different notation conventions and with less focused questions.

  • $\begingroup$ The curve you plotted looks like a parabola. I don't know whether it can be explained though. $\endgroup$ – Sylvain JULIEN Apr 27 '17 at 11:12
  • $\begingroup$ The graph is a bit misleading, making the offsets seem small. In reality they are huge, once one keeps in mind that there are only about 1600 squares up to $2.7\times 10^6$ and and thus primes within $\pm 7$ (or $\pm 5$) of a square are only a smallish fraction of 3200 in number. I would be surprised if simple modular considerations don't explain the offsets. $\endgroup$ – Yaakov Baruch Apr 27 '17 at 11:34
  • $\begingroup$ And yes, in that case each curve would be close to $C \sqrt{n}/\log{n}$, so quite similar to a half parabola (and possibly with equal but opposite $C$ for the 2 cases). $\endgroup$ – Yaakov Baruch Apr 27 '17 at 11:45
  • 3
    $\begingroup$ This might have something to with with Chebyshev’s bias: note that $+7\equiv-5\equiv3\pmod4$. $\endgroup$ – Emil Jeřábek Apr 27 '17 at 12:04
  • 1
    $\begingroup$ The question title and text does not agree. Edit one of them. $\endgroup$ – Stig Hemmer Apr 28 '17 at 7:21

Consider $n^2+7$ and $n^2-7$ modulo $3$. If these are to be prime they must be non-zero $\pmod 3$, and in the first case $n$ can be anything mod $3$, whereas in the second case $n$ must be $0 \pmod 3$. If you consider $n^2+5$ and $n^2-5$, you see that the pattern reverses. This is already a huge bias for one offset to be preferred over the other.

The Hardy-Littlewood conjectures make this precise. One expects that (for a number $k$ not minus a square) the number of primes of the form $n^2+k$ with $n\le N$ (say) is $$ \sim \frac 12 \prod_{p\ge 3} \Big(1 -\frac{(\frac{-k}{p})}{p-1} \Big) \frac{N}{\log N}, $$ where in the numerator of the product above is the Legendre symbol. The constants in front of the $N/\log N$ explain these biases.

You don't have to worry about a smaller offset than $\pm 5$ or $\pm 7$, since an application of the sieve shows that the numbers $n^2+a$ and $n^2+b$ (for fixed $a$, $b$) are both prime only $\le CN/(\log N)^2$ of the time for a constant $C$.

| cite | improve this answer | |
  • 7
    $\begingroup$ Lucia of course knows this, but I thought it was worth mentioning that this product is well-approximated by the inverse special value $L(1,\chi)^{-1}$ of the $L$-function associated to the unique Dirichlet character $\chi$ mod $4k$ such that $\chi(p) = \left( \frac{-k}{p} \right)$. Known bounds on this special value thus gives bounds on how large and small this constant can be. $\endgroup$ – Will Sawin Apr 27 '17 at 17:45

Modulo 6 the squares are 0,1,4,3,4,1 and the squares+7 (or -5) can only be 1,2,5,4,5,2, of which 3/6 can at all be prime. The squares-7 (or +5) are 5,0,3,2,3,0 of which only 1/6 can be prime. Obviously this not a proof, but there is clearly no first order surprise in the observed offsets.

UPDATE I checked offsets modulo different numbers (such as (mod 2*3*5*7*11*13*17*...)) and I found that mod(3*7*11*19*23) we get 64638/25806 for +7/-7 and 21945/73899 for +5/-5, while primes 2, 5, 13, 17, 29 don't affect the ratio. I imagine that exploring more primes will further refine the ratios, with primes $\equiv 3$ (mod 4) affecting them and others not. WHAT IS GOING ON HERE?

| cite | improve this answer | |
  • 4
    $\begingroup$ I see now, thanks to Lucia's answer, that the ratios between the asymptotics there for, say, $k=\pm7$ are affected only by primes $p$ such that $$\Big(\frac{-7}{p}\Big)\neq \Big(\frac{7}{p}\Big)$$ which are the primes $\equiv 3$ (mod 4). $\endgroup$ – Yaakov Baruch Apr 27 '17 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.