From GRH to Goldbach: the spectral bridge
Verify the 2026 conditional proof GRH + S ⇒ Goldbach, settle its finite parts, and attack the hypothesis that is left

| 1 | #!/usr/bin/env python3 |
| 2 | """The Goldbach comet, docs/comet.svg: for every even N up to 60,000, r(N), the number of ways N = p + q with primes |
| 3 | p <= q. A dot's colour is the Hardy-Littlewood factor of N's odd primes, prod (p - 1)/(p - 2), from faint against the |
| 4 | background (1, a power of 2) to vivid (4 or more), in light colours or dark as the reader's system is. Its only words |
| 5 | are numbers and r(N), so README.md and README.zh.md each caption it. Standard library only: |
| 6 | |
| 7 | python3 scripts/comet.py > docs/comet.svg |
| 8 | """ |
| 9 | import math |
| 10 | |
| 11 | M, W, H = 60000, 720, 340 |
| 12 | L, R, T, B = 46, W - 8, 10, H - 26 |
| 13 | MARKS = (30030, 32768) |
| 14 | LIGHT = ('#7fb3c1', '#4f98aa', '#1f7187', '#03586f', '#0b3a47') |
| 15 | DARK = ('#2f6676', '#3f8a9d', '#62b0c2', '#93d2df', '#cdeef5') |
| 16 | BINS = 8 |
| 17 | |
| 18 | spf = list(range(M + 1)) # each number's smallest prime factor |
| 19 | for i in range(2, math.isqrt(M) + 1): |
| 20 | if spf[i] == i: |
| 21 | for j in range(i * i, M + 1, i): |
| 22 | if spf[j] == j: |
| 23 | spf[j] = i |
| 24 | primes = [p for p in range(2, M + 1) if spf[p] == p] |
| 25 | r = [0] * (M + 1) |
| 26 | for a, p in enumerate(primes): |
| 27 | for q in primes[a:]: |
| 28 | if p + q > M: |
| 29 | break |
| 30 | r[p + q] += 1 |
| 31 | |
| 32 | |
| 33 | def factor(n): |
| 34 | m = 1.0 |
| 35 | while n % 2 == 0: |
| 36 | n //= 2 |
| 37 | while n > 1: |
| 38 | p = spf[n] |
| 39 | m *= (p - 1) / (p - 2) |
| 40 | while n % p == 0: |
| 41 | n //= p |
| 42 | return m |
| 43 | |
| 44 | |
| 45 | def ramp(stops, t): |
| 46 | f = t * (len(stops) - 1) |
| 47 | i = min(len(stops) - 2, int(f)) |
| 48 | a, b = (tuple(int(s[k:k + 2], 16) for k in (1, 3, 5)) for s in (stops[i], stops[i + 1])) |
| 49 | return '#' + ''.join(f'{round(x + (y - x) * (f - i)):02x}' for x, y in zip(a, b)) |
| 50 | |
| 51 | |
| 52 | top = max(r[4::2]) |
| 53 | step = next((s for s in (100, 200, 250, 500, 1000, 2000, 5000) if top / s <= 5), 10000) |
| 54 | y_max = math.ceil(top / step) * step |
| 55 | X = lambda n: L + n / M * (R - L) |
| 56 | Y = lambda c: B - c / y_max * (B - T) |
| 57 | num = lambda x: f'{x:.1f}'.rstrip('0').rstrip('.') |
| 58 | |
| 59 | # One path a colour band, the palest first so the rarer, darker dots lie on top. A dot is a square cap on a pixel |
| 60 | # (a zero-length line), each pixel once, each a short move from the one before: some 110 KB for 30,000 N. |
| 61 | cells = [set() for _ in range(BINS)] |
| 62 | for n in range(4, M + 1, 2): |
| 63 | cells[min(BINS - 1, round((factor(n) - 1) / 3 * (BINS - 1)))].add((round(X(n)), round(Y(r[n])))) |
| 64 | bands = [] |
| 65 | for band in cells: |
| 66 | d, at = [], None |
| 67 | for x, y in sorted(band): |
| 68 | d.append(f'M{x} {y}h0' if at is None else f'm{x - at[0]}{"" if y < at[1] else " "}{y - at[1]}h0') |
| 69 | at = (x, y) |
| 70 | bands.append(d) |
| 71 | |
| 72 | css = ['.bg{fill:#fff}.grid{stroke:#ebedf0}.axis{stroke:#dadce0}.t{fill:#5f6368}.ink{fill:#1f1f1f}.ring{stroke:#1f1f1f}.halo{stroke:#fff}'] |
| 73 | css += [f'.b{b}{{stroke:{ramp(LIGHT, b / (BINS - 1))}}}' for b in range(BINS)] |
| 74 | dark = ['.bg{fill:#1f2023}.grid{stroke:#2e3033}.axis{stroke:#3c4043}.t{fill:#9aa0a6}.ink{fill:#e8eaed}.ring{stroke:#e8eaed}.halo{stroke:#1f2023}'] |
| 75 | dark += [f'.b{b}{{stroke:{ramp(DARK, b / (BINS - 1))}}}' for b in range(BINS)] |
| 76 | out = [f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {W} {H}" width="{W}" height="{H}" font-family="system-ui, -apple-system, \'Segoe UI\', sans-serif" font-size="12">', |
| 77 | '<title>The Goldbach comet: r(N) for every even N up to 60,000</title>', |
| 78 | f'<style>{"".join(css)}@media (prefers-color-scheme: dark){{{"".join(dark)}}}</style>', |
| 79 | f'<rect class="bg" width="{W}" height="{H}"/>'] |
| 80 | for c in range(0, y_max + 1, step): |
| 81 | y = round(Y(c)) + 0.5 |
| 82 | out.append(f'<path class="grid" d="M{L} {y}H{R}"/><text class="t" x="{L - 8}" y="{y + 4}" text-anchor="end">{c:,}</text>') |
| 83 | for n in range(0, M + 1, 10000): |
| 84 | out.append(f'<text class="t" x="{num(min(R - 18, X(n)))}" y="{B + 18}" text-anchor="middle">{n:,}</text>') |
| 85 | out.append(f'<path class="axis" d="M{L} {B + 0.5}H{R}"/><text class="t" x="{L + 6}" y="{T + 10}">r(N)</text>') |
| 86 | out += [f'<path class="b{b}" stroke-width="1.6" stroke-linecap="square" d="{"".join(d)}"/>' for b, d in enumerate(bands) if d] |
| 87 | for n in MARKS: # a ring, and N with its count beside it |
| 88 | x, y = X(n), Y(r[n]) |
| 89 | ly = y + 18 if y > T + (B - T) * 0.55 else y - 10 |
| 90 | out.append(f'<circle class="halo" cx="{num(x)}" cy="{num(y)}" r="5" fill="none" stroke-width="4"/><circle class="ring" cx="{num(x)}" cy="{num(y)}" r="5" fill="none" stroke-width="1.5"/>' |
| 91 | f'<text class="ink halo" x="{num(x + 10)}" y="{num(ly)}" font-weight="600" stroke-width="4" paint-order="stroke">{n:,} · {r[n]}</text>') |
| 92 | out.append('</svg>') |
| 93 | print('\n'.join(out)) |