import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation, PillowWriter
from matplotlib.patches import Circle, Rectangle
from pathlib import Path
import math
# Output paths
out_gif = Path("/mnt/data/prime_gap_1e18_virtual_polar_stack.gif")
out_png = Path("/mnt/data/prime_gap_1e18_virtual_polar_stack_final.png")
# Prime utilities
def primes_upto(n):
sieve = np.ones(n 1, dtype=bool)
sieve[:2] = False
for p in range(2, int(n**0.5) 1):
if sieve[p]:
sieve[p*p:n 1:p] = False
return np.nonzero(sieve)[0]
primes = primes_upto(10000)
gaps = np.diff(primes)
p_for_gap = primes[:-1]
n_gaps = len(gaps)
# Polar mapping: theta from prime position, radius from modular lane normalized gap
theta_base = 2*np.pi*(np.arange(n_gaps) / n_gaps)
lane = (p_for_gap % 30) / 30.0
r_base = 0.18 0.68*lane 0.16*(gaps / gaps.max())
# Virtual stack parameters
total_layers = 10**18
step_deg = 10
unique_positions = 360 // math.gcd(360, step_deg)
cycles = total_layers // unique_positions
remainder = total_layers % unique_positions
# Animation settings
frames = 72
fig = plt.figure(figsize=(14, 8), dpi=120)
fig.patch.set_facecolor("#020812")
def add_panel(ax):
ax.set_facecolor("#020812")
ax.set_xticks([])
ax.set_yticks([])
for spine in ax.spines.values():
spine.set_edgecolor("
#00e5ff")
spine.set_linewidth(1.0)
def polar_grid(ax, maxr=1.0, rings=12):
for rr in np.linspace(0.15, maxr, rings):
ax.plot(np.linspace(0, 2*np.pi, 720), np.full(720, rr), color="
#00c8ff", lw=0.35, alpha=0.45)
for a in np.linspace(0, 2*np.pi, 12, endpoint=False):
ax.plot([a, a], [0, maxr], color="
#00c8ff", lw=0.45, alpha=0.55)
# Create axes
axL = fig.add_axes([0.03, 0.24, 0.43, 0.66], projection="polar")
axR = fig.add_axes([0.54, 0.24, 0.43, 0.66], projection="polar")
axB = fig.add_axes([0.03, 0.04, 0.94, 0.17])
for ax in (axL, axR):
ax.set_facecolor("#020812")
ax.set_theta_zero_location("E")
ax.set_theta_direction(-1)
ax.set_ylim(0, 1.05)
ax.grid(False)
ax.set_xticks([])
ax.set_yticks([])
ax.spines["polar"].set_color("
#00e5ff")
ax.spines["polar"].set_linewidth(1.0)
axB.set_facecolor("#020812")
axB.set_xticks([])
axB.set_yticks([])
for s in axB.spines.values():
s.set_edgecolor("
#ffee00")
s.set_linewidth(1.0)
fig.text(0.5, 0.955, "POLAR PRIME-GAP TEST โ VIRTUAL STACK GIF", ha="center", color="white",
fontsize=15, family="monospace")
fig.text(0.5, 0.928, "same 0โ10,000 prime-gap data โ 1,000,000,000,000,000,000 polar circles",
ha="center", color="
#00ffff", fontsize=10, family="monospace")
fig.text(0.5, 0.902, "10ยฐ start-angle shift โ only 36 unique rotational phases; quintillion stack = repeated saturation",
ha="center", color="
#7CFF00", fontsize=10, family="monospace")
# Precompute 36 unique overlays for true phase stack
unique_offsets = np.deg2rad(np.arange(unique_positions) * step_deg)
def draw_frame(i):
axL.clear(); axR.clear(); axB.clear()
for ax in (axL, axR):
ax.set_facecolor("#020812")
ax.set_theta_zero_location("E")
ax.set_theta_direction(-1)
ax.set_ylim(0, 1.05)
ax.grid(False)
ax.set_xticks([])
ax.set_yticks([])
ax.spines["polar"].set_color("
#00e5ff")
ax.spines["polar"].set_linewidth(1.0)
polar_grid(ax, rings=14)
axB.set_facecolor("#020812")
axB.set_xticks([]); axB.set_yticks([])
for s in axB.spines.values():
s.set_edgecolor("
#ffee00"); s.set_linewidth(1.0)
phase_count = 1 int((i / (frames - 1)) * (unique_positions - 1))
spin = np.deg2rad(i * 5)
# Left: cumulative 36-phase interference field
for j, off in enumerate(unique_offsets[:phase_count]):
th = theta_base off spin * 0.15
alpha = 0.035 if phase_count > 8 else 0.08
color =
plt.cm.hsv((j / unique_positions) % 1)
axL.plot(th, r_base, lw=0.30, alpha=alpha, color=color)
# anomaly/gap spikes
mask = gaps >= np.percentile(gaps, 93)
axL.scatter(th[mask], r_base[mask], s=1.0, alpha=min(0.6, alpha*8), color=color)
axL.scatter([0], [0], s=16, color="black", zorder=5)
axL.text(0.02, 0.98, f"INTERFERENCE FIELD | phases drawn {phase_count}/36",
transform=axL.transAxes, ha="left", va="top", color="white", fontsize=8, family="monospace")
axL.text(0.02, 0.03, "1e18 virtual layers collapse onto 36 angle states",
transform=axL.transAxes, ha="left", va="bottom", color="
#00ffff", fontsize=8, family="monospace")
# Right: clean active scan layer plus ghost ring
active_phase = (i % unique_positions) * step_deg
th_active = theta_base np.deg2rad(active_phase) spin
axR.plot(th_active, r_base, color="
#ff00ff", lw=0.75, alpha=0.9)
axR.scatter(th_active, r_base, s=3, color="
#ff00ff", alpha=0.8)
mask = gaps >= np.percentile(gaps, 95)
axR.scatter(th_active[mask], r_base[mask], s=10, facecolors="none", edgecolors="
#00ffff", lw=0.7)
# memory haze
for off in unique_offsets:
axR.plot(theta_base off, r_base*0.99, color="
#00c8ff", lw=0.18, alpha=0.035)
axR.add_patch(Circle((0,0), 0.22, transform=axR.transData._b, color="#020812", zorder=3))
axR.text(0.5, 0.5, "PRIME\nGAP", transform=axR.transAxes, ha="center", va="center",
color="white", fontsize=12, family="monospace")
axR.text(0.02, 0.98, f"CLEAN POLAR SCAN | active offset {active_phase:03d}ยฐ",
transform=axR.transAxes, ha="left", va="top", color="white", fontsize=8, family="monospace")
axR.text(0.5, 0.39, "mod 6 / mod 12 / mod 30 rings", transform=axR.transAxes,
ha="center", color="white", fontsize=8, alpha=0.75, family="monospace")
# Bottom data panel
axB.set_xlim(0, 1); axB.set_ylim(0, 1)
axB.text(0.02, 0.78, "READ THIS", color="
#ffee00", fontsize=10, family="monospace")
axB.text(0.02, 0.48, f"range: 0โ10,000\nprimes: {len(primes):,}\ngaps: {len(gaps):,}\navg gap: {gaps.mean():.2f}\nmax gap: {gaps.max()}",
color="white", fontsize=8, family="monospace", va="top")
axB.text(0.27, 0.78, "QUINTILLION STACK MATH", color="
#00ffff", fontsize=10, family="monospace")
axB.text(0.27, 0.50,
f"total layers: {total_layers:,}\n10ยฐ step โ 36 unique phases\nfull cycles: {cycles:,}\nremainder layers: {remainder}\nvisual result: saturation, not new geometry",
color="white", fontsize=8, family="monospace", va="top")
axB.text(0.56, 0.78, "FRAME STATUS", color="
#ff00ff", fontsize=10, family="monospace")
axB.text(0.56, 0.50,
f"gif frame: {i 1}/{frames}\nactive scan angle: {active_phase}ยฐ\nphases visible: {phase_count}/36\npoints per scan: {n_gaps:,}",
color="white", fontsize=8, family="monospace", va="top")
axB.text(0.78, 0.78, "RESULT", color="
#7CFF00", fontsize=10, family="monospace")
axB.text(0.78, 0.50,
"same prime-gap rhythm\nrotated through finite phase states\npatterns reinforce/cancel\nmod-30 lanes remain visible",
color="white", fontsize=8, family="monospace", va="top")
axB.text(0.5, 0.05, "1,000,000,000,000,000,000 requested layers rendered as mathematically equivalent virtual phase stack",
ha="center", color="
#ffee00", fontsize=8, family="monospace")
return []
anim = FuncAnimation(fig, draw_frame, frames=frames, interval=80, blit=False)
anim.save(out_gif, writer=PillowWriter(fps=12))
draw_frame(frames-1)
fig.savefig(out_png, dpi=160, facecolor=fig.get_facecolor())
plt.close(fig)
str(out_gif), str(out_png)