Reputation: 11
I am trying to compute for the Fourier Transform but keep on getting TypeError: Cannot convert complex to float.
def x(t, k):
return np.exp(-k * t**2) * sy.sin(k*t) * t**4
def get_x_FT(x, f, k):
x_FT_integrand_real = lambda t: np.real(x(t, k)*np.exp(-2*np.pi*1j*f*t))
x_FT_integrand_comp = lambda t: np.imag(x(t, k)*np.exp(-2*np.pi*1j*f*t))
x_FT_real = quad(x_FT_integrand_real, -np.inf, np.inf)[0]
x_FT_comp = quad(x_FT_integrand_comp, -np.inf, np.inf)[0]
return x_FT_real + 1j*x_FT_comp
f = np.linspace(-4, 4, 100)
x_FT = np.vectorize(get_x_FT)(x, f, k=2)
the problem arises in the vectorization part. Pls help me by pointing out where i went wrong or tell me how i could resolve this :)))
Upvotes: 0
Views: 36