files / problems / landau-n2-plus-1 / WALKTHROUGH.md

11 KB · on GitHub

Walkthrough — Landau 4, certified prefix and Iwaniec P2s

0. What was actually missing

Infinitude is the headline and is out of reach. What was missing on disk was a prefix one can replay without trusting OEIS, together with the nearby object Iwaniec actually proved — n2+1n^2+1 with at most two prime factors, counted with multiplicity — and a comparison of the prime count to the Landau–Shanks / Bateman–Horn main term.

A new prime not on the published list we cite would have been a construction. That list is complete through m2+1<6.25×1028m^2+1<6.25\times 10^{28}. We did not beat it. The missing finite object was a replayable census past N=106N=10^6 that hits the next Wolf πq(10k)\pi_q(10^k) rows, together with the Ω=2\Omega=2 list on the same range. The N=108N=10^8 extension hits πq(1016)\pi_q(10^{16}).

1. False starts

Hilbert 16 / Smale 13 and Smale 7 were the other computational reads. Both need a heavier pipeline than a primality sieve. Landau 3 is already checked through 2642^{64}. See notes/ideation-historical.md.

The first sieve on this folder had three specific defects.

2. The useful failure

The ω\omega mistake has a one-line witness:

182+1=325=52⋅13,ω(325)=2,Ω(325)=3.18^2+1=325=5^2\cdot 13,\qquad \omega(325)=2,\qquad \Omega(325)=3.

So 18 is not an Iwaniec P2P_2. Replaying the first sieve's predicate at N=200000N=200000 reproduced the 34507 exactly; the Ω=2\Omega=2 count on the same range is 31953. The 2554-term gap is the 325325 class. A failed or mislabelled search with a verifier is the product. The 34507 was not a bound and is not one now.

The leftover analysis is what the dead end taught. Trial division of every n2+1n^2+1 up to n2+1≈n\sqrt{n^2+1}\approx n is O(N2/log⁡N)O(N^2/\log N) and dies at N=106N=10^6. The right remainder is not “try harder trial division”. It is that after every prime q≡1(mod4)q\equiv 1\pmod 4 with q≤Nq\le N has been divided out, a leftover larger than 1 has all prime factors >N>N, and n2+1≤N2+1<N3n^2+1\le N^2+1<N^3 cannot be a product of three such primes.

3. The click

Only even nn, and n=1n=1, can make n2+1n^2+1 prime. For each prime q≡1(mod4)q\equiv 1\pmod 4 there is a square root of −1 mod q-1\bmod q, and qq divides n2+1n^2+1 exactly on the two progressions n≡±r(modq)n\equiv\pm r\pmod q. Sieving those progressions, and dividing out full powers, classifies Ω(n2+1)\Omega(n^2+1) for every even n≤Nn\le N. Leftover composites are split by Pollard rho only to write the two prime factors down.

That is a finite classification, not a proof that the Ω=1\Omega=1 column is unbounded.

4. The argument, in the order it was found

Local constraints

Odd n>1n>1 make n2+1n^2+1 even and greater than 2. A prime divisor of n2+1n^2+1 is 2 or ≡1(mod4)\equiv 1\pmod 4. The equation n2+1=p2n^2+1=p^2 is the Pell equation p2−n2=1p^2-n^2=1 and has no solution for n≥1n\ge 1. Therefore an Iwaniec P2P_2 is either prime or a product of two distinct primes.

Complete classification by a residue sieve

Write rr for a square root of −1-1 modulo q=1(mod4)q=1\pmod 4. After removing every such q≤Nq\le N from n2+1n^2+1, the leftover LL satisfies:

Miller–Rabin on LL, with a deterministic 64-bit witness set, separates the last two cases. Pollard rho is used only when LL is composite, to name the two factors.

What is compared, and what is not claimed

Hardy–Littlewood / Bateman–Horn / Landau–Shanks predict

#{n≤N:n2+1 prime}∼Cq∫2Ndtlog⁡(t2+1),\#\{n\le N:n^2+1\text{ prime}\} \sim C_q\int_2^N\frac{dt}{\log(t^2+1)},

with Cq=1.372813462818246…C_q=1.372813462818246\ldots (OEIS A199401; Wolf's CqC_q). A match is a check of the implementation against a conjecture, not a proof of the conjecture and not a proof of infinitude.

Iwaniec's theorem supplies the comparison shape N/(log⁡N)3/2N/(\log N)^{3/2} for the P2P_2 count. The ratio of our P2P_2 count to that shape is a descriptive diagnostic. It is not a new lower bound.

The published record we did not beat

Wolf, arXiv:0803.1456, tabulated πq(10k)\pi_q(10^k) through k=20k=20. OEIS A083844 continues that column through k=28k=28. Grantham–Graves, arXiv:2502.03513, computed every prime m2+1≤6.25×1028m^2+1\le 6.25\times 10^{28}. A construction tonight would have been a prime with nn beyond that range. The N=108N=10^8 census matches Wolf through 101610^{16} instead.

Replay the N=106N=10^6 prefix from the problem folder:

python3 compute/sieve_n2p1.py --self-test
python3 compute/sieve_n2p1.py --n-max 1000000
python3 compute/verify.py
python3 compute/plot_counts.py

Replay the N=107N=10^7 extension from compute/q2/:

compute/q2/run_all.sh

Replay the N=108N=10^8 extension from compute/q3/ (regenerates the gitignored lists):

compute/q3/run_all.sh

The sieve writes compute/prime_n.txt (54110 values of nn) and compute/p2_omega2.txt (147612 rows n p q with n2+1=pqn^2+1=pq). compute/n2p1.json holds the counts, the Wolf rows, the Bateman–Horn integral, and SHA-256 of the two lists. The verifier ignores the stored prime list, re-tests every even nn and n=1n=1 by Miller–Rabin, multiplies every claimed P2P_2 factorization back, and factors every even n2+1n^2+1 by an independent trial-plus-Pollard pass.

At N=106N=10^6:

object count
nn with n2+1n^2+1 prime 54110
Ω(n2+1)=2\Omega(n^2+1)=2 147612
Iwaniec P2P_2 (union) 201722
ω≤2\omega\le 2 composites (wrong predicate) 158367

At N=107N=10^7, from compute/q2/ (C residue sieve, 15 s, 56 MB RSS; independent C trial-plus-Pollard verifier, 53 s; verify.py, 885 s):

object count
nn with n2+1n^2+1 prime 456362
Ω(n2+1)=2\Omega(n^2+1)=2 1334083
Iwaniec P2P_2 (union) 1790445
ω≤2\omega\le 2 composites (wrong predicate) 1421501

The Ω\Omega histogram on the 5000001 live nn at N=107N=10^7 is a partition: 1:4563621{:}456362, 2:13340832{:}1334083, 3:15906473{:}1590647, 4:10414934{:}1041493, 5:4256515{:}425651, 6:1205486{:}120548, 7:255857{:}25585, 8:47248{:}4724, 9:7479{:}747, 10:13910{:}139, 11:1811{:}18, 12:412{:}4. The N=106N=10^6 prefix of both lists is the committed N=106N=10^6 pair.

At N=108N=10^8, from compute/q3/ (segmented C residue sieve, 147 s, 93 MB RSS; independent C trial-plus-Pollard verifier, 742 s; streaming Python multiply-back plus Wolf/OEIS):

object count
nn with n2+1n^2+1 prime 3954181
Ω(n2+1)=2\Omega(n^2+1)=2 12172983
Iwaniec P2P_2 (union) 16127164
ω≤2\omega\le 2 composites (wrong predicate) 12914417

The Ω\Omega histogram on the 50000001 live nn at N=108N=10^8 is a partition: 1:39541811{:}3954181, 2:121729832{:}12172983, 3:155625373{:}15562537, 4:111401744{:}11140174, 5:50818185{:}5081818, 6:16100826{:}1610082, 7:3860997{:}386099, 8:759968{:}75996, 9:133529{:}13352, 10:234610{:}2346, 11:35511{:}355, 12:6412{:}64, 13:1413{:}14. The N=107N=10^7 prefix of both lists is the certified q2 pair. The lists themselves are regenerable and gitignored; counts and SHA-256 live in compute/q3/n2p1.json.

The Ω\Omega histogram on the 500001 live nn is a partition: 1:541101{:}54110, 2:1476122{:}147612, 3:1610653{:}161065, 4:940194{:}94019, 5:332095{:}33209, 6:81516{:}8151, 7:15417{:}1541, 8:2428{:}242, 9:449{:}44, 10:810{:}8.

Wolf / A083844, recomputed from our list as #{n:n2+1<10k}\#\{n:n^2+1<10^k\}:

10k10^k ours Wolf
10610^6 112 112
10710^7 316 316
10810^8 841 841
10910^9 2378 2378
101010^{10} 6656 6656
101110^{11} 18822 18822
101210^{12} 54110 54110
101310^{13} 156081 156081
101410^{14} 456362 456362
101510^{15} 1339875 1339875
101610^{16} 3954181 3954181

The first 10000 terms of prime_n.txt are the OEIS A005574 b-file; the 10000th nn is 158704. First primes 2,5,17,37,101,197,257,401,577,6772,5,17,37,101,197,257,401,577,677 match A002496. First Iwaniec composites: 82+1=5⋅138^2+1=5\cdot 13, 122+1=5⋅2912^2+1=5\cdot 29. The integer 18 is absent from p2_omega2.txt.

Bateman–Horn at selected NN, from compute/comparison.json:

NN primes Cq∫C_q\int ratio
10310^3 112 121.09 0.9249
10410^4 841 854.54 0.9842
10510^5 6656 6609.15 1.0071
2⋅1052\cdot 10^5 12391 12379.26 1.0009
5⋅1055\cdot 10^5 28563 28558.07 1.0002
10610^6 54110 53969.85 1.0026
2⋅1062\cdot 10^6 102205 102312.04 0.9990
5⋅1065\cdot 10^6 239185 239309.07 0.9995
10710^7 456362 456409.53 0.9999
2⋅1072\cdot 10^7 872121 872370.61 0.9997
5⋅1075\cdot 10^7 2059567 2060327.13 0.9996
10810^8 3954181 3955300.85 0.9997

The Wolf-li form at N=106N=10^6 is 53970.55. OEIS A331942 predicts 53970. A truncated Euler product for CqC_q through 2⋅1062\cdot 10^6 recovers 1.37281051 against the published 1.37281346.

Certified prime counts against the Bateman–Horn integral, the ratio to that integral, and the Iwaniec P_2 count over N/(\log N)^{3/2}

SHA-256 of the committed N=106N=10^6 lists (also in compute/n2p1.json):

SHA-256 of the N=107N=10^7 lists in compute/q2/ (also in compute/q2/n2p1.json):

SHA-256 of the N=108N=10^8 lists regenerated in compute/q3/ (also in compute/q3/n2p1.json):

The six-prime Miller–Rabin set without 17 only covers n2+1<3.474×1012n^2+1<3.474\times 10^{12} (OEIS A014233). That is enough for N=106N=10^6 and not enough for N=107N=10^7. The working bases are now 2,3,5,7,11,13,17,19,232,3,5,7,11,13,17,19,23, which cover 3.825×10183.825\times 10^{18}.

6. Proven vs still open

Proven here, as a finite computation: there are exactly 54110 integers nn with 1≤n≤1061\le n\le 10^6 and n2+1n^2+1 prime, and exactly 147612 further nn in that range with Ω(n2+1)=2\Omega(n^2+1)=2. Extending the same classification, there are exactly 456362 such primes with n≤107n\le 10^7 and exactly 1334083 further nn in that range with Ω(n2+1)=2\Omega(n^2+1)=2, and exactly 3954181 such primes with n≤108n\le 10^8 and exactly 12172983 further nn in that range with Ω(n2+1)=2\Omega(n^2+1)=2. The N=108N=10^8 counts sit in compute/q3/n2p1.json and are re-derived by the C trial-plus-Pollard verifier. The prime count equals Wolf's πq(1016)\pi_q(10^{16}). The count tracks the Bateman–Horn main term to a few parts in 10410^4. None of that is a lower bound on the number of such primes for all NN, and none of it is infinitude.

Still open: Landau 4.

Not claimed: a new prime off the Wolf / Grantham lists; an improvement of Iwaniec's exponent; anything about 2026 preprints. The Goldbach other-other check on this prefix (every a>1a>1 in the list is b+cb+c with both still in the list; largest j(m)=38j(m)=38 at a=1174484a=1174484) is a consistency check, not a bound: Grantham–Graves already ran it to 6.25×10286.25\times 10^{28}.