back to table · edit · history · where entries came from · files · download
718 bytes, as of the version from 2026-11-02 13:17 (current). Recorded here, not run.
# B([0; overline(a_1,...,a_l)]) for a tuple of positive integers.
import numberdb.sage as numberdb
from sage.rings.real_arb import RealBallField
def brjuno_period(period, bits=429):
if not period or any(a < 1 or int(a) != a for a in period):
raise ValueError("Positive integer partial quotients required")
F = RealBallField(bits)
xs = []
for j in range(len(period)):
p, q, r, s = 1, 0, 0, 1
rotated = period[j:] + period[:j]
for a in rotated:
p, q, r, s = q, p+a*q, s, r+a*s
xs.append((F(p-s) + F((s-p)**2+4*r*q).sqrt()) / (2*r))
P, S = F(1), F(0)
for x in xs:
S += P*(-x.log())
P *= x
return S/(1-P)
brjuno_period((1,))