program_check.py

back to table · edit · history · where entries came from · files · download

1160 bytes, as of the version from 2026-11-27 09:27 (current). Recorded here, not run.

import numberdb.sage as numberdb
from sage.rings.real_arb import RealBallField
from sage.rings.complex_arb import ComplexBallField
from sage.rings.integer import Integer
R, C = RealBallField(512), ComplexBallField(512)
def hyperball_density(cell, p):
    q, r, first = {"tetrahedron": (3,3,7), "cube": (3,4,7),
                   "octahedron": (4,3,5)}[cell]
    if not isinstance(p, (int, Integer)) or p < first:
        raise ValueError("p must be an integer in the tiling domain")
    pi = R.pi()
    a, b, g = pi/p, pi/q, pi/r
    c = (2*a).cos()
    D = {"tetrahedron": c/(2*c-1), "cube": 1/(2*c-1),
         "octahedron": (1+c)/(2*c)}[cell]
    h = D.arccosh()/2
    t = ((b.cos()**2-a.sin()**2*g.sin()**2).sqrt()
         /(a.cos()*g.cos())).arctan()
    def L(x):
        return (C(0,2)*C(x)).exp().polylog(2).imag()/2
    v = (L(a+t)-L(a-t)+L(pi/2+b-t)+L(pi/2-b-t)
         +L(g+t)-L(g-t)+2*L(pi/2-t))/4
    return (pi/2-a-b)*((2*h).sinh()+2*h)/(4*v)
hyperball_density("cube", 7)
d=hyperball_density("cube",7)
assert d.is_finite() and 0 < d < 1
assert (d-R("0.68839367")).abs() < R("1e-8")
print("Displayed Sage program: cube order 7 control passed")