back to table · edit · history · where entries came from · files · download
4215 bytes, as of the version from 2026-12-01 03:06 (current). Recorded here, not run.
"""Reproduce T883, values of the inverse logarithmic integral.
Requires SageMath with Arb and numberdb: sage -pip install numberdb
Read-only verification: sage -python generate.py
Fill the authorized draft: sage -python generate.py --publish
The latter submits entries only; it never offers or publishes the draft.
Credentials and agent/model provenance are configured outside this file.
For real x, g(x)>1 uniquely solves Ei(log(g(x)))=x, with real principal-value
Ei and natural logarithms. This is the unoffset li inverse (DLMF 6.2.8;
Arias de Reyna and Toulisse, arXiv:1203.5413v2, Section 2). The default inputs
are all positive integers 1 through 500, selected by the nth-prime context.
The cutoff is a practical reference bound, not a mathematical threshold.
Every computation maintains exact rational endpoints for r=log(g(x))>0.
Arb Ei endpoint signs, continuity and Ei'(r)=exp(r)/r>0 prove the bracket.
Bisection continues to 30 decimal guard digits beyond the requested digits;
the complete ball is exponentiated. Working precision is at least 512 bits
(548 bits for 100 digits), increasing if an endpoint sign is unresolved.
The actual endpoint certificate and independent checks are attached separately.
"""
import os
import sys
from functools import lru_cache
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
@lru_cache(maxsize=1200)
def enclose(x, digits=100):
"""Enclose g(x) for an exact rational x; no approximate input is accepted."""
x = QQ(x)
bits = max(512, numberdb.bits(digits + 60))
field = RealBallField(bits)
low, high = QQ(1)/2, QQ(16)
while not field(low).Ei() < x:
low /= 2
while not field(high).Ei() > x:
high *= 2
initial_low, initial_high = low, high
initial_left, initial_right = field(low).Ei()-x, field(high).Ei()-x
assert initial_left.is_finite() and initial_right.is_finite()
assert initial_left < 0 and initial_right > 0
target = QQ(1)/10**(digits+30)
iterations = 0
while high-low > target:
middle = (low+high)/2
evaluation = field(middle).Ei()-x
assert evaluation.is_finite()
if evaluation < 0:
low = middle
elif evaluation > 0:
high = middle
else:
bits *= 2
field = RealBallField(bits)
continue
iterations += 1
left, right = field(low).Ei()-x, field(high).Ei()-x
assert left.is_finite() and right.is_finite() and left < 0 and right > 0
root = field(low).union(field(high))
value = root.exp()
assert value.is_finite() and root.is_finite() and value > 1 and value.rad() > 0
return value, {'x':str(x),'working_bits':bits,'iterations':iterations,
'initial_r_lower':str(initial_low),'initial_r_upper':str(initial_high),
'initial_residual_lower':str(initial_left),'initial_residual_upper':str(initial_right),
'r_lower':str(low),'r_upper':str(high),'r_radius':str(root.rad()),
'residual_lower':str(left),'residual_upper':str(right),
'value_radius':str(value.rad()),'value_ball':str(value)}
class InverseLi(numberdb.Generator):
table = 'T883'
parameters = ('x',)
type = 'R'
digits = 100
rigour = 'proven'
files = ('generate.py',)
def enumerate(self, maximum=500):
if not isinstance(maximum, int) or maximum < 1:
raise ValueError('maximum must be a positive integer')
for n in range(1, maximum+1):
yield {'x':n}
def value(self, params, digits):
if set(params) != {'x'} or isinstance(params['x'], float):
raise ValueError('Supply one exact rational real input x')
return enclose(str(params['x']), digits)[0]
if __name__ == '__main__':
if os.environ.get('NUMBERDB_KEY_FROM_STDIN') == '1':
os.environ['NUMBERDB_API_KEY'] = sys.stdin.read().strip()
generator = InverseLi()
if '--publish' in sys.argv or os.environ.get('NUMBERDB_PUBLISH') == '1':
print(generator.publish(message=os.environ.get('NUMBERDB_EDIT_MESSAGE','Reproduce certified inverse logarithmic integral values.')))
else:
print(generator.verify(sample=None))