I am currently working on an fft that takes a guassian wavefunction from position space to momentum space by doing an fft. But when I do this, for some reason, I do not
seem to get a normalized state using the typical dividing by the length of sampling as seen in many documentation examples. If I force a state to be normalized through
pVecFFTnorm=pVecFFTTrial./(sqrt(sum(abs(pVecFFTTrial).^2)*dp));
I get a result for a quantity that I do not expect (I get a pExpectSquare, shown in the code below, that deviates significantly from 0.5) What could be done to ensure that my norm will be 1 for my wavefunction? The code is provided below:
%Note: the parameters of a=1, hbar=1 p0=0, and x0=0 have been numerically assumed
%for wave pack and all other functions below.
N=2048;clfwavePack=@(x)((1/pi)^(1/4)*exp((-(x).^2)/2));xDomFFT=linspace(-20,20,N);xVecFFT=wavePack(xDomFFT);dx=(xDomFFT(2)-xDomFFT(1));normBeforeFFT=sum(xVecFFT.^2)*dx;%xPoints = 2^nextpow2(xPoints);
pVecFFTpreShift=fft(xVecFFT,N);pVecFFT=fftshift(fft(xVecFFT));%the fft may not necesarily be normalized. This line is to make sure that
%the fft is normalized.
pDom=linspace(-N/2+1,N/2,(N));dp=abs(pDom(2)-pDom(1));pVecFFTTrial=pVecFFT/N;pVecFFTnorm=pVecFFTTrial./(sqrt(sum(abs(pVecFFTTrial).^2)*dp));plot(pDom,pVecFFTnorm);xlim([-25,25]);xlabel("p")ylabel("\psi(p)")title("\psi(p) on a grid")pPopFFT=abs(pVecFFTTrial).^2;%plot(pDom,pPopFFT)
IsNorm=sum(pPopFFT)*dp %This should be 1, I am getting this to be some other number.
%NewNorm=std(pVecFFTTrial)
pExpect=pPopFFT.*pDom;expectP=sum(pExpect)*dp %This should be close to 0
%plot(pDom,pExpect)
pExpectSquare=pPopFFT.*(pDom.^2); %This should be close to 0.5
Best Answer