back to table · edit · history · where entries came from · files · download
3464 bytes, as of the version from 2026-12-01 17:23 (current). Recorded here, not run.
"""T896: Thue-Morse constants in integer bases.
Requires SageMath and numberdb. Install with ``sage -pip install numberdb``.
Run ``sage -python generate.py`` to check (no writes), or explicitly use
``sage -python generate.py --publish`` to fill the assigned draft's entries.
This never offers a draft or publishes a table to the public catalogue.
V_b=sum(t_n*b^(-n-1),n>=0), t_n=parity of the binary digit sum of n.
The first fractional digit is t_0=0. The default selection is every integer
b=2,...,16; --maximum-base extends the same discrete family.
Badziahin--Zorin, arXiv:1407.3182v2, sections 1--2, gives the sequence and
Q(z)=product(1-z^(2^j),j>=0). Hence V_b=1/(2(b-1))-Q(1/b)/(2b).
For the first J product factors Q_J, the omitted product changes Q_J by at
most 1/(b^(2^J)-1). This follows from 1-product(1-a_j)<=sum(a_j), with
sum(b^(-2^j),j>=J)<=sum(b^(-k*2^J),k>=1). Exact rational endpoints are
converted to an enclosing Arb ball. No rounded input or float is used.
At 100 digits this uses 453 bits (120 guard bits), measured against the exact
endpoints and independent digit sums. The exact tail goal is 10^-130/b^2.
All computation depends only on this file; runtime provenance belongs to the
upload environment. The command defaults to verify(sample=None).
"""
import argparse
import os
import sys
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
def product_bounds(b, digits=100):
b = ZZ(b)
if b < 2:
raise ValueError('The integer radix must satisfy b >= 2.')
q = QQ(1)
m = 1
factors = 0
goal = QQ(1) / (ZZ(10)**(digits + 30) * b**2)
while True:
q *= 1 - QQ(1) / b**m
factors += 1
m *= 2
error = QQ(1) / (2*b*(b**m - 1))
if error < goal:
break
lower = QQ(1)/(2*(b-1)) - q/(2*b)
return lower, lower + error, factors, error
class ThueMorseConstants(numberdb.Generator):
table = 'T896'
parameters = ('b',)
type = 'R'
digits = 100
rigour = 'proven'
def enumerate(self, maximum_base=16):
for b in range(2, int(maximum_base) + 1):
yield {'b': b}
def value(self, params, digits):
b = ZZ(params['b'])
if b != params['b']:
raise ValueError('The radix must be an integer.')
lower, upper, _, _ = product_bounds(b, digits)
field = RealBallField(numberdb.bits(digits, losing=120))
result = field((lower+upper)/2).add_error(field((upper-lower)/2))
assert result.is_finite() and not result.is_exact()
assert result.contains_exact(lower) and result.contains_exact(upper)
return result
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--publish', action='store_true')
parser.add_argument('--maximum-base', type=int, default=16)
options = parser.parse_args()
if os.environ.get('NUMBERDB_KEY_FROM_STDIN') == '1':
key = sys.stdin.read().strip()
if '=' in key and key.split('=', 1)[0].isidentifier():
key = key.split('=', 1)[1].strip().strip('\"\'')
os.environ['NUMBERDB_API_KEY'] = key
generator = ThueMorseConstants()
if options.publish or os.environ.get('NUMBERDB_PUBLISH') == '1':
print(generator.publish(maximum_base=options.maximum_base))
else:
print(generator.verify(sample=None))