Currently there may be errors shown on top of a page, because of a missing Wiki update (PHP version and extension DPL3). |

**Navigation**

Topics | Help • Register • News • History • How to • Sequences statistics • Template prototypes |

# Fast Fourier transform

A **fast Fourier transform** (**FFT**) is an efficient algorithm to compute the discrete Fourier transform (DFT) and its inverse. FFTs are of great importance to a wide variety of applications, from digital signal processing to solving partial differential equations to algorithms for quickly multiplying large integers. This article describes the algorithms, of which there are many; see discrete Fourier transform for properties and applications of the transform.

Let *x*_{0}, ...., *x*_{n-1} be complex numbers. The DFT is defined by the formula

- [math]\displaystyle{ \large f_j = \sum_{k=0}^{n-1} x_k e^{-{2\pi i \over n} jk } \qquad j = 0, ... ,n-1. }[/math]

Evaluating these sums directly would take O(*n*^{2}) arithmetical operations . An FFT is an algorithm to compute the same result in only O(*n* log *n*) operations. In general, such algorithms depend upon the factorization of *n*, but (contrary to popular misconception) there are O(*n* log *n*) FFTs for all *n*, even prime *n*.

Since the inverse DFT is the same as the DFT, but with the opposite sign in the exponent and a 1/*n* factor, any FFT algorithm can easily be adapted for it as well.

## Contents

## The Cooley-Tukey algorithm

By far the most common FFT is the Cooley-Tukey algorithm. This is a divide and conquer algorithm that recursively breaks down a DFT of any composite size *n* = *n*_{1}*n*_{2} into many smaller DFTs of sizes *n*_{1} and *n*_{2}, along with O(*n*) multiplications by complex roots of unity traditionally called **twiddle factors**.

This method (and the general idea of an FFT) was popularized by a publication of J. W. Cooley and J. W. Tukey in 1965, but it was later discovered that those two authors had independently re-invented an algorithm known to Carl Friedrich Gauss around 1805 (and subsequently rediscovered several times in limited forms).

The most well-known use of the Cooley-Tukey algorithm is to divide the transform into two pieces of size [math]\displaystyle{ n / 2 }[/math] at each step, and is therefore limited to power-of-two sizes, but any factorization can be used in general (as was known to both Gauss and Cooley/Tukey). These are called the **radix-2** and **mixed-radix** cases, respectively (and other variants have their own names as well). Although the basic idea is recursive, most traditional implementations rearrange the algorithm to avoid explicit recursion. Also, because the Cooley-Tukey algorithm breaks the DFT into smaller DFTs, it can be combined arbitrarily with any other algorithm for the DFT, such as those described below.

## Other FFT algorithms

*Wikipedia articles*

There are other FFT algorithms distinct from Cooley-Tukey. For [math]\displaystyle{ n = n_1n_2 }[/math] with coprime [math]\displaystyle{ n_1 }[/math] and [math]\displaystyle{ n_2 }[/math], one can use the Prime-Factor (Good-Thomas) algorithm (PFA), based on the Chinese Remainder Theorem, to factorize the DFT similarly to Cooley-Tukey but without the twiddle factors. The Rader-Brenner algorithm is a Cooley-Tukey-like factorization but with purely imaginary twiddle factors, reducing multiplications at the cost of increased additions and reduced numerical stability. Algorithms that recursively factorize the DFT into smaller operations other than DFTs include the Bruun and QFT algorithms. (The Rader-Brenner and QFT algorithms were proposed for power-of-two sizes, but it is possible that they could be adapted to general composite [math]\displaystyle{ n }[/math]. Bruun's algorithm applies to arbitrary even composite sizes.) Bruun's algorithm, in particular, is based on interpreting the FFT as a recursive factorization of the polynomial [math]\displaystyle{ z^n-1 }[/math], here into real-coefficient polynomials of the form [math]\displaystyle{ z^m-1 }[/math] and [math]\displaystyle{ z^{2m} + az^m + 1 }[/math]. Another polynomial viewpoint is exploited by the Winograd algorithm, which factorizes [math]\displaystyle{ z^n-1 }[/math] into cyclotomic polynomials; these often have coefficients of 1, 0, or −1, and therefore require few (if any) multiplications, so Winograd can be used to obtain minimal-multiplication FFTs and is often used to find efficient algorithms for small factors. Indeed, Winograd showed that the DFT can be computed with only [math]\displaystyle{ O(n) }[/math] multiplications, leading to a proven achievable lower bound on the number of irrational multiplications for power-of-two sizes; unfortunately, this comes at the cost of many more additions, a tradeoff no longer favorable on modern processors with hardware multipliers. In particular, Winograd also makes use of the PFA as well as an algorithm by Rader for FFTs of *prime* sizes. Rader's algorithm, exploiting the existence of a generator for the multiplicative group modulo prime [math]\displaystyle{ n }[/math], expresses a DFT of prime size [math]\displaystyle{ n }[/math] as a cyclic convolution of (composite) size [math]\displaystyle{ n-1 }[/math], which can then be computed by a pair of ordinary FFTs via the convolution theorem (although Winograd uses other convolution methods). Another prime-size FFT is due to L. I. Bluestein, and is sometimes called the chirp-z algorithm; it also re-expresses a DFT as a convolution, but this time of the *same* size (which can be zero-padded to a power of two and evaluated by radix-2 Cooley-Tukey FFTs, for example), via the identity [math]\displaystyle{ jk = -(j-k)^2/2 + j^2/2 + k^2/2 }[/math].

## FFT algorithms specialized for real and/or symmetric data

In many applications, the input data for the DFT are purely real, in which case the outputs satisfy the symmetry

- [math]\displaystyle{ f_{n-j} = f_j^*, }[/math]

and efficient FFT algorithms have been designed for this situation (see e.g. Sorensen, 1987). One approach consists of taking an ordinary algorithm (e.g. Cooley-Tukey) and removing the redundant parts of the computation, saving roughly a factor of two in time and memory. Alternatively, it is possible to express an *even*-length real-input DFT as a complex DFT of half the length (whose real and imaginary parts are the even/odd elements of the original real data), followed by O(*n*) post-processing operations.

It was once believed that real-input DFTs could be more efficiently computed by means of the Discrete Hartley transform (DHT), but it was subsequently argued that a specialized real-input DFT algorithm (FFT) can typically be found that requires fewer operations than the corresponding DHT algorithm (FHT) for the same number of inputs. Bruun's algorithm (above) is another method that was initially proposed to take advantage of real inputs, but it has not proved popular.

There are further FFT specializations for the cases of real data that have even/odd symmetry, in which case one can gain another factor of (roughly) two in time and memory and the DFT becomes the discrete cosine/sine transform(s) (DCT/DST). Instead of directly modifying an FFT algorithm for these cases, DCTs/DSTs can also be computed via FFTs of real data combined with O(*n*) pre/post processing.

## Accuracy and approximations

All of the FFT algorithms discussed so far compute the DFT exactly (in exact arithmetic, i.e. neglecting floating-point errors). A few "FFT" algorithms have been proposed, however, that compute the DFT *approximately*, with an error that can be made arbitrarily small at the expense of increased computations. Such algorithms trade the approximation error for increased speed or other properties. For example, an approximate FFT algorithm by Edelman et al. (1999) achieves lower communication requirements for parallel computing with the help of a fast-multipole method. A wavelet-based approximate FFT by Guo and Burrus (1996) takes sparse inputs/outputs (time/frequency localization) into account more efficiently than is possible with an exact FFT. Another algorithm for approximate computation of a subset of the DFT outputs is due to Shentov et al. (1995). Only the Edelman algorithm works equally well for sparse and non-sparse data, however, since it is based on the compressibility (rank deficiency) of the Fourier matrix itself rather than the compressibility (sparsity) of the data.

Even the "exact" FFT algorithms have errors when finite-precision floating-point arithmetic is used, but these errors are typically quite small; most FFT algorithms, e.g. Cooley-Tukey, have excellent numerical properties. The upper bound on the relative error for the Cooley-Tukey algorithm is O(ε log *n*), compared to O(ε *n*^{3/2}) for the naive DFT formula (Gentleman and Sande, 1966), where ε is the machine floating-point relative precision. In fact, the root mean square (rms) errors are much better than these upper bounds, being only O(ε √log *n*) for Cooley-Tukey and O(ε √*n*) for the naive DFT (Schatzman, 1996). These results, however, are very sensitive to the accuracy of the twiddle factors used in the FFT (i.e. the trigonometric function values), and it is not unusual for incautious FFT implementations to have much worse accuracy, e.g. if they use inaccurate trigonometric recurrence formulas. Some FFTs other than Cooley-Tukey, such as the Rader-Brenner algorithm, are intrinsically less stable.

In fixed-point arithmetic, the finite-precision errors accumulated by FFT algorithms are worse, with rms errors growing as O(√*n*) for the Cooley-Tukey algorithm (Oppenheim & Schafer, 1975). Moreover, even achieving this accuracy requires careful attention to scaling in order to minimize the loss of precision, and fixed-point FFT algorithms involve rescaling at each intermediate stage of decompositions like Cooley-Tukey.

To verify the correctness of an FFT implementation, rigorous guarantees can be obtained in O(*n* log *n*) time by a simple procedure checking the linearity, impulse-response, and time-shift properties of the transform on random inputs (Ergün, 1995).

## Multidimensional FFT algorithms

As defined in the multidimensional DFT article, the multidimensional DFT

- [math]\displaystyle{ f_\mathbf{j} = \sum_{\mathbf{k}=0}^{\mathbf{n}-1} e^{-2\pi i \mathbf{j} \cdot (\mathbf{k} / \mathbf{n})} x_\mathbf{k} }[/math]

transforms an array [math]\displaystyle{ x_\mathbf{k} }[/math] with a [math]\displaystyle{ d }[/math]-dimensional vector of indices [math]\displaystyle{ \mathbf{k}=(k_1 = 0 \ldots n_1-1, \cdots, k_d = 0 \ldots n_d-1) }[/math] by a set of [math]\displaystyle{ d }[/math] nested summations. Equivalently, it is simply the composition of a sequence of [math]\displaystyle{ d }[/math] one-dimensional DFTs, performed along one dimension at a time (in any order).

This compositional viewpoint immediately provides the simplest and most common multidimensional DFT algorithm, known as the **row-column** algorithm (after the two-dimensional case, below). That is, one simply performs a sequence of [math]\displaystyle{ d }[/math] one-dimensional FFTs (by any of the above algorithms): first you transform along the [math]\displaystyle{ k_1 }[/math] dimension, then along the [math]\displaystyle{ k_2 }[/math] dimension, and so on (or actually, any ordering will work). This method is easily shown to have the usual [math]\displaystyle{ O(N \log N) }[/math] complexity, where [math]\displaystyle{ N = n_1 n_2 \cdots n_d }[/math] is the total number of data points transformed. In particular, there are [math]\displaystyle{ N/n_1 }[/math] transforms of size [math]\displaystyle{ n_1 }[/math], etcetera, so the complexity of the sequence of FFTs is:

- [math]\displaystyle{ N/n_1 O(n_1 \log n_1) + \cdots + N/n_d O(n_d \log n_d) = O(N [\log n_1 + \cdots + \log n_d]) = O(N \log N). }[/math]

In two dimensions, the [math]\displaystyle{ x_\mathbf{k} }[/math] can be viewed as an [math]\displaystyle{ n_1 \times n_2 }[/math] matrix, and this algorithm corresponds to first performing the FFT of all the rows and then of all the columns (or vice versa), hence the name.

In more than two dimensions, it is often advantageous for cache locality to group the dimensions recursively. For example, a three-dimensional FFT might first perform two-dimensional FFTs of each planar "slice" for each fixed [math]\displaystyle{ k_1 }[/math], and then perform the one-dimensional FFTs along the [math]\displaystyle{ k_1 }[/math] direction. More generally, an (asymptotically) optimal cache-oblivious algorithm consists of recursively dividing the dimensions into two groups [math]\displaystyle{ (k_1, \cdots, k_{d/2}) }[/math] and [math]\displaystyle{ (k_{d/2+1}, \cdots, k_d) }[/math] that are transformed recursively (rounding if [math]\displaystyle{ d }[/math] is not even) (see Frigo and Johnson, 2005). Still, this remains a straightforward variation of the row-column algorithm that ultimately requires only a one-dimensional FFT algorithm as the base case, and still has [math]\displaystyle{ O(N \log N) }[/math] complexity. Yet another variation is to perform matrix transpositions in between transforming subsequent dimensions, so that the transforms operate on contiguous data; this is especially important for out-of-core and distributed memory situations where accessing non-contiguous data is extremely time-consuming.

There are other multidimensional FFT algorithms that are distinct from the row-column algorithm, although all of them have [math]\displaystyle{ O(N \log N) }[/math] complexity. Perhaps the simplest non-row-column FFT is the vector-radix FFT algorithm, which is a generalization of the ordinary Cooley-Tukey algorithm where one divides the transform dimensions by a vector [math]\displaystyle{ \mathbf{r}=(r_1, r_2, \cdots, r_d) }[/math] of radices at each step. (This may also have cache benefits.) The simplest case of vector-radix is where all of the radices are equal (e.g. vector-radix-2 divides *all* of the dimensions by two), but this is not necessary. Vector radix with only a single non-unit radix at a time, i.e. [math]\displaystyle{ \mathbf{r}=(1, \cdots, 1, r, 1, \cdots, 1) }[/math], is essentially a row-column algorithm. Other, more complicated, methods include polynomial transform algorithms due to Nussbaumer (1977), which view the transform in terms of convolutions and polynomials products. See Duhamel and Vetterli (1990) for more information and references.

## References

- James W. Cooley and John W. Tukey, "An algorithm for the machine calculation of complex Fourier series,"
*Math. Comput.***19**, 297-301 (1965). - Carl Friedrich Gauss, "Nachlass: Theoria interpolationis methodo nova tractata,"
*Werke*band**3**, 265–327 (Königliche Gesellschaft der Wissenschaften, Göttingen, 1866). See also M. T. Heideman, D. H. Johnson, and C. S. Burrus, "Gauss and the history of the fast Fourier transform,"*IEEE ASSP Magazine***1**(4), 14-21 (1984). - P. Duhamel and M. Vetterli, "Fast Fourier transforms: a tutorial review and a state of the art,"
*Signal Processing***19**, 259-299 (1990). - W. M. Gentleman and G. Sande, "Fast Fourier transforms—for fun and profit,"
*Proc. AFIPS***29**, 563-578 (1966). - H. Guo, G. A. Sitton, and C. S. Burrus, "The Quick Discrete Fourier Transform,"
*Proc. IEEE Conf. Acoust. Speech and Sig. Processing (ICASSP)***3**, 445-448 (1994). - H. V. Sorensen, D. L. Jones, M. T. Heideman, and C. S. Burrus, "Real-valued fast Fourier transform algorithms,"
*IEEE Trans. Acoust. Speech Sig. Processing***ASSP-35**, 849-863 (1987). - A. Edelman, P. McCorquodale, and S. Toledo, "The future fast Fourier transform?"
*SIAM J. Sci. Computing***20**, 1094-1114 (1999). - H. Guo and C. S. Burrus, "Fast approximate Fourier transform via wavelets transform,\
*Proc. SPIE Intl. Soc. Opt. Eng.***2825**, 250-259 (1996). - O. V. Shentov, S. K. Mitra, U. Heute, and A. N. Hossen, "Subband DFT. I. Definition, interpretations and extensions,"
*Signal Processing***41**(3), 261-277 (1995). - James C. Schatzman, "Accuracy of the discrete Fourier transform and the fast Fourier transform,"
*SIAM J. Sci. Comput.***17**(5), 1150-1166 (1996). - A. V. Oppenheim and R. Schafer, "Digital Signal Processing" (Englewood Cliffs, NJ: Prentice-Hall, 1975).
- Funda Ergün, "Testing multivariate linear functions: Overcoming the generator bottleneck,"
*Proc. 27th ACM Symposium on the Theory of Computing*, 407-416 (1995). - H. J. Nussbaumer, "Digital filtering using polynomial transforms,"
*Electronics Lett.***13**(13), 386-387 (1977). - Matteo Frigo and Steven G. Johnson:
*FFTW*, http://www.fftw.org/. A free (GPL) C library for computing discrete Fourier transforms in one or more dimensions, of arbitrary size. Also M. Frigo and S. G. Johnson, "The Design and Implementation of FFTW3,"*Proceedings of the IEEE***93**(2), 216-231 (2005).