
5.5 Discrete Fourier Transform 151
Transform (FFT), consider Table 5.4. Here the array dimensions increase by factors of 2,
the second and third columns represent the number of operations for straightforward and
optimized Fourier transforms, while the final column of ratios shows the factor by which
FFT is faster. Note that we have chosen N 2
n
on purpose – the maximum savings are
realized when N is a power of 2. The FFT for even N is still better than the straightforward
algorithm but the advantage is smaller; one should avoid odd or, even worse, prime values
of N for which FFT is no better than the standard algorithm. If your sample set is not a
power of 2, simply pad it with some extra zeros – the computational savings far outweigh
the cost in extra memory and, as we will see below, zero-padding is often useful anyway.
Table 5.4. Scaling of conventional versus fast Fourier transform with sample size.
NN
2
N log
2
N Ratio
512 262 144 4 608 57
1 024 1 048 576 10 240 102
2 048 4 194 304 22 528 186
4 096 16 777 216 49 152 341
8 192 67 108 864 106 496 630
16 384 268 435 456 229 376 1 170
32 768 1 073 741 824 491 520 2 185
The first widely disseminated FFT subroutine was developed by Cooley and Tukey
in the mid-60s and revolutionized numerical signal processing and related fields. Similar
FFT programs are now standard tools for numerical analysis and we assume that you can
find one in whatever computational environment you would use. Since FFT programs are
now so widely available that hardly anyone would consider writing his/her own anymore,
we will not discuss the details of those algorithms here. Useful discussions can be found in
books like Numerical Recipes (W. H. Press, B. P. Flannery, S. A. Teukolsky, and W. T. Vet-
terling, Cambridge University Press).
An important feature of the discrete Fourier transform is its periodicity:
˜
f
Nn
˜
f
n
f
Nn
f
n
(5.162)
However, the discrete Fourier transform is intended to be an approximation of the con-
tinuous Fourier transform that is suitable for numerical computation using computers, yet
the primary motivation for the Fourier transform was its ability to describe nonperiodic
functions. It seems that we have circled back to the Fourier series, but the Fourier series is
capable, at least in principle, of describing continuous functions f t with arbitrary accu-
racy (except at discontinuities) while the discrete Fourier transform represents sampled
quantities, f
i
, instead of continuous functions. On the other hand, arbitrary accuracy is
not really possible numerically because an infinite number of Fourier coefficients would
be needed, not to mention the inevitable truncation errors due to the finite number of bits
available to the digital representation of numbers in a computer. The discrete Fourier trans-
form represents N samples f
j
faithfully, whether they come from a smooth function or not,
except for truncation errors related to machine precision. The price is unwanted periodic-
ity and its effects upon transformations, like convolution, that require knowledge of the