generate.py

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

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

"""T822: Volumes of regular truncated hyperbolic tetrahedra, cubes and octahedra.

Install SageMath, then install the client and run:
    sage -pip install numberdb
    sage -python generate.py             # verify all stored entries
    sage -python generate.py --publish   # add computed entries to this table
The latter fills an authorized draft; it does not offer or publish it.

Kellerhals' formula: Szirmai arXiv:1803.04948v1, Theorem 2.2;
arXiv:1405.0248v2, Theorem 4.2. Ordered chamber [p,q,r], outer A3
polar-truncated, curvature -1. Symbolic keys are permanent identities.
All transcendental operations enclose the exact inputs in Arb balls.
Working precision is at least 512 bits, or digits converted to bits plus
160 guard bits for extensions. Both normalizations are returned as balls.
The attached check program uses a separately regularized Schlaefli integral.
"""
import os
import numberdb.sage as numberdb
from sage.rings.real_arb import RealBallField
from sage.rings.complex_arb import ComplexBallField

FAMILIES = {'tetrahedron': (3, 3, 24, 7), 'cube': (3, 4, 48, 7),
            'octahedron': (4, 3, 48, 5)}

def chamber_volume(cell, p, digits=100):
    q, r, M, minimum = FAMILIES[cell]
    if int(p) != p or p < minimum:
        raise ValueError('p is outside the natural integer domain')
    precision = max(512, numberdb.bits(digits, losing=160))
    R = RealBallField(precision)
    C = ComplexBallField(precision)
    pi = R.pi()
    a, b, g = pi/p, pi/q, pi/r
    radicand = b.cos()**2-a.sin()**2*g.sin()**2
    assert radicand > 0
    theta = (radicand.sqrt()/(a.cos()*g.cos())).arctan()
    assert 0 < theta < pi/2
    def lob(x):
        return (C(0, 2)*C(x)).exp().polylog(2).imag()/2
    v = (lob(a+theta)-lob(a-theta)+lob(pi/2+b-theta)
         +lob(pi/2-b-theta)+lob(g+theta)-lob(g-theta)
         +2*lob(pi/2-theta))/4
    assert v.is_finite() and v > 0 and v.accuracy() > 400
    return v

class Volumes(numberdb.Generator):
    table = os.environ.get('NUMBERDB_TABLE', 'T822')
    parameters = ('cell', 'p', 'normalization')
    type = 'R'
    digits = 100
    rigour = 'proven'

    def enumerate(self, maximum=30):
        for cell, (_, _, _, minimum) in FAMILIES.items():
            for p in range(minimum, maximum+1):
                for normalization in ('cell','chamber'):
                    yield dict(cell=cell,p=p,normalization=normalization)

    def value(self, params, digits):
        cell, p = params['cell'], int(params['p'])
        v = chamber_volume(cell,p,digits)
        normalization = params['normalization']
        if normalization == 'cell':
            return FAMILIES[cell][2]*v
        if normalization == 'chamber':
            return v
        raise ValueError('unknown normalization')

if __name__ == '__main__':
    import sys
    if '--publish' in sys.argv:
        Volumes().publish()
    else:
        Volumes().verify(sample=None)