The Fast Fourier Transform¶
The fast Fourier transform, abbreviated by FFT, computes the discrete Fourier transform for \(n\) points in time \(O(n \log(n))\).
Time and Frequency Domains¶
Data is often periodic, e.g.: seasonal temperature fluctuations. To fit periodic data, a basis of cosines and sines works well. The problem we solve is an interpolation problem, stated as follows.
Given \((t_i, f_i)\), \(i=0,1,\ldots,n\), compute the coefficients of
so \(y(t)\) fits the data \((t_i, f_i)\) best.
A Fourier series approximation is written as
The Fast Fourier Transform solves the interpolation problem in time \(O(n \log(n))\) for \(n\) data points.
There is excellent software available for computing the FFT. Below is a session with Julia which illustrates the transition from the time to the frequency domain.
using Plots
using FFTW
dt = 0.01
t = 0:dt:4
# amplitudes 3 and 5 at frequencies 4 and 2
y = 3*sin.(4*2*pi*t) + 5*sin.(2*2*pi*t)
plot(t, y, yticks=-7:1:7, label="Amplitude in seconds")
F = fft(y)
n = length(y)/2
amps = abs.(F)/n
freq = [0:79]/(2*n*dt)
plot(freq, amps[1:80], xticks=0:1:20,
label="Frequency (Hz) versus Amplitude")
Observe that the test signal is a linear combination of two sine functions, running at frequencies 4 and 2, and corresponding amplitudes 3 and 5, as can be seen from the definition of \(y(t)\) below:
The Julia code makes two plots, shown in Fig. 29 (the plot of \(y(t)\) in the time domain), and in Fig. 30, which shows the essential characterics of the signal in the frequency domain.

Fig. 29 The plot of \(y(t) = 3 \sin(4 \cdot 2 \pi t) + 5 \sin(2 \cdot 2 \pi t)\).¶

Fig. 30 The plot of the Fourier transform of \(y(t) = 3 \sin(4 \cdot 2 \pi t) + 5 \sin(2 \cdot 2 \pi t)\). Observe the spikes at 2 and 4 (the frequencies) with corresponding heights 3 and 5 (the amplitudes).¶
The Fast Fourier Transform¶
For \(n=4\), consider \(\widehat{\bf x} = \frac{1}{\sqrt{4}} M_4 {\bf x}\), with \(\omega = e^{-i 2 \pi/4}\) and
In Fig. 31 is the corresponding plot of the four roots of unity.

Fig. 31 The four complex roots of unity.¶
Now we introduce the permute and partition operations on the matrix.
Multiplying \(M_4\) with \(P\) swaps columns 2 and 3.
Observe the repeated occurrence of \(M_2\):
The matrix \(D_2\) is obtained via a multiplication with \(\omega\).
Multiplying the second row by \(\omega\) of \(M_2\), via a matrix multiplication:
where \(D_2\) is the multiplier matrix:
Consider flipping signs:
and we have
The butterfly matrix is illustrated in Fig. 32.

Fig. 32 The 2-dimensional butterfly matrix.¶
we rewrite \(M_4 P\) as
The matrix
is called the butterfly matrix. For \(n=4\), the effect of the butterfly matrix \(B_4\) is shown below:
For any \(n\), we apply the recursive factorization
where the partition \(P_n\) reorders the even and odd indexed numbers, with the butterfly matrix
where \(I_{n/2}\) is the identity matrix of dimension \(n/2\), and \(D_{n/2}\) is the diagonal matrix with on its diagonal
To the recurrence \(T(n) \leq 2 T(n/2) + O(n)\), we apply the following theorem:
For the inverse FFT, \(F^{-1}_n = \overline{F}_n\), so
and no extra work is needed.
Filter Design¶
To design filters, we apply the convolution property of the discrete Fourier transform, shown as a diagram in Fig. 33. The inverse discrete Fourier transform (iDFT) applied to the componentwise product \(\widehat{x} \bullet \widehat{y}\) of the discrete Fourier transforms (DFTs) \(\widehat{x}$ and $\widehat{y}\), respectively of \(x\) and \(y\), equals the convolution \(x \star y\).

Fig. 33 The convolution property of the discrete Fourier transform.¶
As the fast Fourier fourier transform of vectors of size \(n\) can be computed in time \(O(n \log(n))\), the \(O(n^2)\) cost of a convolution is reduced to time \(O(n \log(n))\), as illustrated in Fig. 34.

Fig. 34 The FFT reduces the cost of a convolution to \(O(n \log(n))\).¶
Exercises¶
Use your
FourierMatrix
of Exercise 2 of the previous lecture, section 4.1, to compare the outcome of \(F_n {\bf x}\) computed with the \(F_n\) computed with yourFourierMatrix
and the output ofFFTW.fft
.Do the comparison on a random vector \(\bf x\) of size \(n = 8\).
Does the
FFTW.fft
use the normalization factor \(1/\sqrt{n}\)?
Write a Julia function
ButterflyMatrix
which takes on input the dimension \(n\) and which returns the butterfly matrix of dimension \(n\).To verify the decomposition, define a function
mFourierMatrix
that takes on input the dimension \(n\) and which returns the Fourier matrix times \(\sqrt{n}\).For \(n=8\), verify the relationship between
mFourierMatrix
(n) andButterflyMatrix
(n).Generate random vectors for size \(2^k\), for \(k=10, 11, \ldots, 20\).
For each random vector, record the time for
FFTW.fft
.Do you observe the \(O(n \log(n))\) time?
Bibliography¶
Matteo Frigo and Steven G. Johnson: The Design and Implementation of FFTW3. Proc. IEEE 93(2): 216–231, 2005.
Charles R. MacCluer, Chapter 4 of Industrial Mathematics. Modeling in Industry, Science, and Government, Prentice Hall, 2000.
Timothy Sauer, chapter 10 of Numerical Analysis, second edition, Pearson, 2012.