# How to find the position expectation value from the Fourier transform of a wave function?

Here's my reasoning:

$$\langle \hat{x} \rangle=\int_{-\infty}^{\infty}\psi^*(x,t)\hat{x}\psi(x,t)$$ $$=\frac{1}{2\pi}\int_{-\infty}^{\infty}dx(\int_{-\infty}^{\infty}\phi(k,t)e^{ikx}dk)^*\hat{x}\int_{-\infty}^{\infty}dk'\phi(k',t)e^{ik'x}$$

Where $$\phi(k,t)$$ is the Fourier transform of $$\psi$$ (I included the $$\omega t$$ term in $$\phi$$)

$$=\frac{1}{2\pi}\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}dkdk'\phi^*(k,t)\phi(k',t)\int_{-\infty}^{\infty}xe^{-i(k-k')x}dx$$

The integral $$\int_{-\infty}^{\infty}xe^{-i(k-k')x}dx=\frac{(i(k-k')x+1)}{(k-k')^2}e^{-i(k-k')x}\Bigg|_{-\infty}^{\infty}=???$$ if $$k\neq k'$$ and it obviously equals $$0$$ when $$k=k'$$.

My understanding is that this limit diverges, but that doesn't really make sense since the expectation value does exist.

The last integral converges, not to a function but to a distribution: the fourier transform of a monomial (here $$x$$) is the $$n$$-th derivative of a Dirac, see Wikipedia.
You can get the intuition by starting from: $$\int_{-\infty}^{+\infty} e^{-iux}du = 2\pi \delta(x)$$ Then: $$\frac{d}{dx}\int_{-\infty}^{+\infty} e^{-iux}du =\int_{-\infty}^{+\infty} -iu e^{-iux}du = 2\pi \frac{d}{dx} \delta(x) = 2\pi \delta^{(1)} (x)$$ So your last integral would evaluate to : $$\int_{-\infty}^{+\infty} x e^{-i\left(k-k'\right)x}dx=i 2\pi \delta^{(1)} (k-k')$$
This distribution behaves as the (minus) derivative operator when you apply it to a function (meaning integrating the distribution times the function). You can re-derive this by integrating by parts $$\delta^{(1)} (x) f(x)$$.
Another nice way to understand this is the representation of the $$\hat{x}$$ operator in $$k$$-space as the derivative operator: $$\hat{x} = i \hat{\partial}_k$$
Then the expectation value in the momentum basis would be : $$\langle \hat{x} \rangle = i \int_{-\infty}^{+\infty} \psi^*(k) \left(\partial_k \psi(k) \right) dk$$
It comes out to be the derivative of a Dirac delta function $$\int x\exp(ikx) dx = -i\partial_k \int \exp(ikx) dx = -i\partial_k 2\pi\delta(k)$$ When you use the result inside the integral with the wave functions, integration by parts transfers the derivative to one of the wave functions.