Solution (source code)

= Solution

Choose an <orthonormal> <eigenbasis> $H_0|n\rangle=E_n|n\rangle$ and the <phase> convention $\langle0|\psi'\rangle=0$. Comparing coefficients of the <eigenvalue> equation at first order yields
$$
(H_0-E_0)\psi'=-(H'-E')|0\rangle.
$$
Projecting onto $|0\rangle$ and the other <eigenvectors> gives
$$
\boxed{E'=\langle0|H'|0\rangle,\qquad\psi'=\sum_{n\ne0}\frac{\langle n|H'|0\rangle}{E_0-E_n}|n\rangle.}
$$
Projection of the next-order equation onto $|0\rangle$ gives
$$
\boxed{E''=\langle0|H'|\psi'\rangle=\sum_{n\ne0}\frac{|\langle n|H'|0\rangle|^2}{E_0-E_n}.}
$$
These are coefficients of the printed series, so $E''$ denotes the quadratic coefficient rather than the second derivative itself. Without a <phase> convention an arbitrary purely imaginary multiple of $\psi_0$ can be added to the first vector correction. Continuous spectrum, if present, requires the corresponding <spectral theorem>[spectral integral]; the oscillator has a discrete <complete> <eigenbasis>.

Put $K=m\omega^2/2$ and let $g(x)=(2\pi\sigma^2)^{-1/2}e^{-x^2/(2\sigma^2)}$ denote the ground-state density. Then $H'=K(a^2-x^2)\mathbf1_{[-a,a]}$ and $p=\int_{-a}^ag(x)\,dx$. Because $g'=-xg/\sigma^2$, <integration by parts> yields
$$
I_2:=\int_{-a}^ax^2g\,dx=\sigma^2p-2a\sigma^2g(a),\qquad
I_4:=\int_{-a}^ax^4g\,dx=3\sigma^4p-2a\sigma^2(a^2+3\sigma^2)g(a).
$$
Thus the two first-order shifts are
$$
\boxed{E'_0=K[(a^2-\sigma^2)p+2a\sigma^2g(a)],\qquad
E'_1=K[(a^2-3\sigma^2)p+6a\sigma^2g(a)].}
$$
The first is the supplied ground-state expression; the second follows because the excited-state density is $x^2g/\sigma^2$, so $E'_1=K(a^2I_2-I_4)/\sigma^2$.

Subtracting, and using $K\sigma^2=\hbar\omega/4$, gives
$$
\boxed{E'_1-E'_0=-\frac{\hbar\omega}{2}[p(a)-2ag(a)].}
$$
The bracket is zero at $a=0$, tends to one at infinity, and has derivative $2a^2g(a)/\sigma^2\geq0$. Therefore the first-order predicted level gap is
$$
\boxed{E_1^{\rm app}-E_0^{\rm app}=\hbar\omega\left[1-\frac\lambda2\{p(a)-2ag(a)\}\right].}
$$
For every $\lambda>2$ it becomes negative for all sufficiently large $a$, crossing when $p-2ag=2/\lambda$. It is still positive at $a=0$: the stated conclusion must be read with the large-$a$ regime, rather than for every interval width.

For $\lambda>1$ the inner potential curves downward, placing a central barrier between two symmetric minima at $\pm a$. The <even> unperturbed <ground state> has its greatest density at the central barrier, while the <odd> first <excited state> has a node there and is less penalized. This explains the relative first-order shifts. \b[A negative predicted gap signals failure of that perturbation approximation], not inversion of the exact lowest two states: the true one-dimensional <ground state> remains <nodeless> and <even>, with the <odd> state above it. At a high barrier the actual low levels instead form a close double-well pair. The <apparent level crossing from a finite-interval oscillator perturbation> is useful precisely as a diagnostic of the approximation's range.