back to table · edit · history · where entries came from · files · download
4328 bytes, as of the version from 2026-11-11 00:55 (current). Recorded here, not run.
"""T712: Squared Bagchi sequence-space distances.
Usage (SageMath with numberdb installed):
sage -pip install numberdb
sage -python generate.py # verify all stored entries; no writes
sage -python generate.py --publish # fill the assigned draft, additive
from generate import BagchiDistances
BagchiDistances().value({'support': 'all', 'N': 31}, 100)
The integer N is a denominator bound, not dimension. The two arithmetic
supports are all integers 2..N and their squarefree subset. No basis or weight
normalization is applied. Exact rationals enter Arb before transcendental
operations. The rational autocorrelation formula is BBLS (math/0306251),
Proposition 89, with V(p,q)=sum_{r=1}^{q-1}{rp/q}cot(pi*r/q).
K_ij=G_ij-G_i1/j-G_1j/i+G_11/(ij), G_ij=A(i/j)/i;
b_i=log(i)/i. Native real-ball solve encloses K alpha=b, followed by 1-b^T alpha.
Working precision is max(512, bits(digits, losing=180)). Finite balls and at
least digits*log2(10)+16 relative accuracy bits are required, never guessed.
The selected prefixes have at most 29 dimensions. See numerical-evidence.md
and check-results.json for measured precision and independent validation.
Canonical instruction archive: skill-manifest.json (bundle
d6661c2f21613524889fa3a57d3c95f8330344ca62e5a856211c08a282b7dbab).
No website credentials or session attribution belong in this reusable file.
"""
import functools
import math
import os
import sys
import numberdb.sage as numberdb
# Initialize the Laurent ring constructor used by Sage's matrix machinery.
import sage.rings.polynomial.laurent_polynomial_ring
from sage.rings.rational_field import QQ
from sage.rings.integer_ring import ZZ
from sage.rings.real_arb import RealBallField
from sage.matrix.constructor import matrix
def support_indices(support, N):
N = int(N)
if N < 2 or support not in ('all', 'squarefree'):
raise ValueError('support must be all or squarefree, and N >= 2')
return tuple(k for k in range(2, N+1)
if support == 'all' or ZZ(k).is_squarefree())
@functools.lru_cache(maxsize=None)
def gram(j, k, precision):
R = RealBallField(precision)
d = math.gcd(j, k)
p, q = j//d, k//d
lam = R(QQ(p)/q)
C = (2*R.pi()).log() - R.euler_constant()
def V(a, b):
return sum((R(QQ((r*a) % b)/b) *
(R.pi()*R(QQ(r)/b)).cot()
for r in range(1, b)), R(0))
A = ((1-lam)*lam.log() + (1+lam)*C)/2
A -= R.pi()*(V(p,q)+V(q,p))/(2*q)
return A/j
@functools.lru_cache(maxsize=None)
def system(indices, precision):
R = RealBallField(precision)
b = matrix(R, len(indices), 1, [R(k).log()/k for k in indices])
K = matrix(R, [[gram(j,k,precision)-gram(j,1,precision)/k
-gram(1,k,precision)/j+gram(1,1,precision)/(j*k)
for k in indices] for j in indices])
alpha = K.solve_right(b)
value = R(1)-(b.transpose()*alpha)[0,0]
assert value.is_finite() and value > 0 and value < 1
assert all(x.is_finite() for x in alpha.list())
return K, b, alpha, value
class BagchiDistances(numberdb.Generator):
table = os.environ.get('NUMBERDB_TABLE', 'T712')
parameters = ('support', 'N')
type = 'R'
digits = 100
rigour = 'proven'
def enumerate(self, limit=30):
for support in ('all', 'squarefree'):
for N in range(2, int(limit)+1):
yield {'support': support, 'N': N}
def value(self, params, digits):
precision = max(512, numberdb.bits(digits, losing=180))
indices = support_indices(str(params['support']), int(params['N']))
value = system(indices, precision)[3]
if value.accuracy() < numberdb.bits(digits, losing=16):
raise ArithmeticError('Insufficient certified accuracy; raise working precision')
return value
if __name__ == '__main__':
if os.environ.get('NUMBERDB_KEY_FROM_STDIN') == '1':
key = sys.stdin.read().strip()
if '=' in key and key.split('=', 1)[0].replace('_','').isalnum():
key = key.split('=', 1)[1].strip().strip('\"\'')
numberdb.configure(api_key=key)
g = BagchiDistances()
if '--publish' in sys.argv:
print(g.publish(message=os.environ.get('NUMBERDB_EDIT_MESSAGE','')))
else:
print(g.verify(sample=None))