import numberdb.sage as numberdb
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.real_mpfi import RealIntervalField
def champernowne(b, digits=100):
b = ZZ(b)
if b < 2:
raise ValueError("b must be an integer at least 2")
A, D, n, k, next_power = ZZ(0), ZZ(1), ZZ(0), 1, b
while D <= ZZ(10)**(digits + 15):
n += 1
while n >= next_power:
k += 1
next_power *= b
A = A * b**k + n
D *= b**k
R = RealIntervalField(max(512, numberdb.bits(digits, losing=128)))
return R(QQ(A)/D, QQ(A+1)/D)
champernowne(10) # an enclosure of C_10
Complete integer blocks were accumulated with exact integer arithmetic until $b^{L_n}>10^{115}$. Any continuation changes the prefix by at most $b^{-L_n}$, since $(b-1)\sum_{j>L_n}b^{-j}=b^{-L_n}$. Both exact rational endpoints were converted outward using MPFI at 512 bits. Every resulting enclosure is contained in its stored 100-significant-digit decimal interval.
A separate implementation locates each digit from the cumulative counts $\sum_{j=1}^{k}j(b-1)b^{j-1}$. It checked every generated prefix in bases 2 through 16 and containment in every serialized interval. Controls included the first 150 decimal digits from [3], the initial binary blocks, transitions at $b$ and $b^2$, exact repeating-digit streams, and deliberately corrupted data. The attached code and results retain the checks.