1

I am trying to get the Fourier transform of a simple Gaussian function centered at zero. When I FT the positive (or negative) half of the function, I get the expected Gaussian transform, but when I try to FT the symmetric (even) Gaussian, I get strange rapid oscillations in the real and imaginary parts that form a Gaussian envelope. Why am I seeing this? I see this with any symmetric function, by the way, not just a Gaussian. Ideally, the imaginary part should be zero since the function is even, but I see rapid oscillations. What's going on?

import numpy as np
import matplotlib.pyplot as plt
import scipy.fft as sfft


def gaussian(t, sigma):
    return np.exp(-0.5 * (t**2 / sigma**2))


N = 10000
t = np.array([i for i in range(N)])
fx = [gaussian(t[i], 1000) for i in range(N)]

# t_rev = -t[::-1][:-1]
# t = np.array(list(t_rev) + list(t))
fx_rev = fx[::-1][:-1]
fx = list(fx_rev) + list(fx)

ft = np.fft.fftshift(sfft.fft(fx))

plt.plot(fx)
plt.show()
plt.plot(ft.real)
plt.plot(ft.imag)
plt.show()

result has rapid sinusoidal oscillations

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264

0 Answers0