I am trying to understand how the fft
and ifft
functions work in python. I made a simple example of an imaginary odd function to compute the inverse Fourier transform in the hopes of getting a real odd function (as should be the case). Below is my code:
v = np.array([-1,-2,0,2,1]) * 1j
t = [-2,-1,0,1,2]
V = ifft(fftshift(v))
Clearly, the function sampled by v
is an odd imaginary function, so when I compute the inverse Fourier Transform and after shifting, I should get a real odd function. But this is not the case. What am I misunderstanding about the Fourier Transform? Thanks!
Theorem 5.6 The Fourier transform of an odd function is odd. dt. = −F(−s). The Fourier transform of the even part (of a real function) is real (Theorem 5.3):
Compute the one-dimensional inverse discrete Fourier Transform. This function computes the inverse of the one-dimensional n-point discrete Fourier transform computed by fft . In other words, ifft(fft(a)) == a to within numerical accuracy.
Compute the 2-dimensional discrete Fourier Transform. This function computes the n-dimensional discrete Fourier Transform over any axes in an M-dimensional array by means of the Fast Fourier Transform (FFT). By default, the transform is computed over the last two axes of the input array, i.e., a 2-dimensional FFT.
Since ⟨δ,f⟩=f(0) (this is the definition of δ), the unitary inverse Fourier transform of the Dirac delta is a distribution which, given a function f, evaluates the Fourier transform of f at zero. In other words, ⟨F−1(δ),f⟩=1√2π∫∞−∞f(x)dx.
You need ifftshift
where you use fftshift
and fftshift
at the very end:
>>> w = fftshift(ifft(ifftshift(v)))
>>>
>>> np.allclose(w, w.real)
True
>>> np.allclose(w, -w[::-1])
True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With