I’m trying to implement a function that calculates the inverse Fourier transform of a continuous function F(ω)
to obtain f(x)
.
My input function is continuous (you can assume it is a lambda function) so I have to sample from it to make it discrete. Here’s my current implementation:
import numpy as np
def fourier_inverse(f, n, omega_max):
"""
:param f: The function to be transformed
:param n: Number of samples
:param omega_max: The max frequency we want to be samples
"""
omega_range = np.linspace(-omega_max, omega_max, n)
f_values = f(omega_range, sigma, alpha)
inverse_f = np.fft.ifftshift(np.fft.ifft(np.fft.fftshift(f_values)))
return inverse_f
If more explanation is needed for the code: f is the function,
omega_max is the range of omega I want to sample from, the bigger the
better the quality must be, and n is the number of samples taken from
-omega to +omaga, bigger n means better quality.
However, I have two main concerns:
- The x-axis of the result ranges from 0 to n, which doesn’t seem
correct. I don’t know how to approach it. - I’m unsure if the overall approach is correct, particularly
regarding the sampling and normalization.
Any help or guidance would be greatly appreciated. Thank you!