7.2. The Inverse DFT#

Generalizing the strategy used in the previous section’s example, we get the following definition for an inverse Discrete Fourier Transform (IDFT).

Definition 7.1 (The Inverse DFT)

Let x[n] be an arbitrary signal of N samples, and let X[m] be its DFT. The inverse DFT (IDFT) is defined as

(7.1)#x[n]=1Nm=0N1X[m]e+2πjmNn

Intuitively, this says that the nth sample of the signal x[n] can be recovered by averaging the nth samples of all DFT sinusoids.

Before proving the correctness of this definition, we should highlight the three key ways that it differs from the forward DFT defined by equation (5.12):

  1. There is a global scaling of 1/N;

  2. The sign of the complex exponent is flipped: positive for inverse transform, negative for the forward transform;

  3. The summation ranges over m (frequencies), rather than n (samples). Note that the number of frequencies (and samples) is still N, so the summation still ranges from m=0 to m=N1.

The proof of DFT invertibility makes no assumptions about x[n], apart from its duration (N).

Proof. Plugging in the definition of the DFT X[m] (but using sample index n to avoid confusion with n), we get the following:

1Nm=0N1X[m]e+2πjmNn=1Nm=0N1(n=0N1x[n]e2πjmNn)e+2πjmNnDFT definition for X[m]=1Nn=0N1x[n]m=0N1e2πjmNne+2πjmNnRearranging summation=1Nn=0N1x[n]m=0N1e2πjmNn+2πjmNneaeb=ea+b=1Nn=0N1x[n]m=0N1e2πjnnNm

Now, there are two cases to consider. If n=n, then the inner summation simplifies:

m=0N1e2πjnnNm=m=0N1e2πj0Nm=m=0N11=Nif n=n.

If nn, then the inner summation cancels totals to zero. This is because n and n are both integers, and we can use the result of Section 5.7, except now with nn taking the place of the frequency index, and m taking the place of the sample position:

m=0N1e2πjnnNm=0 if nn0.

The entire summation, therefore, has N1 terms contributing 0 and one term contributing x[n]N. Combining these cases, we can finish the derivation above:

1Nn=0N1x[n]m=0N1e2πjnnNm=1Nx[n]N=x[n].

This is exactly what we needed to show: the nth sample is recovered exactly.

7.2.1. The IDFT in practice#

Like the forward DFT, the inverse DFT (IDFT) is implemented by most signal processing packages.

In Python, we have two ways to invert a DFT, depending on whether we have the full spectrum or only the real part:

# Full spectrum, all N analysis frequencies
X = np.fft.fft(x)

# Full inverse, should produce x_inv == x
x_inv = np.fft.ifft(X)

# Real-part only, 1 + N//2 analysis frequencies
Xr = np.fft.rfft(x)

# Real-part inverse, again produces x_inv == x
x_inv = np.fft.irfft(Xr)

7.2.2. Discussion#

Nowhere in the proof of the inverse DFT did we assume anything about the signal contents x[n]: it works for any signal x. The entire derivation relies on the definition of the forward transform coefficients X[m], and a couple of observations about summing complex sinusoids. So what does this actually tell us about the DFT?

The inverse DFT gives us an alternative representation of signals: every signal x[n] can be uniquely represented as a combination of sinusoids:

  • The summation in the inverse DFT m=0N1 represents the “combination”;

  • The coefficient X[m] encodes the amplitude and phase of the mth sinusoid;

  • The complex exponential e2πjmn/N represents the mth sinusoid itself.

Up until this point, we’ve occasionally had to assume that such a representation exists. But now we’ve proven that it exists.

Aside from analysis and theoretical properties, the inverse DFT gives us tools to modify signals. Rather than operating on individual samples, we can alter the DFT coefficients to produce desired effects, and then take the inverse DFT to recover the time-domain signal. We’ll have more to say about the frequency domain view of filtering in later chapters, but in the next section, we’ll see how to use this insight for synthesizing signals directly.