Image and invertibility of $\frac{d}{dx}-x$ on $\mathbb{R}$ This question is about the first-order differential operator 
$$D=i\frac{d}{dx}-ix:C^\infty(\mathbb{R},\mathbb{C})\to C^\infty(\mathbb{R},\mathbb{C}).$$ 
One finds that $\ker(D)$ is the one-dimensional space $\mathbb{C}f$, where $f(x)=e^{x^2/2}$.
Since $f\notin L^2(\mathbb{R},\mathbb{C})$, I would like to say that $D$ is invertible on $L^2(\mathbb{R},\mathbb{C})$, but I'm not sure in what precise sense this is true.
Question 1: Are there natural choices of domain and codomain that make $D$ an invertible operator? (One guess is $H^1(\mathbb{R},\mathbb{C})$ and $L^2(\mathbb{R},\mathbb{C})$, where $H^1$ is the first Sobolev space.)
Question 2: Does the image of $D$ contain the function $e^{-x^2/2}$?
 A: Since multiplication by $i$ is analytically irrelevant I will ignore it. The operator $\frac{d}{dx}-x$ is conjugate to the ordinary differentiation under multiplication by $e^{-x^2/2}$, i.e.
$$
\left(\frac{d}{dx}-x\right)f=e^{x^2/2}\frac{d}{dx}\left(e^{-x^2/2}f\right).
$$
In particular, it can be inverted explicitly: if $f'-xf=g$ then 
$$f=e^{x^2/2}\int e^{-x^2/2}g(x)\,dx,$$
where $\int$ stands for any antiderivative. By the way, this is the operator whose powers applied to $1$ generate the Hermite polynomials $He_n$.
As for spaces, the simplest one consists of functions $f$ such that $e^{-x^2/2}f\in H^1$. The $H^1$ norm of $e^{-x^2/2}f$ gives a Hilbert norm on it. But the image of the operator does not contain all functions $g$ such that $e^{-x^2/2}g\in L^2$ (this is the space where the Hermite polynomials $H_n$ are orthogonal). In fact, no positive function is in it. This is because to have an antiderivative in $L^2$ the function has to integrate to $0$ over the entire line. Indeed, the image of $\frac{d}{dx}-x$ on functions that vanish at $\pm\infty$ is orthogonal to $e^{-x^2/2}$, which spans the kernel of its $L^2$-adjoint. Integrating by parts,
$$
\int e^{-x^2/2}\left(\frac{d}{dx}-x\right)\!\phi\,dx
=\int\!\left(-\frac{d}{dx}-x\right)\!e^{-x^2/2}\phi\,dx=0.
$$
Nonetheless, the pre-image of $e^{-x^2/2}$ is easily found explicitly, it is $\frac{\sqrt{\pi}}{2}e^{x^2/2}\,\textrm{erf}(x)$, where $\textrm{erf}(x)$ is the error function. So to get $e^{-x^2/2}$ into the image one needs to replace $H^1$ above with some weighted Sobolev space that contains $\textrm{erf}(x)$.
