Solution (source code)

= Solution

Write $B=-A=-\partial_x^2+1+x^2$. Smooth compactly supported functions lie in $D(A)$ and are dense in <L2 space>, so $A$ is densely defined.

For $\lambda>0$, use the form
$$
a_\lambda(u,v)=\int_{\mathbb R}u'\overline{v'}+(1+\lambda+x^2)u\bar v\,dx
$$
on the <one-dimensional harmonic oscillator form domain> $X$. It is bounded and coercive in the $X$ norm. The <Lax-Milgram theorem> gives a unique $u\in X$ satisfying $a_\lambda(u,v)=\langle g,v\rangle$ for every $v\in X$. Thus $-u''+(1+\lambda+x^2)u=g$ in <distributions>.

We must verify the full specified <operator domain>, not just the form domain. The equation first gives $u\in H^2_{\mathrm{loc}}$. For compactly supported $H^2$ functions, <integration by parts> gives the <graph estimate for the harmonic oscillator>, obtained from
$$
\begin{aligned}
\|-v''+(1+\lambda+x^2)v\|_2^2
={}&\|v''\|_2^2+\|(1+\lambda+x^2)v\|_2^2\\
&+2\int(1+\lambda+x^2)|v'|^2\,dx-2\|v\|_2^2.
\end{aligned}
$$
Apply this to $v=\chi_Ru$, with $\chi_R=1$ on $[-R,R]$, supported in $[-2R,2R]$, and derivatives bounded by $C/R$ and $C/R^2$. Its right-hand source is $\chi_Rg-2\chi_R'u'-\chi_R''u$, uniformly bounded in <L2 space>. The estimate and the <Fatou lemma> give $x^2u\in L^2$; the original equation then gives $u''\in L^2$, and hence $u\in H^2$. Thus $u\in D(A)$, proving that $\lambda-A$ is onto. The energy identity proves injectivity and the <resolvent of the shifted harmonic oscillator> estimate
$$
(1+\lambda)\|u\|_2^2\leq a_\lambda(u,u)=\operatorname{Re}\langle g,u\rangle
\leq\|g\|_2\|u\|_2,
\qquad
\boxed{\|(\lambda-A)^{-1}\|_{2\to2}\leq\frac1{1+\lambda}.}
$$
To prove closedness, suppose $u_n\to u$ and $Au_n\to v$ in <L2 space>. For one fixed $\lambda>0$,
$$
u_n=(\lambda-A)^{-1}(\lambda u_n-Au_n)\longrightarrow(\lambda-A)^{-1}(\lambda u-v).
$$
Therefore $u$ belongs to the range of the resolvent, namely $D(A)$, and $Au=v$.

All hypotheses of the <Hille-Yosida theorem> now hold; the resolvent bound is stronger than $1/\lambda$. Let $S(t)$ be its <contraction semigroup>. The <exponentially shifted semigroup>
$$
\boxed{\psi(t)=e^tS(t)\psi_0}
$$
has generator $A+I=\partial_x^2-x^2$. It is continuous in <L2 space>, takes the initial value $\psi_0$, and satisfies $\boxed{\|\psi(t)\|_2\leq e^t\|\psi_0\|_2}$. For $\psi_0\in D(A)$, its time derivative exists in <L2 space> and equals $(A+I)\psi(t)$, so the equation holds as a strong <L2 space> solution. For general initial data it is the semigroup solution, without an unproved pointwise differentiability claim.