Show the the position operator does not preserve the Hilbert space

Consider a Hilbert space $$H$$ that consists of all functions $$ψ(x)$$ such that $$\int_{-\infty}^{\infty} |\psi(x)|^2\, dxˆ$$ is finite. Show that there are functions in $$H$$ for which $$\hat x\psi(x)=x\psi(x)$$ is not in $$H$$. That is to say, there are functions in $$H$$ that are taken out of H when acted upon by the position operator (or equivalently, the position operator does not preserve $$H$$).

My attempt $$\int_{-\infty}^{\infty} |ψ^*(x)\, \hat x\,\psi(x)|\, dxˆ$$

=$$\int_{-\infty}^{\infty} |ψ^*(x)\,\hat x\,\psi(x)|\, dxˆ$$

=$$\int_{-\infty}^{\infty} |ψ^*(x)\,\psi(x)\,x|\, dxˆ$$

=$$\int_{-\infty}^{\infty} |x\,ψ^2(x)|\, dxˆ$$

So, the integral will be divergent and not finite. So position operator does not preserve hilbert space

Is this the correct answer? I'm not sure whether I'm doing this correctly

This is very simple, and really a purely mathematical question, not so much a physics one. What you want is to try and find a function $$\psi(x)$$ so that

$$\int_{-\infty}^{\infty} |\psi(x)|^2\ dx$$

converges but

$$\int_{-\infty}^{\infty} |x \psi(x)|^2\ dx$$

diverges. One way to intuitively guess at what such a function might look like is to imagine it as a bell-like curve but with "heavy tails" - that is, peaked in the middle (at 0) but dying off poorly to the left and right there so the integral is finite, but "just barely". The trick then is to control this so that it's bad enough - but not too bad - that multiplying by $$x \mapsto x$$ will cause the tails to overfatten and the integral to blow up.

Hence, one guess, if one knows a little statistics, might be to try a "Cauchy distribution" - this is a rather bad function which, in nondimensionalized form, has the form

$$[\psi(x)]^2 := \frac{1}{1 + x^2}$$

so

$$\psi(x) = \sqrt{\frac{1}{1 + x^2}}$$

is the relevant wave function. It has a finite area under it, but "just barely" in that many strict statistical measures based on integrating it "blow up" and fail rather badly, such as the variance (variance is infinite). And, it turns out - this works! If we multiply it by $$x$$, as though applying the position operator, so that $$[\psi(x)]^2$$ becomes multiplied by $$x^2$$, then we have

$$x^2 [\psi(x)]^2 = \frac{x^2}{1 + x^2}$$

And this is now bounded away from 0 at $$\pm \infty$$ (it has limit $$1$$ there), hence the integral blows up. Thus the corresponding ket vector $$|\psi\rangle$$ is in $$H$$, but $$\hat{x} |\psi\rangle$$ is not.