from sage.all import QQ, ZZ, RealBallField, moebius, gcd
from functools import lru_cache
def baez_duarte_error(N, bits=461):
N=ZZ(N)
if N<1:
raise ValueError("N must be positive")
if N==1:
return ZZ(1)
R=RealBallField(bits)
C=(2*R.pi()).log()-R.euler_constant()
@lru_cache(None)
def V(p,q):
return sum((R(QQ((m*p)%q)/q)*(R.pi()*R(QQ(m)/q)).cot()
for m in range(1,q)),R(0))
def G(j,k):
d=gcd(j,k); p=j//d; q=k//d; x=R(QQ(p)/q)
return (((1-x)*x.log()+(1+x)*C)/2
-R.pi()*(V(p,q)+V(q,p))/(2*q))/j
w=[QQ(moebius(n)) for n in range(1,N+1)]
w[-1]-=N*sum((w[n-1]/n for n in range(1,N+1)),QQ(0))
b=[(R(n).log()+1-R.euler_constant())/n for n in range(1,N+1)]
return (1+2*sum((w[j]*b[j] for j in range(N)),R(0))
+sum((w[j]*w[k]*G(j+1,k+1) for j in range(N)
for k in range(N)),R(0)))
# The stored selection is every N=1,...,30; the domain is all N>=1.
baez_duarte_error(4)
Computed with Arb real balls at 461 working bits from exact rational Möbius weights and finite cotangent sums at exact rational arguments. All inexact entries retain at least 443 bits of relative accuracy, with radii below $7.42\times10^{-136}$, sufficient for 100 significant digits. The first entry is the exact integer 1 because $B_1=0$. No rounded companion values are inputs.
A separate 720-bit calculation integrates the piecewise quadratic fractional-part product against the trigamma kernel. It evaluates 16 terms analytically, then sums powers 0 through 125 with an explicit alternating-series remainder bound. All 465 symmetric Gram entries and all 30 norms agree; the independent norm radii are below $6.04\times10^{-151}$. Whole-residual integrals also agree for $N=1,2,3,4,6$. Known-answer, deliberately incorrect, wide-ball and NaN controls test the checker. Exact endpoint cancellation and lower bounds from independently solved least-squares systems hold throughout the computed prefix. The generator, checks, derivation and numerical evidence are attached.