back to table · edit · history · where entries came from · files · download
3208 bytes, as of the version from 2026-12-02 10:31 (current). Recorded here, not run.
"""Reproduce NumberDB T916: Largest edges of cubes contained in unit cubes.
Requires SageMath 10.9 (or compatible SageMath/passagemath) and numberdb.
sage -pip install numberdb
sage -python generate.py # preview, no writes
sage -python generate.py --verify # compare every stored entry
sage -python generate.py --publish # authorized entries upload only
The two parameters, in order, are the cube dimension m and ambient dimension n.
The default is every 1 <= m < n <= 16 with m dividing n or m=2. Increasing
limit extends these proved classes; unsupported dimension pairs are refused.
Diagonal values can be evaluated but are omitted from default enumeration.
Shultz (2013), printed pp. 5-7 and 18-26, supplies the optimality formulas.
Exact rational radicands are formed before sqrt. Perfect rational squares
return exact QQ values. Other roots use positive Arb square roots at
numberdb.bits(digits, losing=64), 397 bits for 100 decimal digits. The
builder measured all resulting balls and checked every serialized enclosure
by rational squaring, separately from exact fitting-matrix certificates.
No numerical optimization or source decimal approximation is an input.
Credentials and agent/model provenance are configured by the caller.
"""
import os
import sys
import argparse
import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
class CubeContainment(numberdb.Generator):
table = 'T916'
parameters = ('m', 'n')
type = 'R'
digits = 100
rigour = 'proven'
files = ('generate.py',)
def enumerate(self, limit=16):
for n in range(2, int(limit) + 1):
for m in range(1, n):
if n % m == 0 or m == 2:
yield {'m': m, 'n': n}
def value(self, params, digits):
m, n = ZZ(params['m']), ZZ(params['n'])
if not 1 <= m <= n:
raise ValueError('Require integer dimensions 1 <= m <= n')
if n % m == 0:
q = QQ(n) / m
elif m == 2 and n % 2 == 1:
q = QQ(4*n-3) / 8
else:
raise ValueError('No implemented proved optimum for this dimension pair')
if q.is_square():
return QQ(q.sqrt())
return RealBallField(numberdb.bits(digits, losing=64))(q).sqrt()
if __name__ == '__main__':
p = argparse.ArgumentParser(description=__doc__)
choice = p.add_mutually_exclusive_group()
choice.add_argument('--publish', action='store_true')
choice.add_argument('--verify', action='store_true')
p.add_argument('--limit', type=int, default=16)
args = p.parse_args()
if os.environ.get('NUMBERDB_KEY_FROM_STDIN') == '1':
numberdb.configure(api_key=sys.stdin.read().strip())
g = CubeContainment()
if args.verify:
print(g.verify(sample=None))
elif args.publish or os.environ.get('NUMBERDB_PUBLISH') == '1':
print(g.publish(limit=args.limit, message=os.environ.get('NUMBERDB_EDIT_MESSAGE', ''), removing=False))
else:
for params in g.enumerate(limit=args.limit):
print(params, g.value(params, g.digits))