import numberdb.sage
from math import factorial
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
def moment(n):
"""Raw moment of the standard Brownian excursion area, n >= 1."""
if n < 1:
raise ValueError('n must be positive')
k = [-QQ(1)/QQ(2)]
for j in range(1, n+1):
k.append(QQ(3*j-4)/QQ(4)*k[j-1]
+ sum((k[i]*k[j-i] for i in range(1,j)), QQ(0)))
m = n//2
if n%2:
r = RealBallField(512)
q = QQ(4*factorial(n))*k[n]/QQ(2**m*factorial(3*m))
return r(q)*(r.pi()/r(2)).sqrt()
j = 3*m-1
return QQ(4*factorial(n)*4**j*factorial(j))*k[n]/QQ(2**m*factorial(2*j))
# For example, the mean:
print(moment(1))
The recurrence for $K_n$ and the rational prefactors were evaluated exactly over $\mathbb Q$. Even moments are stored as exact rational numbers. Odd moments are formed from the rational prefactor and an Arb enclosure of $\sqrt{\pi/2}$ at 513 bits, then written to 100 significant digits; the lowest measured relative accuracy was 510 bits. Each written decimal denotes the interval within one unit of its last place.
An independent exact calculation used the formal logarithm of the factorial series for graph enumeration and Spencer’s moment relation, [1], equations (34), (36), and (63)–(64), for orders 2 through 12. The mean was independently recovered from the Maxwell radial mean and the beta integral over bridge time. The four positive moments in Table 1 of [1] agree. Direct Arb evaluation of the Gamma formula checks the cancellation at all twelve orders. The attached checks also test the written enclosures and strict log-convexity, with the zeroth moment equal to one. See checks.py and numerical-evidence.json for the controls and results.