Python Inverse Fourier Transform of Imaginary Odd Function
Asked Answered
A

1

6

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!

Arbitration answered 4/3, 2019 at 3:53 Comment(0)
P
4

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
Platinum answered 4/3, 2019 at 4:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.