Goertzel Algorithm - The Algorithm

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 has a cascade of two stages. The first stage calculates an intermediate sequence, given an input sequence, :

(1)

The output sequence from the first filter, is then applied to the following filter to produce output sequence .

(2)

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 for are presumed all equal to 0. To establish the initial filter state so that evaluation can begin at sample, the filter states are assigned initial values . The parameter specifies the normalised frequency to be analysed, given in cycles per sample. To avoid aliasing hazards, frequency is often restricted to the range 0 to 1/2, but the results are mathematically valid outside of this range.

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:

(3)

The Z transform of the second filter stage given in equation (2) is:

(4)

The combined transfer function of the cascade of the two filter stages is then

(5)

This can be transformed back to an equivalent time domain sequence, and the terms unrolled back to the first input term at index .

(6)  \begin{align} y(n) & = x(n) + e^{+2 \pi i \omega} y(n-1) \\ & = \sum_{k=-\infty}^{n}x(k) e^{+2 \pi i \omega (n-k)} \\ & = e^{+2 \pi i \omega n} \sum_{k=0}^{n} x(k) e^{-2 \pi i \omega k}
\end{align}

It can be observed that the poles of the filter's Z transform are located at and, 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 potentially vulnerable to numerical error accumulation when computed using low-precision arithmetic and long input sequences.

Read more about this topic:  Goertzel Algorithm