I need to perform the following integral ($i^2 = -1$) (with a fixed value of $m$):

$ \int_{\phi=0}^{\phi=2\pi} \psi(\phi) e^{-im \phi} \hspace{0.7mm} d\phi $

for all values of $m$ in $\{-N_{\theta}, -N_{\theta}+1, ..., 0, 1, ..., N_{\theta}-1, N_{\theta} \}$, that would be $2N_{\theta} + 1$ naive calculations of the above integral (plug $m$ into the formula and use Riemann sums, for example), each time with a different value of $m$. $N_{\theta}$ is an integer $> 0$.

I recognize the above as a Fourier Transform from $\phi$ to $m$.

How could I use the DFT (i.e. scipy's FFT implementation) to help me perform the integral above?

[ I have the function $\psi$ evaluated at equidistant points $\phi_j$ for $j \in \{0, 1, ..., 2N_{\theta} \}$ in memory. ]

My problem is that reading the scipy's documentation, it outputs a result of the form: $ I(m_x) = \sum_{j=0}^{j=M-1} \psi(\phi_j) \hspace{0.8mm} e^{-i \frac{2\pi x}{M} j} $, with $x \in \{ 0, 1, ..., M-1 \}$, thus I cannot get results for $m_x = - 20$ or $m_x = -15$ or any other negative value of $m_x$, because $x$ is $\geq 0$ in the scipy's implementation. I define $m_x = \frac{2\pi x}{M\Delta_{\phi}}$

Am I missing something obvious?

Thank you!


1 Answer 1


Am I missing something obvious?

Yes. The FFT implements the DFT (Discrete Fourier Transform) which is periodic in both time and frequency. So we simply have $X(-k) = X(N-k)$ or more generally $X(-k) = X(mN-k), m \in \mathbb{Z}$, where $N$ is the FFT length.

Whether the approximation will be any good or not depends a lot on how exactly the continuous function is being sampled.

  • $\begingroup$ thank you, got it. $\endgroup$
    – velenos14
    Aug 18, 2022 at 12:32
  • $\begingroup$ the more general equality you wrote does not agree with the first equality you wrote, for any m value? probably a typo $\endgroup$
    – velenos14
    Aug 18, 2022 at 12:51
  • $\begingroup$ Yes. Good catch, I'll fix it $\endgroup$
    – Hilmar
    Aug 18, 2022 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.