8.6 The inverse DFT#
The DFT is invertible via the inverse DFT (\(\texttt{IDFT}\)), in a manner that does not cause any distortion of the original signal: \(x = \texttt{IDFT}(\texttt{DFT}(x))\). Because the round trip is exact, we can move freely between the time and frequency domains, editing a sound in whichever domain is more convenient and transforming back.
Given the \(N\) frequency-domain coefficients from the \(\texttt{DFT}\), the \(\texttt{IDFT}\) reconstructs the original \(N\) time-domain samples exactly:
Definition 25 (Inverse discrete Fourier transform)
The inverse discrete Fourier transform of a length-\(N\) spectrum \(X[k]\) is the length-\(N\) signal
Applied to a spectrum \(X = \texttt{DFT}(x)\), it recovers the original samples exactly: \(\texttt{IDFT}(\texttt{DFT}(x)) = x\).
The formula mirrors the forward transform, with two differences: the sign in the exponent flips (the phasors rotate the other way), and a factor of \(1/N\) normalizes the result. Conceptually, this is additive synthesis: it rebuilds the signal as a sum of the phasors at each bin, weighted by that bin’s DFT coefficient.
Technically, the output of the inverse DFT is complex-valued. However, for real-valued input signals \(x\), the imaginary components of all the DFT bins will perfectly cancel out, leaving the imaginary coefficient of each sample as precisely \(0\).
The inverse transform has the same \(O(N^2)\) structure as the forward one, so it enjoys the same speedup: there is a fast inverse DFT (the inverse FFT, or IFFT, available as np.fft.ifft) that runs the same divide-and-conquer in reverse to invert in \(O(N \log N)\) time. We will make use of this in Chapter 9, where transforming to the frequency domain, multiplying, and transforming back turns out to be a fast way to apply a filter.