encyclopegia.org

Goertzel algorithm

The Goertzel algorithm is a technique in digital signal processing (DSP) for efficient evaluation of the individual terms of the discrete Fourier transform (DFT). It is useful in certain practical applications, such as recognition of dual-tone multi-frequency signaling (DTMF) tones produced by the push buttons of the keypad of a traditional analog telephone. The algorithm was first described by Gerald Goertzel in 1958. Like the DFT, the Goertzel algorithm analyses one selectable frequency component from a discrete signal. Unlike direct DFT calculations, the Goertzel algorithm applies a single real-valued coefficient at each iteration, using real-valued arithmetic for real-valued input sequences. For covering a full spectrum (except when using for continuous stream of data where coefficients are reused for subsequent calculations, which has computational complexity equivalent of sliding DFT), the Goertzel algorithm has a higher order of complexity than fast Fourier transform (FFT) algorithms, but for computing a small number of selected frequency components, it is more numerically efficient. The simple structure of the Goertzel algorithm makes it well suited to small processors and embedded applications. The Goertzel algorithm can also be used "in reverse" as a sinusoid synthesis function, which requires only 1 multiplication and 1 subtraction per generated sample.

The Goertzel algorithm is a technique in digital signal processing (DSP) for efficient evaluation of the individual terms of the discrete Fourier transform (DFT). It is useful in certain practical applications, such as recognition of dual-tone multi-frequency signaling (DTMF) tones produced by the push buttons of the keypad of a traditional analog telephone. The algorithm was first described by Gerald Goertzel in 1958. Like the DFT, the Goertzel algorithm analyses one selectable frequency component from a discrete signal. Unlike direct DFT calculations, the Goertzel algorithm applies a single real-valued coefficient at each iteration, using real-valued arithmetic for real-valued input sequences. For covering a full spectrum (except when using for continuous stream of data where coefficients are reused for subsequent calculations, which has computational complexity equivalent of sliding DFT), the Goertzel algorithm has a higher order of complexity than fast Fourier transform (FFT) algorithms, but for computing a small number of selected frequency components, it is more numerically efficient. The simple structure of the Goertzel algorithm makes it well suited to small processors and embedded applications. The Goertzel algorithm can also be used "in reverse" as a sinusoid synthesis function, which requires only 1 multiplication and 1 subtraction per generated sample. The first filter stage can be observed to be a second-order IIR filter with a direct-form structure. This particular structure has the property that its internal state variables equal the past output values from that stage. Input values x[n] for n are presumed all equal to 0. To establish the initial filter state so that evaluation can begin at sample x[0] , the filter states are assigned initial values s[-2] = s[-1] = 0 . To avoid aliasing hazards, frequency \omega_0 is often restricted to the range 0 to π (see Nyquist–Shannon sampling theorem); using a value outside this range is not meaningless, but is equivalent to using an aliased frequency inside this range, since the exponential function is periodic with a period of 2π in \omega_0 . The second-stage filter can be observed to be a FIR filter, since its calculations do not use any of its past outputs. Z-transform methods can be applied to study the properties of the filter cascade. The Z transform of the first filter stage given in equation (1) is {{NumBlk|:| \begin{align} \frac{S(z)}{X(z)} &= \frac{1}{1 - 2 \cos(\omega_0) z^{-1} + z^{-2}} \\ & = \frac{1}{(1 - e^{+j \omega_0} z^{-1})(1 - e^{-j \omega_0} z^{-1})}. \end{align} |3}} The Z transform of the second filter stage given in equation (2) is The combined transfer function of the cascade of the two filter stages is then {{NumBlk|:| \begin{align} \frac{S(z)}{X(z)} \frac{Y(z)}{S(z)} = \frac{Y(z)}{X(z)} &= \frac{(1 - e^{-j \omega_0}z^{-1})}{(1 - e^{+j \omega_0} z^{-1})(1 - e^{-j \omega_0} z^{-1})} \\ &= \frac{1}{1 - e^{+j \omega_0} z^{-1}}. \end{align} |5}} This can be transformed back to an equivalent time-domain sequence, and the terms unrolled back to the first input term at index n = 0 : The filtering terminates at index n = N , where N is the number of terms in the input sequence of the DFT. The frequencies chosen for the Goertzel analysis are restricted to the special form The index number k indicating the "frequency bin" of the DFT is selected from the set of index numbers Making these substitutions into equation (6) and observing that the term e^{+j 2 \pi k} = 1 , equation (6) then takes the following form: {{NumBlk|:| y[N] = \sum_{n=0}^{N} x[n]e^{-j 2 \pi \frac{n k}{N}}. |9}} We can observe that the right side of equation (9) is extremely similar to the defining formula for DFT term X[k] , the DFT term for index number k , but not exactly the same. The summation shown in equation (9) requires N+1 input terms, but only N input terms are available when evaluating a DFT. A simple but inelegant expedient is to extend the input sequence x[n] with one more artificial value x[N] = 0 . We can see from equation (9) that the mathematical effect on the final result is the same as removing term x[N] from the summation, thus delivering the intended DFT value. However, there is a more elegant approach that avoids the extra filter pass. From equation (1), we can note that when the extended input term x[N] = 0 is used in the final step, Thus, the algorithm can be completed as follows: terminate the IIR filter after processing input term x[N-1] , apply equation (10) to construct s[N] from the prior outputs s[N-1] and s[N-2] , apply equation (2) with the calculated s[N] value and with s[N-1] produced by the final direct calculation of the filter. The last two mathematical operations are simplified by combining them algebraically: {{NumBlk|:| \begin{align} y[N] & = s[N] - e^{-j 2 \pi \frac{k}{N}} s[N-1] \\ & = (2 \cos(\omega_0) s[N-1] - s[N-2]) - e^{-j 2 \pi \frac{k}{N}} s[N-1] \\ & = e^{j 2 \pi \frac{k}{N}} s[N-1] - s[N-2]. \end{align} |11}} Note that stopping the filter updates at term N-1 and immediately applying equation (2) rather than equation (11) misses the final filter state updates, yielding a result with incorrect phase. The particular filtering structure chosen for the Goertzel algorithm is the key to its efficient DFT calculations. We can observe that only one output value y[N] is used for calculating the DFT, so calculations for all the other output terms are omitted. Since the FIR filter is not calculated, the IIR stage calculations s[0], s[1] , etc. can be discarded immediately after updating the first stage's internal state. This seems to leave a paradox: to complete the algorithm, the FIR filter stage must be evaluated once using the final two outputs from the IIR filter stage, while for computational efficiency the IIR filter iteration discards its output values. This is where the properties of the direct-form filter structure are applied. The two internal state variables of the IIR filter provide the last two values of the IIR filter output, which are the terms required to evaluate the FIR filter stage. Examining equation (6), a final IIR filter pass to calculate term y[N] using a supplemental input value x[N]=0 applies a complex multiplier of magnitude 1 to the previous term y[N-1] . Consequently, y[N] and y[N-1] represent equivalent signal power. It is equally valid to apply equation (11) and calculate the signal power from term y[N] or to apply equation (2) and calculate the signal power from term y[N-1] . Both cases lead to the following expression for the signal power represented by DFT term X[k] : In the pseudocode below, the complex-valued input data is stored in the array x and the variables sprev and sprev2 temporarily store output history from the IIR filter. Nterms is the number of samples in the array, and Kterm corresponds to the frequency of interest, multiplied by the sampling period. Nterms defined here Kterm selected here ω = 2 × π × Kterm / Nterms; coeff := 2 × cos(ω) sprev := 0 sprev2 := 0 for each index n in range 0 to Nterms-1 do s := x[n] + coeff × sprev - sprev2 sprev2 := sprev sprev := s end power := sprev 2 + sprev2 2 - (coeff × sprev × sprev2) It is possible to organise the computations so that incoming samples are delivered singly to a software object that maintains the filter state between updates, with the final power result accessed after the other processing is done. XKreal = sprev * cr - sprev2; XKimag = sprev * ci; ==Further reading== ==External links== A DSP algorithm for frequency analysis The Goertzel Algorithm by Kevin Banks Analysis of the Goertzel Algorithm by Uwe Beis in which he compares it to analog 2nd order Chebyshev low pass filter

References

No reference rows published for this article.

Cite this article

MLA

"Goertzel algorithm." encyclopegia.org, 2026, https://encyclopegia.org/wiki/goertzel-algorithm. Accessed 24 November 2026.

Chicago

"Goertzel algorithm." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/goertzel-algorithm.

APA

encyclopegia.org. (2026). Goertzel algorithm. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/goertzel-algorithm

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1331147672 · 0.5 · snapshot enwiki-001331147672

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.