Solution (source code)

= Solution

Assume a complete <orthonormal eigenbasis> and a <self-adjoint operator> bounded below, with the trial state in its <operator domain> or associated energy-form domain. The expansion and <orthogonality> give
$$
\langle\phi,\phi\rangle=\sum_n|a_n|^2,\qquad\langle\phi,H\phi\rangle=\sum_nE_n|a_n|^2.
$$
Consequently
$$
\boxed{F[\phi]=\frac{\sum_nE_n|a_n|^2}{\sum_n|a_n|^2}\geq E_0.}
$$
It is a weighted average of <eigenvalues>, all at least $E_0$. This is the <Rayleigh-Ritz variational principle>; equality holds precisely when the trial state lies in the <ground-state subspace>. A continuous part of the spectrum would require the corresponding spectral <integral> in place of part of the sum.