Hello, currently I’m having issues understanding how to perform with success a Fourier Transformation using the fft()
function of the fftw.jl
package.
Let’s pick the step function:
using FFTW, Plots
x = range(-5,stop=5,length=1000)
f = [abs(i) <= 1 ? 1 : 0 for i in x]
When applying a Fourier Transformation to this function we have the following analytic function:
with
a=2
being the width of the rectangle.
Fanalyt = (1/pi)*sinc.(x)
plot(x,Fanalyt)
If I, naively, perform a fourier transformation to f
, I’ll get this wrong solution:
Fnumeric = fftshift(fft(f))
plot(x,real(Fnumeric))
Neither the scale is correct, neither the ‘form’ of the solution.
It’ s easy to properly scale the output of fft()
, if I multiply Fnumeric
by a factor of dx/2pi
, which is the factor that appears in the first order approximation of the F.T., this scales the things down correctly. But i’m still having in incorrect behaviour, as you can see:
dx = x[2]-x[1]
Fnum_scaled = Fnumeric*(dx/(2pi))
maximum(Fanalyt)
maximum(Fnum_scaled)
plot(x,Fnum_scaled)
Does anyone knows why this happens?
Best regards,
Tiago