Every number is a middle

Goldbach's conjecture, seen from the middle, with an interactive explorer

How this started

In August 2024, I think it was after watching the movie “The Man Who Knew Infinity”, I found myself awake at 4 a.m. thinking about Goldbach’s conjecture (the last time this happened was when I read “Uncle Petros and Goldbach’s Conjecture” decades ago). This conjecture is an amazing math puzzle that is so simple to describe and yet so impossible to prove.

To be clear, I wasn’t hallucinating a proof here. I was merely thinking about primes and their properties, when I realized that if the conjecture is correct, then every integer greater than 1 is “enclosed” (or “defined”, if you prefer) between two primes.

My “breakthrough” idea was that if every even number is a sum of two primes (that’s the conjecture), then half of that number sits right in the middle of the two primes. And since every integer’s double is an even number, every integer greater than 1 is enclosed between two primes. In other words, if we had built our math defining only prime numbers (giving symbols only to primes, let’s say), then all other integers would be defined as the middle of one or more pairs of those primes. Not some of the integers, all of them.

Then I thought that, given an integer, you can imagine expanding around it until you hit the first of those prime pairs, like a bubble that expands around the given integer. And I thought a visualization of that concept might reveal some patterns. For example, going back from a given integer and giving an index to every prime before it, how far in the index would one have to go to reach a prime that “defines” that integer (together, obviously, with the symmetric prime on the other side)? If we were to plot those index numbers for lots of integers, would a pattern reveal itself? If there was a pattern, it might allow us to “predict” prime numbers by simply “reflecting” a known smaller prime to the other side of the integer it defines.

It was 4 a.m. at that point, and in order to get some sleep, I sent myself an email, hoping I would pick it up some other day and write a program to visualize it.

Two years passed and the AI boom happened. Reading about AI solving the Riemann hypothesis got me thinking about the above concept again. Getting this plot should be a one-shot prompt now, right? And indeed it was. I asked Claude whether this concept had already been researched and, as I expected, it had. I asked it to create a mini-page to demonstrate the concept in an interactive way. It explained the research that has been done around this concept and also built the page below.

Before I let you explore this on your own, here is why I wrote this. Personally, not being a genius, I don’t hope to solve any hard math or physics problems. So for me and many other average people in this world, AI doesn’t pose a threat. It’s an opportunity to learn and understand concepts that were out of reach until now, either because good teachers are hard to find or because the concepts are really hard to grasp. In any case, AI can help us understand those concepts and explore deeper, speeding up our experimentation, visualization and iterations.

I think it’s time for me to pick up some of the subjects I studied at university that I never really got a grasp of. In the meantime, knock yourselves out:

Disclaimer: I haven’t checked the correctness of every part of Claude’s answer and of the explanations below it. The sources are linked throughout the post and listed at the end, so you can check them yourself.


Claude’s answer

Yes, this has been explored. “Every integer greater than 1 is the average of two primes” is a known way to restate Goldbach’s conjecture. The smallest bubble around a number n, meaning the smallest distance r for which n − r and n + r are both prime, has its own entry in the On-Line Encyclopedia of Integer Sequences, A047160. Several close relatives have entries too, and they are listed at the end of this post. The backward index does not seem to have an entry of its own, but it follows directly from that distance, because it counts the primes between n − r and n. A plot should show a statistical pattern, with bands that depend on whether 3 divides n, but no exact rule that would predict a prime. The explorer below lets you check that for yourself.

Try it

Pick a number n. The dashed arcs are the radii that fail, tried in order. The first arc that lands on a prime at both ends is highlighted.

n =

From sums to midpoints

Here are all the ways to split 20 into two whole numbers. The highlighted pairs are the ones where both numbers are prime:

“20 is a sum of two primes” says the same thing as “there are two primes at equal distance from 10”. Since every whole number n is the midpoint of 2n, the conjecture can be stated without sums:

For every whole number n ≥ 2 there is an r ≥ 0 with n − r and n + r both prime.

Equivalently, every whole number from 2 on is the average of two primes. This reformulation is well known. It is the reason A047160 defines its terms with the clause “or −1 if no such m exists”: a single −1 anywhere in it would be a counterexample to Goldbach.

These are all the pairs of primes around the n in the explorer above:

The smallest circle

For each n, call r(n) the radius of the smallest circle that lands on two primes. That is the smallest r for which n − r and n + r are both prime. For n = 2, 3, 4, … the first values are

0, 0, 1, 0, 1, 0, 3, 2, 3, 0, 1, 0, 3, 2, 3, …

That is A047160. The zeros are the primes themselves, since a prime p is the middle of p and p. If you require two different primes, so r ≥ 1, you get A082467:

n = 4, 5, 6, …:  1, 2, 1, 4, 3, 2, 3, 6, 1, 6, 3, 2, 3, 6, 1, …

The explorer and the graphs use this second version by default, because it matches the backward walk below, which only looks at primes strictly below n. Tick “allow radius 0” to switch to the first version. The r ≥ 1 version holding for every n ≥ 4 is a slightly stronger claim than Goldbach: every even number greater than 6 is the sum of two different primes. It is also believed to be true and has been checked just as far, but it is not proven either.

Walking backwards

The same search can be done by walking down from n through the primes below it and numbering them. The nearest prime below n gets index 1, the next one index 2, and so on. For each prime p you check its mirror image 2n − p on the other side. The first prime whose mirror is also prime is the one that “defines” n, and its position in the walk is the index k(n). When a mirror is not prime, the chip shows its smallest factor.

The walk passes every prime between n − r and n, so the index counts primes. With π(x) for the number of primes up to x:

k(n) = π(n − 1) − π(n − r(n) − 1)

Near n, primes are about ln n apart on average, so k(n) is roughly r(n) / ln n.

A closely related quantity runs the scan in the opposite direction. The minimal Goldbach partition of 2n starts from the outside, at 3, 5, 7, …, and stops at the first prime p for which 2n − p is prime (A020481). The walk from the middle finds the closest pair of primes and the scan from the outside finds the widest one. Tomás Oliveira e Silva, Siegfried Herzog and Silvio Pardi recorded the minimal partition for every even number up to 4 × 1018 while verifying the conjecture. The largest smallest prime they met was 9781, needed for 3,325,581,707,333,960,528.

The graph

Each dot is one n. Its height is the radius, the index, or the radius divided by (ln n)2. Dots are colored by the small odd primes that divide n, which turns out to matter a lot. Everything is computed in your browser when you change a setting. Hover to read a value, and click a dot to load that n into the explorer.

n up to
Record radii in this range

Each row is an n whose radius is larger than that of every smaller n.

nradius rpairindex kr / (ln n)²

Reading the graph

The radius grows slowly

The radius does grow, but so slowly that the scatter plot hides it. The x axis is linear, so most of the dots sit in the right part of the range, where (ln n)2 barely changes. Between n = 500,000 and 1,000,000 it only goes from 172 to 191. Averaging the radius over ranges of n makes the growth visible:

range of n mean r largest r mean r / (ln n)²
100 to 200 11.3 42 0.45
1,000 to 2,000 26.6 168 0.50
10,000 to 20,000 46.9 486 0.51
100,000 to 200,000 73.2 1,086 0.52
500,000 to 1,000,000 96.1 1,515 0.53

The mean radius grows about nine times over this span, while the mean of r / (ln n)2 stays close to 0.5. The heuristic behind this comes from G. H. Hardy and J. E. Littlewood (1923). The number of ways to write an even number 2n as a sum of two primes is expected to be roughly

G(2n) ≈ 2Π₂ · ∏p | n, p odd (p − 1)/(p − 2) · 2n / (ln 2n)²

Here Π₂ ≈ 0.6602 is the twin prime constant, and the product runs over the odd primes that divide n. The pairs are spread over about n possible radii, so a typical gap between radii that work is around (ln n)2, and the smallest working radius is of that size too. The statistics under the graph put the two numbers side by side: the mean radius and (ln N)2 for the largest n in range.

The bands come from divisibility by 3, 5, 7, …

The colored layers in the graph come from the product term in that formula. Suppose 3 does not divide n. Then for any radius that is not a multiple of 3, one of n − r and n + r is a multiple of 3. For example, with n = 10 and r = 1 you get 9 and 11. So only one radius in three can work. When 3 divides n, the two ends are either both multiples of 3 or neither is, so two radii in three can work. That doubles the chances, which is the factor (3 − 1)/(3 − 2) = 2. The same reasoning gives 4/3 for 5 and 6/5 for 7.

The index looks like a waiting time

Here is how often each index value occurs in the range selected in the graph above:

This is the shape you get from flipping a biased coin and counting the flips until the first heads. Each prime you pass on the walk down has a mirror that is prime with a probability of roughly c / ln n, where c depends on the small prime factors of n. The checks behave close to independently, so the index follows a geometric distribution, the dashed line. Its mean grows slowly with n, in proportion to ln n.

Could the index hand us a prime for free?

The hope in the original email was a shortcut. If k(n) followed a rule, you could compute it for any n, take the k-th prime below n, reflect it through n, and get a prime above n without searching.

The graphs show a statistical regularity: the index is usually small, it is smaller when 3 divides n, and its spread follows the geometric curve. They show no rule that gives the exact value. Index 1 is the most common, but at a million it holds for only about one n in seven, and values above 100 appear. A rule that always returned the right k would be a formula that produces primes on demand. Mathematicians have searched for such formulas for centuries, and the coin-flip behavior above is what the heuristics predict instead.

A rule would also not save any work. To trust the reflected number you would still have to test it for primality, and that test is the expensive step of any prime search. Finding some prime above n is already easy. Bertrand’s postulate, proved by Chebyshev in 1852, guarantees a prime between n and 2n. In practice, testing n + 1, n + 2, … with a fast primality test reaches a prime after about ln n tries.

The picture of the integers as midpoints of primes still holds up. The circles around each n stay small, roughly the size of (ln n)2, and they shrink when n has small odd factors. Proving that the smallest circle always exists is Goldbach’s conjecture itself.

Further reading

  1. OEIS A047160: for n ≥ 2, the smallest m ≥ 0 such that n − m and n + m are both primes. This is the radius r(n) with radius 0 allowed.
  2. OEIS A082467: the least k > 0 such that n − k and n + k are both primes. This is the radius used by default in this post.
  3. OEIS A020481: the least prime p with p + q = 2n and q prime, the minimal Goldbach partition.
  4. OEIS A002375, A045917 and A002372: the number of ways to write 2n as a sum of two primes, counted in slightly different ways. Plotted, these give the Goldbach comet.
  5. T. Oliveira e Silva, S. Herzog and S. Pardi, “Empirical verification of the even Goldbach conjecture and computation of prime gaps up to 4·1018”, Mathematics of Computation 83 (2014), 2033–2060. The project page, with the table of the largest minimal partitions, is at sweet.ua.pt/tos/goldbach.html.
  6. G. H. Hardy and J. E. Littlewood, “Some problems of ‘Partitio numerorum’; III: On the expression of a number as a sum of primes”, Acta Mathematica 44 (1923), 1–70. This is the source of the heuristic formula above.
  7. Wikipedia: Goldbach’s conjecture and Bertrand’s postulate.

All numbers in this post are computed live in your browser, with a sieve of Eratosthenes up to 2,000,000.

Short CV
Studies
Applied Mathematics and Physics
Work
Spectro Cloud, SUSE, testributor.com, incrediblue.com, skroutz.gr
Languages/Technologies
Golang, Ruby, Kubernetes, Containers, Linux
Toolset
Linux, Sway WM, Vim
Passions and Interests
Family, Programming, Running, Sea, Music, Motorcycles
Read the full CV