# An Introduction to the Fast Fourier Transform

8 January 2015

## 1 Introduction

Here is something I wrote a while back while working on the design of anemometers for measuring shear stresses. Part of this work required modelling and compensating for the transfer function of tubing systems. To do this in real time we used TMS320 series DSPs, and I impelemented some large FIR filters using block-floating point FFTs.

This is is a general introduction to the FFT, and also discusses the computation of power spectra and autocorrelation. This document is generated from LaTeX using LaTeXML. Some browsers do not support MathML (ie. Chrome), so the online math display uses MathJax. Conversion is not too bad, though there are some formatting problems eg. with tabbing environments. This PDF version is neater:

## 2 The Discrete Fourier Transform

The Fourier transform allows an arbitrary function to be represented in terms of simple sinusoids. The Fourier transform (FT) of a function $f(t)$ is

 $F(\omega)=\int_{-\infty}^{\infty}f(t)e^{-{\rm i}\omega t}dt$

For this integral to exist, $f$ must be absolutely integrable. That is,

 $\int_{-\infty}^{\infty}~{}|f(t)|dt~{}<~{}\infty$

However, it is possible to express the transforms of functions that are not absolutely integrable (e.g. periodic) using the delta function $\delta$. With this expression of the function, if $f$ is a periodic function with period $T$ then its transform is not continuous in $\omega$ but consists of impulses in the frequency domain separated by $1/T$.

The Discrete Fourier Transform (DFT) is the discrete-time equivalent of the Fourier transform. A function sampled over a finite period of time is defined by a time series { $x(0)$, $x(1)$, …, $x(N-1)$ }. The Discrete Fourier Transform (DFT) of $x(t)$ is

 $X(k)=\sum_{n=0}^{N-1}x(n)e^{-{\rm i}2\pi nk/N},~{}~{}~{}~{}k=0,1,...,N-1$ (1)

For clarity the constant $W$ is defined,

 $W=e^{-{\rm i}2\pi/N}$

then, the sum becomes:

 $X(k)=\sum_{n=0}^{N-1}x(n)W^{nk}$

The comparable inverse function is the Inverse Discrete Fourier Transform (IDFT):

 $x(t)={\frac{1}{N}}\sum_{k=0}^{N-1}X(k)W^{-nk}$

Note that when writing series, lower case letters indicate time-series, and upper case letters denote their transforms.

The DFT is useful whenever a sampled function must be transformed between the time- and frequency-domains. Applications of this sort include:

• Computation of power spectra for sampled signals.

• Frequency-domain design of digital filters.

Intensive research into signal processing algorithms during the 1960s led to the development of a class of very efficient algorithms for the DFT. These Fast Fourier-Transform (FFT) algorithms led to new applications such as:

• Digital filtering (convolution).

• Correlation.

In these applications, the frequency-domain is used as an intermediate stage to make time-domain calculations more efficient.

## 3 The Fast Fourier Transform

The Fast Fourier Transform (or FFT) is a class of efficient algorithms for computing the DFT. FFT algorithms rely on $N$ being composite (ie. non-prime) to eliminate trivial products. Where $N~{}=~{}r_{1}.r_{2}...r_{n}$ the complexity11 When an algorithm has complexity O(n), kn is an upper bound on its run-time, for some constant k. of the FFT is $O(N(r_{1}+r_{2}+...+r_{n}))$. The basic radix-2 algorithm published by Cooley and Tukey (1965) relies on $N$ being a power of 2 and is $O(N{\rm log}_{2}N)$. Other algorithms exist which give better performance. Higher radix algorithms achieve slightly better factorisation and cut down on loop overheads. Winograd’s fourier transform algorithm is based on very efficient short convolutions (Blahut, 1985). However, the saving from using these algorithms is not more than 40%, and this is at the expense of a more complex program. In addition to saving run-time, the FFT is more accurate than straightforward calculation of the DFT since the number of arithmetic operations is less, reducing the rounding error. Stockham (1966) found that two cascaded 256-point FFTs produced half as much error as a single DFT.

In order to derive the basic FFT, assume that $N$ is non-prime and make the factorisations:

 $N~{}=~{}A~{}B$ Composite size time index frequency index

where $a$, $b$, $c$ and $d$ are all integers.

Rewrite the DFT sum

 $\displaystyle X(c+dA)$ $\displaystyle=$ $\displaystyle\sum_{n=0}^{N-1}x(n)W^{n(c+dA)}$ $\displaystyle=$ $\displaystyle\sum_{b=0}^{B-1}\sum_{a=0}^{A-1}x(b+aB)W^{(b+aB)(c+dA)}$ $\displaystyle=$ $\displaystyle\sum_{b=0}^{B-1}\sum_{a=0}^{A-1}x(b+aB)W^{bc}~{}W^{bdA}~{}W^{acB}% ~{}W^{adBA}$

Now $W^{adBA}=W^{adN}=1$, since $a$ and $d$ are both integers. Rearranging the remaining factors gives

 $X(c+dA)=\sum_{b=0}^{B-1}W^{bdA}~{}W^{bc}\sum_{a=0}^{A-1}x(b+aB)W^{acB}$ (2)

This complex expression can be readily understood when decomposed into a series of steps.

1. 1.

${\rm Let}~{}z_{1}(a,b)=x(b+aB).$

2. 2.

${\rm Let}~{}z_{2}(c,b)=\sum_{a=0}^{A-1}z_{1}(a,b)W^{acB}.$

3. 3.

${\rm Let}~{}z_{3}(c,b)=W^{bc}z_{2}(c,b).$

4. 4.

${\rm Let}~{}z_{4}(c,d)=\sum_{b=0}^{B-1}z_{3}(c,b)W^{bdA}.$

5. 5.

${\rm Let}~{}X(c+dA)=z_{4}(c,d).$

When each substitution is made into the previous expression, the result is identical to Equation 2. However, each step is relatively simple:

1. 1.

Map the input vector into a 2-dimensional array in row-major order.

2. 2.

Take the DFTs of the columns in the array.

3. 3.

Scale each element of the array by a complex exponential.

4. 4.

Take DFTs of all the rows in the array.

5. 5.

Now map the 2-dimensional array into the output vector in column-major order.

Figure 1 shows the basic structure of the process. The computation takes place on the rows, columns and elements of a 2-D array formed from the original sequence. The $N$ -point DFT has been decomposed into a series of steps.

1. 1.

Mapping [ $N$ ] $\rightarrow$ [ $A$ x $B$ ]

2. 2.

$B$ $A$ -point DFTs (one per column)

3. 3.

$N$ complex multiplications

4. 4.

$A$ $B$ -point DFTs (one per row)

5. 5.

Mapping [ $A$ x $B$ ] $\rightarrow$ [ $N$ ]

Steps 1, 3 and 5 are all O($N$). In the worst case, $A$ and $B$ might be prime and so the DFTs could not be further factorised. In this case the number of complex multiplications is

 $B.A^{2}~{}+~{}N~{}+~{}A.B^{2}~{}=~{}N(A+B+1)$

 $BA(A-1)~{}+~{}AB(B-1)~{}=~{}N(A+B-2)$

so the overall complexity is $O(N(A+B+1))$. If $A$ is composite (eg. equal to $CD$ ) then the $A^{2}$ representing the contribution of the $A$ -point DFTs can be replaced by $A(C+D)$ giving $O(N(B+C+D))$. Thus it is advantageous to choose $N$ to be highly composite.

The previous discussion involved factorising the DFT when $N$ is non-prime. Cooley and Tukey’s original FFT procedure involves choosing $N=2^{L}$, for some integer $L$. Putting $A=n/2$ and $B=2$ into equation 2 gives

 $\displaystyle X(c)$ $\displaystyle=$ $\displaystyle\sum_{a=0}^{n/2-1}x(2a)W^{2ac}+W^{c}\sum_{a=0}^{n/2-1}x(2a+1)W^{2ac}$ (3) $\displaystyle X(c+n/2)$ $\displaystyle=$ $\displaystyle\sum_{a=0}^{n/2-1}x(2a)W^{2ac}-W^{c}\sum_{a=0}^{n/2-1}x(2a+1)W^{2ac}$ (4)

The first equation is for $d=0$ ; the second is for $d=1$. Together, these are the recurrence relations for the decimation-in-time (DIT) FFT. Putting $A=2$ and $B=n/2$ gives instead

 $\displaystyle X(2d)$ $\displaystyle=$ $\displaystyle\sum_{b=0}^{n/2-1}[x(b)+x(b+n/2)]W^{2bd}$ (5) $\displaystyle X(2d+1)$ $\displaystyle=$ $\displaystyle\sum_{b=0}^{n/2-1}W^{b}[x(b)-x(b+n/2)]W^{2bd}$ (6)

The first equation is for $a=0$ ; the second is for $a=1$. These are the recurrence relations for the decimation-in-frequency (DIF) FFT. These are the two canonical forms of the radix-2 FFT. The computational complexity of the two forms are identical. To illustrate how these relations are used, the structure of the DIT FFT is presented here in a graphical form.

Equation 3 expresses a $N$ -point DFT in terms of two $N/2$ -point DFTs: the DFT of the even terms of the time-series, and the DFT of the odd terms. The equation can be applied recursively to these DFTs until $N=1$, when the transform becomes trivial. Figure 2 shows these relationships graphically. A DFT is represented by a block in the diagram with inputs 0 (top) to $N-1$ (bottom) on the left, and outputs 0 (top) to $N-1$ (bottom) on the right. An open circle denotes a complex addition. A labelled line denotes a complex multiplication by the value of the label. The figure shows the flow-graphs for 8, 4, and 2-point DFTs. Figure 2: Partial signal-flow graphs for DIT FFT (N=2,4, and 8). Figure 3: Expanded flow-graphs for 8-point DIT and DIF FFTs.

Expanding each of the DFT blocks in Figure 2 gives the graph for the 8-point DIT FFT shown in Figure 3. It also shows the flow graph for the DIF FFT, which can be derived from Equation 5 in a similar way. The major element in the graphs is a pair of parallel line connected by crossing lines. This structure is often termed a “butterfly” calculation, because of its graphical appearance. Each butterfly computation replaces its two inputs with two outputs, without affecting (or being affected by) any other butterfly at the same level in the flow graph. Thus, computation of the FFT can be done in-place with no intermediate storage required. However, the inputs to the DIT FFT (and the outputs of the DIF FFT) are not in the regular order due to the odd/even separation at each stage. In fact, the input terms are in bit-reversed order22 A number is bit-reversed for k digits by writing the k digits of its binary representation (including leading zeros) in reverse order. For example, when k=3, the number 3 (011) bit-reversed is 6 (110). When k=4, 3 (0011) bit-reversed is 12 (1100)., so scrambling (or unscrambling) of the data is an important stage in the transform. In applications where data is transformed, adjusted, and then inverse-transformed it is possible to avoid this scrambling by using the DIT form for the forward transform, and the DIF form for the inverse transform (or vice versa).

The FFT consists of ${\rm log}_{2}N$ stages, each consisting of $N/2$ butterflies. Each butterfly consists of 2 complex additions and one complex multiplication. Thus the FFT requires $N\,{\rm log}_{2}N$ additions and $(N/2){\rm log}_{2}N$ multiplications and so is $O(N\,{\rm log}_{2}N)$. A complex addition consists of 2 real additions. A complex multiplication consists of 4 real multiplications and two real additions. Letting $\alpha$ be the real multiplication time, $\beta$ the real addition time,

 $t_{CA}=2\beta$ the time for a complex addition the time for a complex multiplication

Each butterfly takes $2t_{CA}+t_{CM}=4\alpha+6\beta$, and there are $N/2$ butterflies. Thus the proportionality constant for the FFT is

 $t_{fft}=t_{CA}+t_{CM}/2=2\alpha+3\beta$

and the run-time is

 $t_{fft}N\,{\rm log}_{2}N$

## 4 Efficient DFT of a Real Series

When a series is real, its DFT is hermitian33A real function $f$, is said to have even symmetry when $f(-x)=f(x)$ and odd symmetry when $f(-x)=-f(x)$. A complex function is said to have hermitian symmetry when $f(-x)=f(x)^{*}$, where $*$ denotes the complex conjugate (reflection in the imaginary axis). Note that all real functions are hermitian, but not all hermitian functions are real.. Calculating its DFT directly using the complex DFT involves computing redundant information. There are two optimisations for real series that are dependent on the properties of symmetry and the DFT. They will work with the FFT, but do not depend on it.

### 4.1 Simultaneous DFT of two Real Series

Suppose $x(n)$ and $y(n)$ are two real sequences of length $N$. Form the complex sequence $h(n)$

 $h(n)=x(n)+iy(n)$

Since the DFT is linear,

 $H(k)=X(k)+iY(k)$ (7)

Since $x(n)$ and $y(n)$ are both real, their transforms are hermitian, ie.

 $\begin{array}[]{rll}X(k)&=&X(N-k)^{*}\\ Y(k)&=&Y(N-k)^{*}\\ \end{array}$

From (7),

 $\begin{array}[]{rll}H(N-k)^{*}&=&X(N-k)^{*}-iY(N-k)^{*}\\ &=&X(k)-iY(k)\end{array}$ (8)

Now, form the sum and difference of equations 7 and 8, giving:

 $\begin{array}[]{ll}X(k)~{}=~{}(H(N-k)^{*}+H(k))/2\\ Y(k)~{}=~{}i(H(N-k)^{*}-H(k))/2\end{array}$ (9)

Thus, a length-$N$ DFT and $2N$ complex additions, gives the DFT of two length-$N$ real sequences.

### 4.2 DFT of a Real Series using Half-Length Complex DFT

Suppose $x(n)$ is a real sequence length $2N$. Form two length-$n$ real sequences

 $\displaystyle f(n)$ $\displaystyle=$ $\displaystyle x(2n)$ $\displaystyle g(n)$ $\displaystyle=$ $\displaystyle x(2n+1)$

Now consider the transform of $x$

 $\displaystyle X(k)$ $\displaystyle=$ $\displaystyle\sum_{n=0}^{2N-1}x(n)\exp(-i2\pi nk/2N)$ $\displaystyle=$ $\displaystyle\sum_{n=0}^{N-1}x(2n)\exp(-i2\pi 2nk/2N)+\sum_{n=0}^{N-1}x(2n+1)% \exp(-i2\pi(2n+1)k/2N)$ $\displaystyle=$ $\displaystyle\sum_{n=0}^{N-1}x(2n)\exp(-i2\pi nk/N)+\exp(-i\pi k/N)\sum_{n=0}^% {N-1}x(2n+1)\exp(-i2\pi nk/N)$ $\displaystyle=$ $\displaystyle F(k)+e^{-i\pi k/N}G(k)$

$F$ and $G$ are the transforms of the real sequences $f$ and $g$. Equation 9 gives an efficient procedure for calculating the DFT of two real sequences. Let

 $h(n)~{}=~{}f(n)+ig(n)$

Then

 $\displaystyle F(k)$ $\displaystyle=$ $\displaystyle(H(N-k)^{*}+H(n))/2$ $\displaystyle G(k)$ $\displaystyle=$ $\displaystyle i(H(N-k)^{*}-H(n))/2$

So we have

 $X(k)=(H(N-k)^{*}+H(k))/2+e^{i\pi k/N}i(H(N-k)^{*}-H(k))/2$

The symmetry in this computation allows $X(k)$ and $X(N-K)$ to be computed simultaneously. Thus the DFT of a length-$2N$ real sequence can be computed using a length-$N$ DFT, $3N/2$ complex additions and $N/2$ complex multiplications. The run-time is therefore

 ${\frac{N}{2}}t_{CM}+{\frac{3N}{2}}t_{CA}+t_{\frac{fft}{2}}N\,({\rm log}_{2}N-1)$

For $N\geq 8$ this is less than the complex FFT time

 $t_{fft}N\,{\rm log}_{2}N$

Ignoring the linear terms, the speed advantage of the real FFT over the complex FFT for large $N$ is

 $2{\frac{{\rm log}_{2}N}{{\rm log}_{2}N-1}}\approx 2$

Thus, described technique doubles the speed of the FFT for real data. It also halves the storage requirements, since only half of the transform needs to be represented.

## 5 Efficient Convolution and Correlation using the FFT

Two important processes in signal analysis are

 $\begin{array}[]{ll}\mbox{Convolution}&c(k)=\sum_{n=0}^{N}a(k)b(n-k)\\ \mbox{Correlation}&c(k)=\sum_{n=0}^{N}a(k)b(n+k)\end{array}$ (10)

Suppose that the series $a$, $b$ and $c$ are length $N$. Each of the $N$ values of $k$ in (10) requires an integration over $N$ data points, so the processes are both $O(N^{2})$. However, the convolution theorem states that in the frequency domain44 Recall that upper-case letters denote the transform of a lower-case series.

 $\begin{array}[]{ll}\mbox{Convolution}&C(k)~{}=~{}A(k)B(k)\\ \mbox{Correlation}&C(k)~{}=~{}A(k)B(k)^{*}\end{array}$ (11)

The computation in the frequency domain is $O(N)$. The cost of transforming to and from the frequency domain using the FFT is $O(N\,{\rm log}_{2}N)$, which is the most complex part of the process. The speed-up is proportional to $N/{\rm log}_{2}N$, so for large correlations or convolutions the advantage of the frequency domain computation is considerable. For example, when $N=2^{10}$ the order of the advantage is $2^{10}/10\approx 100$, ie. the time-domain computation is roughly 100 times slower than the frequency-domain computation.
The use of the convolution theorem is not quite as simple as (11) suggests, since using the DFT gives a cyclic convolution. This means that the sums and differences in the index of $b$ in (10) are modulo $N$. The effect of this is to make the first and last data points contiguous, causing the convolution to “wrap around” the end of the record. Thus, even for a short convolution the initial output is affected by the data at the end of the record. This problem is usually solved by appending zeroes to the original series. This cancels the contribution of the terms that “wrap around” from the end of the series, producing an acyclic convolution.

## 6 Filtering using the FFT

Filtering involves acyclic convolution. The two standard sectioning techniques, which can be found in most DSP textbooks, are the “select-save” procedure (Helms, 1967) and the “overlap-add” procedure (Stockham, 1966). The “select-save” procedure uses overlapped input sections to produce non-overlapping output sections. Some of the computed output is not valid and must be discarded. The “overlap-add” procedure uses non-overlapped input sections to produce overlapping output sections that must be added together. The “overlap-add” method requires slightly more computation (since the output sections must be added) whereas the “select-save” method requires slightly more storage (to store the overlapping input). Otherwise the complexity of the two procedures is identical. The overlap-add procedure is described here.

Suppose that the input sequence $x(n)$ has length $N$. It is to be convolved with the sequence $h(n)$ which represents the inverse transform of the ITF for the system (ie. the impulse response of the correction filter). Suppose $h(n)$ has length $L$. A length $M$ of input section is chosen such that $M\geq L$. $M$ is the length of the transform operations, so if using a radix-2 FFT, it must be a power of 2. The length of the output section is $M+L-1$. The last $L+1$ points of output must be added to the start of the next output section. The function $h(n)$ is modified by appending $M-L$ zeros as follows

 $a(n)=\left\{\begin{array}[]{r@{}l}h(n),~{}~{}~{}0&\leq n

Define the $j$ th input section

 $x_{j}(n)=x(n+j(M-L+1)),~{}~{}~{}0\leq n

Each input section is extended to $M$ points as follows

 $b_{j}(n)=\left\{\begin{array}[]{cc}x_{j}(n),&0\leq n

The product

 $W_{j}(k)=B_{j}(k)~{}\cdot~{}A(k)$

gives the cyclic convolution of the two sequences $a(n)$ and $b_{j}(n)$. However, the modifications ensure that:

1. 1.

The first $M-L+1$ points of output are correct.

2. 2.

The last $L-1$ points are contribution of the end of the current section to the start of the next section.

The points in (2) are added to the start of the output for section $x_{j+1}$. The algorithm can be summarised as follows. Suppose that $y(n)$ is the output of the convolution.

 (1) Form $a(n)$ and compute its transform $A(k)$ (2) . For $j$ = $0$ to $N/(M-L+1)$ do . a) Form $b_{j}(n)$ and compute the DFT $B_{j}(k)$ . b) . Calculate $W_{j}=A(k)~{}\cdot~{}B_{j}(k)$ . c) . Compute the IDFT $w_{j}(n)$ . d) . Let $w_{{j^{\prime}}}(n)=w_{j}(n)+w_{j-1^{\prime}}(M-L+1+n)$ for $0 . e) . Let $y_{j}(n)=w_{{j^{\prime}}}(n)$ for $0\leq n\leq M-L$

The convolution is computed with $2N/(M-L+1)$ FFT operations. The computation time per sample for complex data is thus

 $T={\frac{2t_{fft}M{\rm log}_{2}M+Mt_{CM}}{(M-L+1)}}$

The optimal values of $L$ and $M$ can be found by minimising this expression. According to Helms (1967) the optimal value of $M$ is approximately $L{\rm log}_{2}L$ but departures from this value can be made without greatly increasing the running time.

## 7 Efficient Calculation of Autocorrelation and Power Spectra

Estimation of autocorrelation and power spectra are classical problems and are well described in the literature (Oppenheim and Schafer, 1975; Geçinki and Yavuz, 1983). They are closely related, since the power spectrum is the fourier transform of the autocorrelation. Two techniques for estimation of power spectra are:

(1) The indirect method - First, the autocorrelation of the sequence is computed. This can be done in the time-domain or in the frequency domain (using the FFT). The autocorrelation function is then transformed into the frequency domain, giving the power spectrum. To reduce leakage, the autocorrelation function is multiplied by a window before transformation.

(2) The direct method - A short section of the input is transformed into the frequency domain (using the FFT). The transformed values are each multiplied by their complex conjugate, giving an estimate of the power spectrum for that section. The process is repeated for a number of sections and the results are added to give the final power spectrum. To reduce leakage, each section of the time-domain data is multiplied by a window function before transformation. This technique is due originally to Welch (1967).

Window functions are necessary to reduce leakage in the power spectrum. The direct method appears to be more efficient, but the transform of its spectral estimator is a measure of cyclic correlation. If only the power spectrum is desired, the direct method is more efficient. However, if both the autocorrelation and the power spectrum are desired the indirect method is preferred. It also gives lower variance in the estimate (Geçinki and Yavuz, 1983).

An efficient algorithm for computing autocorrelation is given by Rader (1970). Suppose that $x(n)$ is the input sequence of length $N$. The inverse transform of $X(k)X^{*}(k)$ gives the cyclic autocorrelation. To get a linear correlation, an equal number of zeros must be appended to the input sequence. However, in practice $N$ is very large compared with the number of lags desired. In this, the data can be processed in smaller sections (as described in section 6). Let $x_{j}(n)$ denote a length $M$ sequence formed by taking $M/2$ points from $x$ and appending $M/2$ zeros as follows

 $x_{j}(n)=\left\{\begin{array}[]{r@{}l}x(n+jM/2)&0\leq n

Let $y_{j}(n)=x(n+jM/2)~{}~{}~{}0\leq n

In the frequency domain form the product

 $W_{j}={X_{j}}^{*}(k)~{}\cdot~{}Y_{j}(k)$

The first $M/2$ elements of $w_{j}$ represent the contribution of the $j$ th section of $x$ to the autocorrelation. Let

 $Z_{j}(k)=\sum_{m=0}^{j}W_{m}(k)=Z_{j-1}(k)+W_{j}(k)$

Then the autocorrelation is given by

 $R(k)=(1/N)IDFT\,\,\{Z_{(2N/M)-1}(k)\}$

 $Y_{j}(k)=X_{j}(k)+(-1)^{k}X_{j+1}(k)$

Thus, it is never necessary to form the sequence $y_{j}(n)$ or take its transform $Y_{j}(k)$ so the required number of DFT operations is halved. Multiplying a DFT by $(-1)^{k}$ corresponds to a shift in time of $M/2$ positions. Rader’s efficient algorithm can be summarised:

 (1) Form $x_{0}(n)$ and calculate its transform $X_{0}(k)$ . Let $Z_{0}(k)=0$, for $0\leq k (2) . For $0~{}\leq~{}j~{}<~{}2N/M-2$ do . a) Form $x_{j+1}(n)$ and compute $X_{j+1}(k)$ . b) . compute $Z_{j+1}(k)~{}=~{}Z_{j}(k)+X_{j}^{*}(k)[X_{j}(k)+(-1)^{k}X_{j+1}(k)]$ (3) . Let $R(s)={\frac{1}{N}}IDFT(Z_{2N/M-1}(k))$ . keeping only the first $M/2+1$ values.

Thus the autocorrelation is computed with $2N/M$ DFT operations (including the final IDFT). However, the number of lag values is not rigidly tied to the transform length $M$. Lag values $pM/2~{}\leq~{}s~{}\leq~{}(p+1)M/2$ can be obtained by accumulating

 ${Z_{j+1}}^{p}(k)={Z_{j}}^{p}(k)+{X_{j}}^{*}(k)[X_{j+p}(k)+(-1)^{k}X_{j+p+1}(k)]$

Suppose that $L$ lag values are desired. The computation time (using the complex FFT) per sample is

 $\displaystyle t_{R}$ $\displaystyle=$ $\displaystyle{\frac{2}{M}}(t_{fft}M{\rm log}_{2}M+t_{CMA}L)$ $\displaystyle=$ $\displaystyle 2t_{fft}{\rm log}_{2}M+2t_{CMA}L/M$

where $t_{CMA}=2t_{CA}+t_{CM}$ is the time per point to compute 2(b) above. $t_{R}$ can be minimised by choosing $M$ appropriately. Analytically, the minimum based on a zero derivative is

 $M=Lt_{cma}\ln(2)/t_{fft}$

With the complex FFT, $t_{CMA}/t_{fft}=2$, so optimum performance obtains when $M\approx 1.38L$. With the real FFT (for large $M$) $t_{CMA}/t_{fft}\approx 4$ so $M\approx 2.77L$. Using the radix-2 FFT, $M$ and $N$ must be powers of 2, so if $M=2.77L$, $L=2^{n}$, and $M=2^{m}$

 $\displaystyle 2^{m}$ $\displaystyle=$ $\displaystyle\ln(2)t_{CMA}/t_{fft}2^{n}$ $\displaystyle m-n$ $\displaystyle=$ $\displaystyle{\frac{\ln(\ln(2)t_{CMA}/t_{FFT})}{\ln(2)}}$

Thus, for $M=2.77L$, $m\approx n+1$.