scipy.fftpack.fft(x, n=None, axis=-1, overwrite_x=0)

Return discrete Fourier transform of arbitrary type sequence x.

Parameters :

x : array-like

array to fourier transform.

n : int, optional

Length of the Fourier transform. If n<x.shape[axis], x is truncated. If n>x.shape[axis], x is zero-padded. (Default n=x.shape[axis]).

axis : int, optional

Axis along which the fft’s are computed. (default=-1)

overwrite_x : bool, optional

If True the contents of x can be destroyed. (default=False)

Returns :

z : complex ndarray

with the elements:

[y(0),y(1),..,y(n/2-1),y(-n/2),...,y(-1)] if n is even [y(0),y(1),..,y((n-1)/2),y(-(n-1)/2),...,y(-1)] if n is odd


y(j) = sum[k=0..n-1] x[k] * exp(-sqrt(-1)*j*k* 2*pi/n), j = 0..n-1

Note that y(-j) = y(n-j).conjugate().

See also

Inverse FFT
FFT of a real sequence


The packing of the result is “standard”: If A = fft(a, n), then A[0] contains the zero-frequency term, A[1:n/2+1] contains the positive-frequency terms, and A[n/2+1:] contains the negative-frequency terms, in order of decreasingly negative frequency. So for an 8-point transform, the frequencies of the result are [ 0, 1, 2, 3, 4, -3, -2, -1].

This is most efficient for n a power of two.


In scipy 0.8.0 fft in single precision is available, but only for input array sizes which can be factorized into (combinations of) 2, 3 and 5. For other sizes the computation will be done in double precision.


>>> x = np.arange(5)
>>> np.all(np.abs(x-fft(ifft(x))<1.e-15) #within numerical accuracy.

Previous topic


Next topic


This Page