[Python] Mathematical expression of Fourier transform used in numpy.fft.fft

Discussão em 'Python' iniciado por Stack, Setembro 8, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to use numpy.fft.fft to perform discrete Fourier transformation. Normally, Fourier transformation is defined as,

    [​IMG]

    My question is : does numpy.fft.fft also use this formula ?

    If one writes the exponent inside the above integral in terms of sine and cosine and K(s) is taken as an even function, the imaginary part of the above integral vanishes. But in my case, I am using an even function and still the imaginary part comes out to be non-vanishing. That's why I am asking the above question.

    I am giving a code example here taking K(s) = cos(s).

    In [2]: import numpy as np

    In [3]: import matplotlib.pyplot as plt

    In [4]: import cmath

    In [5]: s = np.linspace(-10,10,10000)

    In [6]: s
    Out[6]:
    array([-10. , -9.9979998, -9.9959996, ..., 9.9959996,
    9.9979998, 10. ])

    In [7]: f = np.cos(s)

    In [8]: f_t = np.fft.fft(f)

    In [9]: f_t.imag
    Out[9]:
    array([ 0. , -0.18989373, -0.56552844, ..., 4.58808084,
    0.56552844, 0.18989373])

    Continue reading...

Compartilhe esta Página