Solution (source code)

= Solution

For any normalized trial state $\psi$, the spectral expansion gives $\langle\psi|H|\psi\rangle\ge E_0$. Minimize this Rayleigh quotient over a trial family to obtain the best upper bound.