= Solution
Take $\gamma>0$ and set $A=\pi/2$. The <Rayleigh quotient> of the trial for the <quantum harmonic oscillator> is
$$
R(\gamma)=\frac{\int_{-A/\gamma}^{A/\gamma}[\gamma^2\sin^2(\gamma x)+x^2\cos^2(\gamma x)]dx}{\int_{-A/\gamma}^{A/\gamma}\cos^2(\gamma x)dx}.
$$
Its denominator is $\pi/(2\gamma)$. The kinetic numerator is $\gamma^2$ times that denominator. For the remaining <integral>, put $t=\gamma x$ and use
$$
\int_{-\pi/2}^{\pi/2}t^2\cos^2t\,dt=\frac{\pi^3}{24}-\frac\pi4=\frac{\pi(\pi^2-6)}{24},
$$
obtained from $\cos^2t=(1+\cos2t)/2$ and <integration by parts>. Thus the <compact cosine trial bound for the quantum harmonic oscillator> is
$$
\boxed{R(\gamma)=\gamma^2+\frac{\pi^2-6}{12\gamma^2}.}
$$
Differentiation gives $R'=2\gamma-(\pi^2-6)/(6\gamma^3)$, so the minimizing parameter satisfies
$$
\boxed{\gamma_{\mathrm{opt}}^4=\frac{\pi^2-6}{12}.}
$$
The quotient tends to infinity at either end of $\gamma>0$, and the two positive terms are equal at this stationary point, proving it is the global minimum. Therefore
$$
\boxed{\lambda_0\leq\sqrt{\frac{\pi^2-6}{3}}\approx1.13572.}
$$
For comparison, the exact <ground state> has value $1$. The trial is admissible for the energy <quadratic form>: it is continuous, has compact support, and its <weak derivative> is square-integrable. Its first <derivative> jumps at the support endpoints, so it need not belong to the smaller twice-differentiable <operator domain>; this does not invalidate the <Rayleigh-Ritz variational principle> bound.
Back to article page