bundles / scipy 1.17.1 / scipy / fft / _basic / ifft
_Function
scipy.fft._basic:ifft
source: /scipy/fft/_basic.py :171
Signature
def ifft ( x , n = None , axis = -1 , norm = None , overwrite_x = False , workers = None , * , plan = None ) Summary
Compute the 1-D inverse discrete Fourier Transform.
Extended Summary
This function computes the inverse of the 1-D n-point discrete Fourier transform computed by fft. In other words, ifft(fft(x)) == x to within numerical accuracy.
The input should be ordered in the same way as is returned by fft, i.e.,
x[0]should contain the zero frequency term,x[1:n//2]should contain the positive-frequency terms,x[n//2 + 1:]should contain the negative-frequency terms, in increasing order starting from the most negative frequency.
For an even number of input points, x[n//2] represents the sum of the values at the positive and negative Nyquist frequencies, as the two are aliased together. See fft for details.
Parameters
x: array_likeInput array, can be complex.
n: int, optionalLength of the transformed axis of the output. If
nis smaller than the length of the input, the input is cropped. If it is larger, the input is padded with zeros. Ifnis not given, the length of the input along the axis specified byaxisis used. See notes about padding issues.axis: int, optionalAxis over which to compute the inverse DFT. If not given, the last axis is used.
norm: {"backward", "ortho", "forward"}, optionalNormalization mode (see fft). Default is "backward".
overwrite_x: bool, optionalIf True, the contents of
xcan be destroyed; the default is False. See fft for more details.workers: int, optionalMaximum number of workers to use for parallel computation. If negative, the value wraps around from
os.cpu_count(). See fft for more details.plan: object, optionalThis argument is reserved for passing in a precomputed plan provided by downstream FFT vendors. It is currently not used in SciPy.
Returns
out: complex ndarrayThe truncated or zero-padded input, transformed along the axis indicated by
axis, or the last one ifaxisis not specified.
Raises
: IndexErrorIf
axesis larger than the last axis ofx.
Notes
If the input parameter n is larger than the size of the input, the input is padded by appending zeros at the end. Even though this is the common approach, it might lead to surprising results. If a different padding is desired, it must be performed before calling ifft.
If x is a 1-D array, then the ifft is equivalent to
y[k] = np.sum(x * np.exp(2j * np.pi * k * np.arange(n)/n)) / len(x)As with fft, ifft has support for all floating point types and is optimized for real input.
Array API Standard Support
ifft has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ✅ PyTorch ✅ ✅ JAX ✅ ✅ Dask ⚠️ computes graph n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
import scipy.fft import numpy as np✓
scipy.fft.ifft([0, 4, 0, 0])
✗import matplotlib.pyplot as plt rng = np.random.default_rng() t = np.arange(400) n = np.zeros((400,), dtype=complex) n[40:60] = np.exp(1j*rng.uniform(0, 2*np.pi, (20,))) s = scipy.fft.ifft(n) plt.plot(t, s.real, 'b-', t, s.imag, 'r--') plt.legend(('real', 'imaginary')) plt.show()✓

See also
- fft
The 1-D (forward) FFT, of which
ifftis the inverse.- ifft2
The 2-D inverse FFT.
- ifftn
The N-D inverse FFT.
Aliases
-
scipy.fft.ifft