PureOne's picture
Publish verified v5.0.0 research release
b6f1c7f verified
Raw History Blame Contribute Delete
3.11 kB
"""Figures from exact certificates and explicitly labeled formula evaluations."""
from pathlib import Path
import sys,csv,json,math
ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT))
import numpy as np
import matplotlib.pyplot as plt
from evefreq.quantization import numeric_minimum
def save(fig,name):
fig.tight_layout()
fig.savefig(ROOT/'figures'/f'{name}.pdf',bbox_inches='tight')
fig.savefig(ROOT/'figures'/f'{name}.png',dpi=160,bbox_inches='tight')
plt.close(fig)
qs=np.arange(2,81)
actual=np.array([numeric_minimum([[2],[3]],[1,1],int(q))['squared_distance'] for q in qs])
bound=8*np.sin(np.pi/qs)**2
fig,ax=plt.subplots(figsize=(6.5,3.8))
ax.plot(qs,actual/bound,label='Actual squared distance / support bound')
ax.axhline(1,linestyle='--',label='Support lower-bound threshold')
ax.scatter([2,3,6],[(actual/bound)[q-2] for q in [2,3,6]],marker='x',s=50,label='Small-alphabet failures')
ax.set(xlabel='Phase alphabet Q',ylabel='Ratio',title='Arithmetic aliasing and eventual geometric recovery')
ax.legend(fontsize=8);save(fig,'01_arithmetic_recovery')
qs=np.array([16,20,24,31,40,60,80,120,180,256])
actual=np.array([numeric_minimum([[2],[3]],[1,1],int(q))['squared_distance'] for q in qs])
rescaled=qs.astype(float)**4*(actual-4*np.pi**2*13/qs**2)
target=-4*np.pi**4*97/3
fig,ax=plt.subplots(figsize=(6.5,3.8))
ax.plot(qs,rescaled,marker='o',label='Complete finite-code enumeration')
ax.axhline(target,linestyle='--',label='Proved quartic asymptote')
ax.set(xlabel='Q',ylabel=r'$Q^4(D_Q^2-4\pi^2s/Q^2)$',title='The first extrinsic correction: harmonics (2, 3)')
ax.legend(fontsize=8);save(fig,'02_quartic_correction')
eps=np.logspace(-8,-1,80)
fig,ax=plt.subplots(figsize=(6.5,3.8))
ax.loglog(eps,np.sqrt(eps))
ax.set(xlabel=r'$\varepsilon$',ylabel='Distance ratio to the standard isometric circle',title='Identical intrinsic metric; arbitrary chordal-distance collapse')
ax.text(.04,.90,'Exact formula at Q = 28; not a noise experiment',transform=ax.transAxes,fontsize=8)
save(fig,'03_isometric_collapse')
qs=np.arange(2,601)
fig,ax=plt.subplots(figsize=(6.5,3.8))
ax.loglog(qs,2*np.sqrt(3)*np.sin(np.pi/qs),label='Exact theorem for every Q')
small=np.array([2,3,4,6]);ax.scatter(small,2*np.sqrt(3)*np.sin(np.pi/small),label='Exhaustively enumerated alphabets')
ax.set(xlabel='Q',ylabel='Minimum Euclidean distance',title='Beyond graph cuts: the cographic K5 arrangement')
ax.legend(fontsize=8);save(fig,'04_cographic_quantization')
counts={q:[0,0] for q in range(2,12)}
with (ROOT/'results/exact_atlas.csv').open() as f:
for r in csv.DictReader(f):counts[int(r['Q'])][int(r['safe'])]+=1
qs=list(counts);safe=[counts[q][1] for q in qs];unsafe=[counts[q][0] for q in qs]
fig,ax=plt.subplots(figsize=(6.5,3.8))
ax.bar(qs,safe,label='Safe for the support lower bound')
ax.bar(qs,unsafe,bottom=safe,label='Admits a constructive failure')
ax.set(xlabel='Q',ylabel='Primitive integer arrangements',title='Exact arithmetic atlas: 1,092 matrices per alphabet',xticks=qs)
ax.legend(fontsize=8);save(fig,'05_exact_atlas')
print('Saved five vector PDF figures and five PNG previews.')