Solarflare0
Solarflare0

Reputation: 283

Python Inverse Fourier Transform of Imaginary Odd Function

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!

Upvotes: 6

Views: 374

Answers (1)

Paul Panzer
Paul Panzer

Reputation: 53089

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

Upvotes: 4

Related Questions