Controversy in calculating the Fourier transform of a function numerically and analytically

30 visualizzazioni (ultimi 30 giorni)
Hey,
I am trying to calculate the inverse fourier transform of a complex function numerically. And I am trying to start with calculating the fourier transform of a simple gaussian to make sure my code is correct for simple case. The issue is for a Gaussian function (F = exp(-t^2 / 2*(c^2))), the analytical result for the fourier transform is F.F = 2^(1/2)*pi^(1/2)*exp(-2*c^2*f.^2*pi^2)*abs(c). And it is a real function. But when I calculate the fourier transform numerically using trapz function, the result has both real and imaginary parts (although the imaginary part is too small) but the abs value of the result give the same result as the analytical fourier transform. But for a Gaussian centered at zero there is not an imaginary part in the fourier transform. I don't know why I get this imaginary part when I use the definition of fourier transform directly to calculate fourier transform numerically. Can anyone help why there is a controvercy? I need to know to make sure for my general function it works correctly.
I have copied my code and the imaginary part of the fourier transform plot here.
t=-2:.001:2;
c= 0.5;
x = exp(-t.^2/(2*c^2));
% analytical result of fourier transform
% f=-5:.01:5;
% fourierfunc = 2^(1/2)*pi^(1/2)*exp(-2*c^2*f.^2*pi^2)*abs(c);
% plot(f,fourierfunc)
% numerical result of fourier transform
k=0;
for f=-5:.001:5
k=k+1;
fourierx(k)=trapz(t,x.*exp(-1i*2*pi*f*t));
end
f=-5:.001:5;
plot(f,real(fourierx))

Risposta accettata

Image Analyst
Image Analyst il 10 Set 2022
That's basically quantization noise. Since the computations are done digitally/numerically, not analytically/symbolically, it's hard to make sure you always get exactly zero. If you'd taken a course on linear algebra, numerical analysis, or something similar, they would have covered that.
However here and virtually everywhere in MATLAB if you have values that are around 10^-16 or smaller than your other values, you essentially consider it zero.
  7 Commenti
David Goodmanson
David Goodmanson il 11 Set 2022
Modificato: David Goodmanson il 11 Set 2022
Hi Walter,
I don't believe that the heaviside function has a real fourier transform. As continuous function its transform is
N/(2*pi*i*f)
where N is a real normalization factor depending on which transform convention is used. Going to the fft does not alter that conclusion.
However, any real function, symmetric about the origin, has a real (and symmetric) fourier transform.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by