import numberdb.sage as numberdb
from sage.rings.real_arb import RealBallField
from sage.rings.integer import Integer
R = RealBallField(512)
def hyperball_height(cell, p):
    first = {"tetrahedron": 7, "cube": 7, "octahedron": 5}[cell]
    if not isinstance(p, (int, Integer)) or p < first:
        raise ValueError("p must be an integer in the tiling domain")
    c = (2*R.pi()/p).cos()
    C = {"tetrahedron": c/(2*c-1),
         "cube": 1/(2*c-1), "octahedron": (1+c)/(2*c)}[cell]
    return C.arccosh()/2
hyperball_height("octahedron", 6)
h=hyperball_height("octahedron",6)
assert h.is_finite() and ((2*h).cosh()-R(3)/2).contains_zero()
print("Displayed Sage program: golden-ratio control passed")
