Hello Ori,
The problem stems from the following, where I am using t and f rather than x and k (see comment). For an fft, once you have a time array with a certain spacing delt, then you are not free to pick the frequency array arbitrarily. For an n-point fft, the freq array spacing, fdelt, must obey the golden rule for ffts (see code below). So you can't use t (or v) for both the time and frequency arrays. It turns out that in this case with the chosen parameters, delf differs from what it should be by a factor of approximately 2, leading to the factor of 4 that you appear to be off by. Once the frequency array is fixed up, the gaussians agree.
Note the use of ifftshift instead of fftshift in one spot in the code. Ifftshift and fftshift are not the same when n is odd
Comment -- on the Mathworld site I think they are using very poor notation. In configuration space vs momentum space, the the fourier transform exponential is usually denoted as exp(ikx), where k is the wave number, 2pi / lambda . They have exp(2pi ikx) which means that now k represents 1/lambda. Admittedly there is not a well accepted variable name for 1/lambda. I tend to call it ilam for lack of something better. (Spectroscopists use inverse centimeters cm^-1, but that is unit-dependent). To avoid confusion I will use time and frequency instead, where the exponential exp(2pi i f t) is unambiguous.
delt = .01;
t = -100:delt:100;
n = numel(t);
gt = exp(-pi*t.^2);
gf = fftshift(fft(ifftshift(gt)));
delf = 1/(n*delt);
n2 = (n-1)/2;
f = delf*(-n2:n2);
figure(1)
subplot(2,1,1)
plot(t,gt)
xlim([-4 4])
subplot(2,1,2)
plot(f,real(gf))
xlim([-4,4])
0 Comments
Sign in to comment.