Datasets:
Languages:
English
Size:
< 1K
ArXiv:
Tags:
nanofabrication
photochemistry
photonics
mathematical-physics
optimal-control
reaction-diffusion
File size: 2,705 Bytes
d980d12 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #!/usr/bin/env python3
"""Separate implementations; deliberately does not import model.py.
Exact Fraction matrices and high-precision evaluations provide finite audit
coverage. High-precision arithmetic is not presented as an interval proof.
"""
from fractions import Fraction as F
from pathlib import Path
import json
import random
import mpmath as mp
ROOT=Path(__file__).resolve().parents[1]
random.seed(19311020)
checks=[]
def chk(name, ok):
checks.append({'name':name,'passed':bool(ok)})
if not ok: raise AssertionError(name)
def mv(matrix,vector):
return [sum((a*b for a,b in zip(row,vector)),F(0)) for row in matrix]
def eye():
return [[F(int(i==j)) for j in range(4)] for i in range(4)]
filter_matrix=[[F(0),F(1),F(0),F(0)],
[F(0),F(0),F(0),F(0)],
[F(1),F(0),F(1),F(0)],
[F(0),F(0),F(0),F(1)]]
for case in range(80):
state=[F(1),F(0),F(0),F(0)]
remaining=F(1)
for block in range(random.randrange(1,7)):
survive=F(1)
for j in range(random.randrange(1,12)):
p=F(random.randrange(1,13),13)
mm=eye(); mm[0][0]=1-p; mm[1][0]=p
state=mv(filter_matrix,mv(mm,state))
survive*=p
b=F(random.randrange(1,17),17)
commit=[[1-b,F(1),F(1),F(0)],
[F(0),F(0),F(0),F(0)],
[F(0),F(0),F(0),F(0)],
[b,F(0),F(0),F(1)]]
state=mv(commit,state)
remaining*=1-b*survive
chk(f'exact_multibatch_matrices_{case}',
state==[remaining,F(0),F(0),1-remaining] and sum(state)==1)
mp.mp.dps=70
data=json.loads((ROOT/'results'/'verification.json').read_text())
for row in data['dose_table']:
if row['m'] not in [3,4,8,16,64,256]: continue
m=row['m']; u=mp.mpf(str(row['action']))
value=mp.fprod(1-mp.exp(-u*(1-mp.cos(mp.pi*(2*j-1)/m))) for j in range(m))
chk(f'independent_70digit_midpoint_{m}_{row["q"]}',abs(value-mp.mpf(str(row['q'])))<mp.mpf('2e-12'))
for q_string,c in data['cubic_constants'].items():
c=mp.mpf(str(c))
value=mp.fprod((1-mp.exp(-c*mp.pi**2*(2*r+1)**2/2))**2 for r in range(100))
chk(f'independent_70digit_limit_{q_string}',abs(value-mp.mpf(q_string))<mp.mpf('1e-13'))
out={'project':'EVE / ELYRION III','imports_main_implementation':False,
'tests_passed':sum(x['passed'] for x in checks),'tests_total':len(checks),
'mpmath_decimal_digits':mp.mp.dps,
'status':'Exact rational and high-precision finite audit; not external review or interval proof.',
'tests':checks}
(ROOT/'results'/'independent_audit.json').write_text(json.dumps(out,indent=2))
print(f'Independent audit: {out["tests_passed"]}/{out["tests_total"]} checks passed')
|