ArticleslgStudy

computer science

Goertzel algorithm

Goertzel algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Goertzel algorithm rather than just read about it. In short: 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.

Key takeaways

  • Goertzel algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Goertzel algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Goertzel algorithm from memory before moving on to harder problems.

Reference excerpt

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 algorithm The main calculation in the Goertzel algorithm has the form of a digital filter, and for this reason the algorithm is often called a Goertzel filter. The filter operates on an input sequence x[n] in a cascade of two stages with a parameter ω0, giving the frequency to be analysed, normalised to radians per sample. The first stage calculates an intermediate sequence, s[n]:

The second stage applies the following filter to s[n], producing output sequence y[n]:

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<0 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 ω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 ω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

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

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:

Numerical stability It can be observed that the poles of the filter's Z transform are located at e+jω0 and e−jω0, on a circle of unit radius centered on the origin of the complex Z-transform plane. This property indicates that the filter process is marginally stable and vulnerable to numerical-error accumulation when computed using low-precision arithmetic and long input sequences. A numerically stable version was proposed by Christian Reinsch.

DFT computations For the important case of computing a DFT term, the following special restrictions are applied.

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+j2πk=1, equation (6) then takes the following form:

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:

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.

Applications

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Goertzel algorithm

Start with the simplest possible case. Write down what Goertzel algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Goertzel algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Goertzel algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Goertzel algorithm

In research
Goertzel algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Goertzel algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Goertzel algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Digital signal processing, Fast Fourier transforms, so understanding it makes those chapters shorter.
In everyday life
Look for Goertzel algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Goertzel algorithm” →

How to study Goertzel algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Goertzel algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Goertzel algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Goertzel algorithm in simple terms?

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…

Why does Goertzel algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Goertzel algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Goertzel algorithm.

Tags

  • Digital signal processing
  • Fast Fourier transforms

Keep exploring