Inverse Fourier Transform (IDFT, IFFT)❓

How the inverse Fourier transform turns amplitudes over frequency back into samples over time - the inverse discrete Fourier transform (IDFT) that defines it, the inverse fast Fourier transform (IFFT) that computes it fast, and the five things that decide what comes out.

Contents
  1. What is the inverse Fourier transform: what time signal does this spectrum make
  2. Methods
    1. IDFT (direct sum)
    2. IFFT (the forward FFT reused)
  3. Which one should you pick
  4. Key ideas
    1. Round trip: FFT, then IFFT, returns the samples
    2. Scaling: where the 1/N sits
    3. Conjugate symmetry: mirror a one-sided spectrum first
    4. Phase: same amplitudes, a different signal
    5. Zero-padding the spectrum: a finer time grid
  5. REFs

What is the inverse Fourier transform: what time signal does this spectrum make

You have a spectrum - a list of frequencies, each with an amplitude and a phase. It may be the output of an FFT, a spectrum you edited to remove a tone, or a specification written as "1 Hz at 1.0, 3 Hz at 0.5". The question this page answers is the reverse of the Fourier transform's: what signal over time does this spectrum make?

The inverse Fourier transform builds that signal. Every frequency in the spectrum becomes one wave - its height set by the amplitude, its starting point set by the phase - and the waves are added sample by sample. Nothing is estimated: if the spectrum came from an FFT, the samples come back exactly (Fig 1).

The same data twice: on the left bars of 1.00 at 1 Hz and 0.50 at 3 Hz, an arrow labelled inverse transform, and on the right 16 samples over one second

Fig 1. From frequency to time: the same data before and after the inverse transform

Take an example: the spectrum the Fourier transform page found in its own data. Sixteen bins, one second of record, so bin $k$ sits at $k$ Hz. Two of them are non-zero: 1.0 at 1 Hz and 0.5 at 3 Hz, both with phase $-\pi/2$ (Table 1).

bin kf (Hz)amplitudephase (rad)
000.000
111.00−1.5708
220.000
330.50−1.5708
440.000
550.000
660.000
770.000
880.000

Table 1. The example: a one-sided spectrum, bins 0 to N/2 for N = 16

The bold rows are the two tones. A phase of $-\pi/2$ is a quarter turn behind a cosine, which is exactly a sine. Chart 1 draws the same table.

Amplitude per bin: a bar of 1.00 at bin 1 and 0.50 at bin 3, each marked phase minus pi over 2, zero elsewhere

Chart 1. The spectrum of Table 1: amplitude per bin, phase above each bar

And Chart 2 is the signal it makes: the two waves, and their sum at every one of the 16 samples. The sum is the signal of the Fourier transform page's Table 1, to within $3 \times 10^{-15}$ - floating-point round-off and nothing else.

The 1 Hz and 3 Hz cosines dashed, and their sum solid with all 16 samples marked

Chart 2. The signal Table 1 makes: the two waves and their sum at every sample

Getting from Chart 1 to Chart 2 is the whole job. The rest of this page is how it is done, how to do it fast, and the five things that decide what comes out.

Methods

Two routes, one answer. The IDFT is the definition, computed term by term. The IFFT is the forward FFT used a second time, with two sign flips and a division. On this data they agree to within $5 \times 10^{-15}$.

IDFT (direct sum)

In plain words. For every sample you want, go through the spectrum bin by bin: make that bin's wave, read its value at this sample, and add it to the total. The total is the sample.

Basic idea. With $N$ complex bins $Y_0, \dots, Y_{N-1}$, the inverse discrete Fourier transform gives each sample $y_n$ (Math 1). It is the forward DFT with the sign of the exponent flipped and a $1/N$ in front:

$$y_n = \frac{1}{N}\sum_{k=0}^{N-1} Y_k\, e^{+2\pi i k n / N}, \qquad n = 0, \dots, N-1$$

Math 1.

Math 1 wants all $N$ complex bins. Table 1 gives only bins 0 to $N/2$, as an amplitude $A_k$ and a phase $\varphi_k$. Each one becomes a complex bin, and the upper half is filled in as the mirror - the complex conjugate - of the lower half (Math 2):

$$Y_0 = N A_0, \qquad Y_k = \tfrac{N}{2} A_k\, e^{i\varphi_k}, \qquad Y_{N-k} = \overline{Y_k}, \qquad Y_{N/2} = N A_{N/2}$$

Math 2.

The $N/2$ undoes the doubling the Fourier transform page applied to a one-sided spectrum, so a bin reading $A$ becomes a wave of height $A$. On the example (Math 3):

$$Y_1 = 8\,e^{-i\pi/2} = -8i, \qquad Y_{15} = 8i, \qquad Y_3 = 4\,e^{-i\pi/2} = -4i, \qquad Y_{13} = 4i$$

Math 3.

With the mirror in place, each pair $Y_k$, $Y_{N-k}$ adds up to one real cosine, and Math 1 becomes a plain sum of cosines (Math 4):

$$y_n = A_0 + \sum_{k=1}^{N/2} A_k \cos\!\left(\frac{2\pi k n}{N} + \varphi_k\right)$$

Math 4.

Here is one sample by hand: $n = 2$, at $t = 0.125$ s. Only bins 1 and 3 are non-zero (Math 5):

$$\begin{aligned} y_2 &= 1.0 \cos\!\left(\tfrac{2\pi \cdot 1 \cdot 2}{16} - \tfrac{\pi}{2}\right) + 0.5 \cos\!\left(\tfrac{2\pi \cdot 3 \cdot 2}{16} - \tfrac{\pi}{2}\right) \\ &= 1.0 \cos(-45°) + 0.5 \cos(45°) \\ &= 0.707 + 0.354 = 1.061 \end{aligned}$$

Math 5.

1.061 is row 2 of the Fourier transform page's Table 1. The other 15 samples work the same way (Table 2).

nt (s)y
00.00000.000
10.06250.845
20.12501.061
30.18750.733
40.25000.500
50.31250.733
60.37501.061
70.43750.845
80.50000.000
90.5625-0.845
100.6250-1.061
110.6875-0.733
120.7500-0.500
130.8125-0.733
140.8750-1.061
150.9375-0.845

Table 2. The rebuilt signal: all 16 samples, plotted in Chart 2

Important characteristics. Each of the $N$ samples needs a sum over all $N$ bins, so the IDFT costs $N^2$ complex multiplications - the same as the forward DFT.

Advantages

Disadvantages

IFFT (the forward FFT reused)

In plain words.

No separate inverse algorithm is needed: the fast FFT does all the work (Fig 2).

spectrum Y
    ↓
conjugate every bin
    ↓
forward FFT
    ↓
conjugate again, divide by N
    ↓
signal y

Fig 2. The IFFT as the forward FFT reused

Basic idea. Conjugating flips the sign of $i$. The forward FFT multiplies by $e^{-2\pi i k n/N}$; with the spectrum conjugated before and the result conjugated after, that sign comes out as the $+$ Math 1 needs (Math 6):

$$y_n = \frac{1}{N}\,\overline{\sum_{k=0}^{N-1} \overline{Y_k}\, e^{-2\pi i k n / N}} = \frac{1}{N}\sum_{k=0}^{N-1} Y_k\, e^{+2\pi i k n / N}$$

Math 6.

On the example, this route gives Table 2 again: the largest difference from the direct IDFT is $5 \times 10^{-15}$.

Important characteristics. The work is one forward FFT, so the cost is $\tfrac{N}{2}\log_2 N$ complex multiplications. The two conjugations and the division are $N$ cheap steps each.

Advantages

Disadvantages

Which one should you pick

For real data, the IFFT - the saving is the same as the forward one (Table 3).

NIDFT: $N^2$IFFT: $\tfrac{N}{2}\log_2 N$
1625632
1,0241,048,5765,120
65,5364,294,967,296524,288

Table 3. Cost in complex multiplications

The IDFT earns its place when you are learning what the inverse does, and when you need a few samples rather than the whole record. That is why the basic calculator runs an IDFT in your browser, and the advanced calculator offers the IFFT.

Key ideas

The inverse itself is exact. What decides the result is what you feed it - five things, each a common way to get a wrong signal from a right spectrum.

Round trip: FFT, then IFFT, returns the samples

Round trip - take samples, transform them, invert the result. You get the samples back, to round-off (Table 4):

Nlargest |IFFT(FFT(y)) − y|
162.2 × 10⁻¹⁶
1,0001.3 × 10⁻¹⁵
1,0249.3 × 10⁻¹⁶

Table 4. Round trip on random data

That is the reason to edit a signal in the frequency domain: transform, change some bins, invert. Every bin left alone comes back untouched.

Scaling: where the 1/N sits

Scaling convention - the forward and inverse transforms together must divide by $N$ once. $N$ is the number of samples, which is also the number of bins in the full spectrum. In the example $N = 16$: one second at 16 samples per second gives 16 samples, and its full spectrum has 16 bins (Table 1 shows the 9 of them from 0 to $N/2$). So the inverse divides by 16 (Math 1); forget it and every sample comes back 16 times too big.

Libraries disagree on where the division goes: NumPy and SciPy put the whole $1/N$ on the inverse, the "ortho" convention puts $1/\sqrt{N}$ on each side. Mix two conventions and the signal comes back the wrong size (Table 5):

what was donepeak of the example
NumPy default: $1/N$ on the inverse1.0607 (correct)
$1/N$ forgotten16.9706 (16×)
NumPy's spectrum inverted with "ortho" scaling4.2426 (4×)

Table 5. One spectrum, three scalings

A result off by exactly $N$ or $\sqrt{N}$ is a scaling mismatch, never a wrong spectrum. The calculators on this site read amplitudes in the Fourier transform page's scale (Math 2), so its output inverts here unchanged.

Conjugate symmetry: mirror a one-sided spectrum first

Conjugate symmetry - a real signal has a spectrum whose upper half is the mirror of the lower: each upper bin is the complex conjugate of its partner, $Y_{N-k} = \overline{Y_k}$. Feed only the lower half to the inverse, with zeros above, and the result is complex (Chart 3):

The true signal dashed; the real part of the unmirrored inverse at half its height in red; a non-zero imaginary part in green

Chart 3. The example inverted without the mirror: half-height real part, a spurious imaginary part

The real part is exactly half the true signal, and the imaginary part reaches 0.75. Neither is a fault of the inverse: half the spectrum was missing. One-sided input - the usual output of a spectrum analyser or of the Fourier transform page - is mirrored first, as in Math 2.

Phase: same amplitudes, a different signal

Phase - where in its cycle each wave starts. Amplitudes alone do not fix the signal. Chart 4 keeps Table 1's amplitudes and changes only the two phases:

Three signals over one second with the same amplitudes and different phases: the example in blue, phases zero in red with a peak of 1.5, and phases zero and pi in green

Chart 4. Table 1's amplitudes with three phase sets

Three different signals. With both phases 0 the two peaks line up and the signal reaches 1.5; the example's phases keep it to 1.0758. A spectrum given as amplitudes only - a magnitude plot, a datasheet curve - cannot be inverted to the one signal it came from. The phase has to be known too.

Zero-padding the spectrum: a finer time grid

Zero-padding - add bins of zero above the highest frequency, then invert. The record length stays one second, but there are more samples in it: 64 bins give 64 samples, four times finer (Math 7, Chart 5). Every bin keeps its value, scaled by $M/N$ so the amplitudes stay the same:

$$Y'_k = \frac{M}{N}\,Y_k \ \text{ for the } N \text{ original bins}, \qquad Y'_k = 0 \ \text{ for the } M - N \text{ new ones}$$

Math 7.

The 16 original samples as black dots and the 64-sample signal from the padded spectrum as a blue line passing through every one of them

Chart 5. The example padded from 16 to 64 bins: four times the samples, the same signal

Every fourth new sample equals an original one, to $2 \times 10^{-14}$, and the rest fall on the true curve between them. It is interpolation that adds no new frequency - exact for a signal like this one, whose tones sit on the bins. For other ways to fill in between samples, see the interpolation page.

REFs

Fourier Transform (DFT, FFT): What Frequencies Are in My Data? - the forward half of this page Wikipedia, Discrete Fourier transform - inverse transform NumPy numpy.fft - normalization modes SciPy scipy.fft J. O. Smith, Mathematics of the Discrete Fourier Transform (DFT)