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 thue_morse(b, digits=100):
# Morphic digits; exact radix sum plus a geometric tail.
b = ZZ(b)
if b < 2:
raise ValueError("b must be an integer at least 2")
n = 1
while QQ(1)/(b**n*(b-1)) > QQ(1)/(10**(digits+30)*b**2):
n += 1
word = [0]
while len(word) < n:
word = [v for d in word for v in (d, 1-d)]
a = ZZ(0)
for d in word[:n]:
a = b*a+d
lower = QQ(a)/b**n
tail = QQ(1)/(b**n*(b-1))
R = RealBallField(numberdb.bits(digits, losing=120))
return R(lower+tail/2).add_error(R(tail/2))
# Default coverage; thue_morse(b) also accepts larger integer radices.
[(b, thue_morse(b)) for b in range(2, 17)]The generator computes the first $J$ factors $Q_J=\prod_{j=0}^{J-1}(1-b^{-2^j})$ exactly as rationals. The bound $0\leq Q_J-Q(1/b)\leq1/(b^{2^J}-1)$ yields rational lower and upper bounds for $V_b$, with width at most $1/(2b(b^{2^J}-1))$. It stops when this width is less than $10^{-130}/b^2$ for the default $100$ significant digits. A $453$-bit Arb ball encloses both rational endpoints and arithmetic rounding; all returned balls are finite and have positive radius. The default range uses $7$ to $9$ factors.
A separate checker generates the word by substitution, sums its first $N$ digits with exact rational arithmetic, and bounds the remaining tail by $b^{-N}/(b-1)$. For every stored base this independent enclosure is contained in the interval encoded by the recorded decimal; its width is less than $10^{-25}$ times one stored last-place unit. Checks also compare $1024$ digits with binary parity and finite product coefficients, test the functional identity, and reject deliberately shifted, complemented, incorrectly truncated, last-place-altered and vacuous values. Known finite and periodic digit sums control the checker. Attached evidence records exact bounds, software versions and the tested range.