Solution (source code)

= Solution

Only odd <stationary states> contribute, and for $j=2n+1$ their squared coefficients are $128/[\pi^2(j^2-16)^2]$. Since $E_{av}/E_1=16$, substitution gives
$$
\pi^2=8\sum_{n\ge0}\frac{(2n+1)^2}{[(2n+1)^2-16]^2},
$$
so $B=8$.