import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.symbolic.ring import SR
import sage.rings.polynomial.laurent_polynomial_ring
from sage.combinat.sf.sf import SymmetricFunctions
from sage.combinat.partition import Partitions
from collections import Counter
from math import factorial, prod
def symplectic_weingarten(N, mu):
k = sum(mu)
sf = SymmetricFunctions(QQ)
p, s, J = sf.power(), sf.schur(), sf.jack(t=QQ(2)).J()
z = prod(r**m * factorial(m) for r, m in Counter(mu).items())
total = QQ(0)
for lam in Partitions(k):
if len(lam) > N:
continue
doubled_rows = tuple(r for r in lam for _ in (0, 1))
f = s[doubled_rows].scalar(p[[1]*(2*k)])
c = p(J[lam.conjugate()]).coefficient(mu)
d = prod(2*N - 2*i + j for i, row in enumerate(lam) for j in range(row))
total += QQ(f*c) / QQ(d)
return QQ(2**len(mu)*z) * total / QQ(factorial(2*k))
print(symplectic_weingarten(2, (2,))) # 1/40
The attached generator evaluates the twisted spherical expansion over $\mathbb Q$. At the even representatives, $\pi^\lambda(\sigma_\mu)=\omega^{\lambda'}(\sigma_\mu)$, where $\lambda'$ is the conjugate partition and $\omega^{\lambda'}$ is the zonal spherical function. It extracts $\omega^{\lambda'}$ from the expansion of the Jack polynomial $J_{\lambda'}^{(2)}$ in power-sum symmetric polynomials, using [2], equation (3.5), and obtains $f^{\lambda\cup\lambda}$ by the hook-length formula. Every stored value is an exact fraction, without rounding.
All 68 coefficients were independently recovered by rational elimination of the pairing Gram equations, using up to 10,395 pairings. Tensor contractions with $J_N$ determine the Gram signs. The checks recover all 21 admissible moments $\mathbb E|S_{11}|^{2k}=k!/\prod_{j=0}^{k-1}(2N+j)$ from the uniform complex sphere, and compare all 16 coefficients with $k\leq2$ to (4). Known nonzero controls, 38 direct tensor contractions, and an intentionally changed coefficient test the checker. The reader program agrees with every entry.