fbpx
Wikipedia

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.[1]

Like the DFT, the Goertzel algorithm analyses one selectable frequency component from a discrete signal.[2][3][4] 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.[5]

The algorithm edit

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   in a cascade of two stages with a parameter  , giving the frequency to be analysed, normalised to radians per sample.

The first stage calculates an intermediate sequence,  :

 

(1)

The second stage applies the following filter to  , producing 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  . To avoid aliasing hazards, frequency   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  .

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  :[citation needed]

 

(6)

Numerical stability edit

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 vulnerable to numerical-error accumulation when computed using low-precision arithmetic and long input sequences.[6] A numerically stable version was proposed by Christian Reinsch.[7]

DFT computations edit

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

  • The filtering terminates at index  , where   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
 

(7)
  • The index number   indicating the "frequency bin" of the DFT is selected from the set of index numbers
 

(8)

Making these substitutions into equation (6) and observing that the term  , equation (6) then takes the following form:

 

(9)

We can observe that the right side of equation (9) is extremely similar to the defining formula for DFT term  , the DFT term for index number  , but not exactly the same. The summation shown in equation (9) requires   input terms, but only   input terms are available when evaluating a DFT. A simple but inelegant expedient is to extend the input sequence   with one more artificial value  .[8] We can see from equation (9) that the mathematical effect on the final result is the same as removing term   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   is used in the final step,

 

(10)

Thus, the algorithm can be completed as follows:

  • terminate the IIR filter after processing input term  ,
  • apply equation (10) to construct   from the prior outputs   and  ,
  • apply equation (2) with the calculated   value and with   produced by the final direct calculation of the filter.

The last two mathematical operations are simplified by combining them algebraically:

 

(11)

Note that stopping the filter updates at term   and immediately applying equation (2) rather than equation (11) misses the final filter state updates, yielding a result with incorrect phase.[9]

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   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  , 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 edit

Power-spectrum terms edit

Examining equation (6), a final IIR filter pass to calculate term   using a supplemental input value   applies a complex multiplier of magnitude 1 to the previous term  . Consequently,   and   represent equivalent signal power. It is equally valid to apply equation (11) and calculate the signal power from term   or to apply equation (2) and calculate the signal power from term  . Both cases lead to the following expression for the signal power represented by DFT term  :

 

(12)

In the pseudocode below, the real-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 := sprev2 + sprev22 - (coeff × sprev × sprev2) 

It is possible[10] 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.

Single DFT term with real-valued arithmetic edit

The case of real-valued input data arises frequently, especially in embedded systems where the input streams result from direct measurements of physical processes. When the input data are real-valued, the filter internal state variables sprev and sprev2 can be observed also to be real-valued, consequently, no complex arithmetic is required in the first IIR stage. Optimizing for real-valued arithmetic typically is as simple as applying appropriate real-valued data types for the variables.

After the calculations using input term  , and filter iterations are terminated, equation (11) must be applied to evaluate the DFT term. The final calculation uses complex-valued arithmetic, but this can be converted into real-valued arithmetic by separating real and imaginary terms:

 

(13)

Comparing to the power-spectrum application, the only difference are the calculation used to finish:

(Same IIR filter calculations as in the signal power implementation) XKreal = sprev * cr - sprev2; XKimag = sprev * ci; 

Phase detection edit

This application requires the same evaluation of DFT term  , as discussed in the previous section, using a real-valued or complex-valued input stream. Then the signal phase can be evaluated as

 

(14)

taking appropriate precautions for singularities, quadrant, and so forth when computing the inverse tangent function.

Complex signals in real arithmetic edit

Since complex signals decompose linearly into real and imaginary parts, the Goertzel algorithm can be computed in real arithmetic separately over the sequence of real parts, yielding  , and over the sequence of imaginary parts, yielding  . After that, the two complex-valued partial results can be recombined:

 

(15)

Computational complexity edit

  • According to computational complexity theory, computing a set of   DFT terms using   applications of the Goertzel algorithm on a data set with   values with a "cost per operation" of   has complexity  .
To compute a single DFT bin   for a complex input sequence of length  , the Goertzel algorithm requires   multiplications and   additions/subtractions within the loop, as well as 4 multiplications and 4 final additions/subtractions, for a total of   multiplications and   additions/subtractions. This is repeated for each of the   frequencies.
  • In contrast, using an FFT on a data set with   values has complexity  .
This is harder to apply directly because it depends on the FFT algorithm used, but a typical example is a radix-2 FFT, which requires   multiplications and   additions/subtractions per DFT bin, for each of the   bins.

In the complexity order expressions, when the number of calculated terms   is smaller than  , the advantage of the Goertzel algorithm is clear. But because FFT code is comparatively complex, the "cost per unit of work" factor   is often larger for an FFT, and the practical advantage favours the Goertzel algorithm even for   several times larger than  .

As a rule-of-thumb for determining whether a radix-2 FFT or a Goertzel algorithm is more efficient, adjust the number of terms   in the data set upward to the nearest exact power of 2, calling this  , and the Goertzel algorithm is likely to be faster if

 

FFT implementations and processing platforms have a significant impact on the relative performance. Some FFT implementations[11] perform internal complex-number calculations to generate coefficients on-the-fly, significantly increasing their "cost K per unit of work." FFT and DFT algorithms can use tables of pre-computed coefficient values for better numerical efficiency, but this requires more accesses to coefficient values buffered in external memory, which can lead to increased cache contention that counters some of the numerical advantage.

Both algorithms gain approximately a factor of 2 efficiency when using real-valued rather than complex-valued input data. However, these gains are natural for the Goertzel algorithm but will not be achieved for the FFT without using certain algorithm variants [which?] specialised for transforming real-valued data.

See also edit

References edit

  1. ^ Goertzel, G. (January 1958), "An Algorithm for the Evaluation of Finite Trigonometric Series", American Mathematical Monthly, 65 (1): 34–35, doi:10.2307/2310304, JSTOR 2310304
  2. ^ Mock, P. (March 21, 1985), "Add DTMF Generation and Decoding to DSP-μP Designs" (PDF), EDN, ISSN 0012-7515; also found in DSP Applications with the TMS320 Family, Vol. 1, Texas Instruments, 1989.
  3. ^ Chen, Chiouguey J. (June 1996), Modified Goertzel Algorithm in DTMF Detection Using the TMS320C80 DSP (PDF), Application Report, Texas Instruments, SPRA066
  4. ^ Schmer, Gunter (May 2000), DTMF Tone Generation and Detection: An Implementation Using the TMS320C54x (PDF), Application Report, Texas Instruments, SPRA096a
  5. ^ Cheng, Eric; Hudak, Paul (January 2009), (PDF), archived from the original (PDF) on 2017-03-28
  6. ^ Gentleman, W. M. (1 February 1969). "An error analysis of Goertzel's (Watt's) method for computing Fourier coefficients". The Computer Journal. 12 (2): 160–164. doi:10.1093/comjnl/12.2.160.
  7. ^ Stoer, J.; Bulirsch, R. (2002), Introduction to Numerical Analysis, Springer, ISBN 9780387954523
  8. ^ "Goertzel's Algorithm". Cnx.org. 2006-09-12. Retrieved 2014-02-03.
  9. ^ "Electronic Engineering Times | Connecting the Global Electronics Community". EE Times. Retrieved 2014-02-03.
  10. ^ Elmenreich, Wilfried (August 25, 2011). "Efficiently detecting a frequency using a Goertzel filter". Retrieved 16 September 2014.
  11. ^ Press; Flannery; Teukolsky; Vetterling (2007), "Chapter 12", Numerical Recipes, The Art of Scientific Computing, Cambridge University Press

Further reading edit

  • Proakis, J. G.; Manolakis, D. G. (1996), Digital Signal Processing: Principles, Algorithms, and Applications, Upper Saddle River, NJ: Prentice Hall, pp. 480–481, Bibcode:1996dspp.book.....P

External links edit

  • at the Wayback Machine (archived 2018-06-28)
  • A DSP algorithm for frequency analysis
  • The Goertzel Algorithm by Kevin Banks

goertzel, algorithm, technique, digital, signal, processing, efficient, evaluation, individual, terms, discrete, fourier, transform, useful, certain, practical, applications, such, recognition, dual, tone, multi, frequency, signaling, dtmf, tones, produced, pu. 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 1 Like the DFT the Goertzel algorithm analyses one selectable frequency component from a discrete signal 2 3 4 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 5 Contents 1 The algorithm 2 Numerical stability 3 DFT computations 4 Applications 4 1 Power spectrum terms 4 2 Single DFT term with real valued arithmetic 4 3 Phase detection 4 4 Complex signals in real arithmetic 5 Computational complexity 6 See also 7 References 8 Further reading 9 External linksThe algorithm editThis section may require cleanup to meet Wikipedia s quality standards The specific problem is inconsistent styles between equations and labels Please help improve this section if you can February 2014 Learn how and when to remove this message 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 displaystyle x n nbsp in a cascade of two stages with a parameter w 0 displaystyle omega 0 nbsp giving the frequency to be analysed normalised to radians per sample The first stage calculates an intermediate sequence s n displaystyle s n nbsp s n x n 2 cos w 0 s n 1 s n 2 displaystyle s n x n 2 cos omega 0 s n 1 s n 2 nbsp 1 The second stage applies the following filter to s n displaystyle s n nbsp producing output sequence y n displaystyle y n nbsp y n s n e j w 0 s n 1 displaystyle y n s n e j omega 0 s n 1 nbsp 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 x n displaystyle x n nbsp for n lt 0 displaystyle n lt 0 nbsp are presumed all equal to 0 To establish the initial filter state so that evaluation can begin at sample x 0 displaystyle x 0 nbsp the filter states are assigned initial values s 2 s 1 0 displaystyle s 2 s 1 0 nbsp To avoid aliasing hazards frequency w 0 displaystyle omega 0 nbsp is often restricted to the range 0 to p 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 2p in w 0 displaystyle omega 0 nbsp 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 S z X z 1 1 2 cos w 0 z 1 z 2 1 1 e j w 0 z 1 1 e j w 0 z 1 displaystyle begin aligned frac S z X z amp frac 1 1 2 cos omega 0 z 1 z 2 amp frac 1 1 e j omega 0 z 1 1 e j omega 0 z 1 end aligned nbsp 3 The Z transform of the second filter stage given in equation 2 is Y z S z 1 e j w 0 z 1 displaystyle frac Y z S z 1 e j omega 0 z 1 nbsp 4 The combined transfer function of the cascade of the two filter stages is then S z X z Y z S z Y z X z 1 e j w 0 z 1 1 e j w 0 z 1 1 e j w 0 z 1 1 1 e j w 0 z 1 displaystyle begin aligned frac S z X z frac Y z S z frac Y z X z amp frac 1 e j omega 0 z 1 1 e j omega 0 z 1 1 e j omega 0 z 1 amp frac 1 1 e j omega 0 z 1 end aligned nbsp 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 displaystyle n 0 nbsp citation needed y n x n e j w 0 y n 1 k n x k e j w 0 n k e j w 0 n k 0 n x k e j w 0 k since k lt 0 x k 0 displaystyle begin aligned y n amp x n e j omega 0 y n 1 amp sum k infty n x k e j omega 0 n k amp e j omega 0 n sum k 0 n x k e j omega 0 k qquad text since forall k lt 0 x k 0 end aligned nbsp 6 Numerical stability editIt can be observed that the poles of the filter s Z transform are located at e j w 0 displaystyle e j omega 0 nbsp and e j w 0 displaystyle e j omega 0 nbsp 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 6 A numerically stable version was proposed by Christian Reinsch 7 DFT computations editFor the important case of computing a DFT term the following special restrictions are applied The filtering terminates at index n N displaystyle n N nbsp where N displaystyle N nbsp 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 w 0 2 p k N displaystyle omega 0 2 pi frac k N nbsp 7 dd The index number k displaystyle k nbsp indicating the frequency bin of the DFT is selected from the set of index numbers k 0 1 2 N 1 displaystyle k in 0 1 2 N 1 nbsp 8 dd Making these substitutions into equation 6 and observing that the term e j 2 p k 1 displaystyle e j2 pi k 1 nbsp equation 6 then takes the following form y N n 0 N x n e j 2 p n k N displaystyle y N sum n 0 N x n e j2 pi frac nk N nbsp 9 We can observe that the right side of equation 9 is extremely similar to the defining formula for DFT term X k displaystyle X k nbsp the DFT term for index number k displaystyle k nbsp but not exactly the same The summation shown in equation 9 requires N 1 displaystyle N 1 nbsp input terms but only N displaystyle N nbsp input terms are available when evaluating a DFT A simple but inelegant expedient is to extend the input sequence x n displaystyle x n nbsp with one more artificial value x N 0 displaystyle x N 0 nbsp 8 We can see from equation 9 that the mathematical effect on the final result is the same as removing term x N displaystyle x N nbsp 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 displaystyle x N 0 nbsp is used in the final step s N 2 cos w 0 s N 1 s N 2 displaystyle s N 2 cos omega 0 s N 1 s N 2 nbsp 10 Thus the algorithm can be completed as follows terminate the IIR filter after processing input term x N 1 displaystyle x N 1 nbsp apply equation 10 to construct s N displaystyle s N nbsp from the prior outputs s N 1 displaystyle s N 1 nbsp and s N 2 displaystyle s N 2 nbsp apply equation 2 with the calculated s N displaystyle s N nbsp value and with s N 1 displaystyle s N 1 nbsp produced by the final direct calculation of the filter The last two mathematical operations are simplified by combining them algebraically y N s N e j 2 p k N s N 1 2 cos w 0 s N 1 s N 2 e j 2 p k N s N 1 e j 2 p k N s N 1 s N 2 displaystyle begin aligned y N amp s N e j2 pi frac k N s N 1 amp 2 cos omega 0 s N 1 s N 2 e j2 pi frac k N s N 1 amp e j2 pi frac k N s N 1 s N 2 end aligned nbsp 11 Note that stopping the filter updates at term N 1 displaystyle N 1 nbsp and immediately applying equation 2 rather than equation 11 misses the final filter state updates yielding a result with incorrect phase 9 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 displaystyle y N nbsp 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 displaystyle s 0 s 1 nbsp 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 editPower spectrum terms edit Examining equation 6 a final IIR filter pass to calculate term y N displaystyle y N nbsp using a supplemental input value x N 0 displaystyle x N 0 nbsp applies a complex multiplier of magnitude 1 to the previous term y N 1 displaystyle y N 1 nbsp Consequently y N displaystyle y N nbsp and y N 1 displaystyle y N 1 nbsp represent equivalent signal power It is equally valid to apply equation 11 and calculate the signal power from term y N displaystyle y N nbsp or to apply equation 2 and calculate the signal power from term y N 1 displaystyle y N 1 nbsp Both cases lead to the following expression for the signal power represented by DFT term X k displaystyle X k nbsp X k X k y N y N y N 1 y N 1 s 2 N 1 s 2 N 2 2 cos 2 p k N s N 1 s N 2 displaystyle begin aligned X k X k amp y N y N y N 1 y N 1 amp s 2 N 1 s 2 N 2 2 cos left 2 pi frac k N right s N 1 s N 2 end aligned nbsp 12 In the pseudocode below the real 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 w 2 p Kterm Nterms coeff 2 cos w 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 sprev2 sprev22 coeff sprev sprev2 It is possible 10 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 Single DFT term with real valued arithmetic edit The case of real valued input data arises frequently especially in embedded systems where the input streams result from direct measurements of physical processes When the input data are real valued the filter internal state variables sprev and sprev2 can be observed also to be real valued consequently no complex arithmetic is required in the first IIR stage Optimizing for real valued arithmetic typically is as simple as applying appropriate real valued data types for the variables After the calculations using input term x N 1 displaystyle x N 1 nbsp and filter iterations are terminated equation 11 must be applied to evaluate the DFT term The final calculation uses complex valued arithmetic but this can be converted into real valued arithmetic by separating real and imaginary terms c r cos 2 p k N c i sin 2 p k N y N c r s N 1 s N 2 j c i s N 1 displaystyle begin aligned c r amp cos 2 pi tfrac k N c i amp sin 2 pi tfrac k N y N amp c r s N 1 s N 2 jc i s N 1 end aligned nbsp 13 Comparing to the power spectrum application the only difference are the calculation used to finish Same IIR filter calculations as in the signal power implementation XKreal sprev cr sprev2 XKimag sprev ci Phase detection edit This application requires the same evaluation of DFT term X k displaystyle X k nbsp as discussed in the previous section using a real valued or complex valued input stream Then the signal phase can be evaluated as ϕ tan 1 ℑ X k ℜ X k displaystyle phi tan 1 frac Im X k Re X k nbsp 14 taking appropriate precautions for singularities quadrant and so forth when computing the inverse tangent function Complex signals in real arithmetic edit Since complex signals decompose linearly into real and imaginary parts the Goertzel algorithm can be computed in real arithmetic separately over the sequence of real parts yielding y r n displaystyle y text r n nbsp and over the sequence of imaginary parts yielding y i n displaystyle y text i n nbsp After that the two complex valued partial results can be recombined y n y r n j y i n displaystyle y n y text r n jy text i n nbsp 15 Computational complexity editThis section needs additional citations for verification Please help improve this article by adding citations to reliable sources in this section Unsourced material may be challenged and removed February 2014 Learn how and when to remove this message According to computational complexity theory computing a set of M displaystyle M nbsp DFT terms using M displaystyle M nbsp applications of the Goertzel algorithm on a data set with N displaystyle N nbsp values with a cost per operation of K displaystyle K nbsp has complexity O K N M displaystyle O KNM nbsp To compute a single DFT bin X f displaystyle X f nbsp for a complex input sequence of length N displaystyle N nbsp the Goertzel algorithm requires 2 N displaystyle 2N nbsp multiplications and 4 N displaystyle 4 N nbsp additions subtractions within the loop as well as 4 multiplications and 4 final additions subtractions for a total of 2 N 4 displaystyle 2N 4 nbsp multiplications and 4 N 4 displaystyle 4N 4 nbsp additions subtractions This is repeated for each of the M displaystyle M nbsp frequencies In contrast using an FFT on a data set with N displaystyle N nbsp values has complexity O K N log 2 N displaystyle O KN log 2 N nbsp This is harder to apply directly because it depends on the FFT algorithm used but a typical example is a radix 2 FFT which requires 2 log 2 N displaystyle 2 log 2 N nbsp multiplications and 3 log 2 N displaystyle 3 log 2 N nbsp additions subtractions per DFT bin for each of the N displaystyle N nbsp bins In the complexity order expressions when the number of calculated terms M displaystyle M nbsp is smaller than log N displaystyle log N nbsp the advantage of the Goertzel algorithm is clear But because FFT code is comparatively complex the cost per unit of work factor K displaystyle K nbsp is often larger for an FFT and the practical advantage favours the Goertzel algorithm even for M displaystyle M nbsp several times larger than log 2 N displaystyle log 2 N nbsp As a rule of thumb for determining whether a radix 2 FFT or a Goertzel algorithm is more efficient adjust the number of terms N displaystyle N nbsp in the data set upward to the nearest exact power of 2 calling this N 2 displaystyle N 2 nbsp and the Goertzel algorithm is likely to be faster if M 5 N 2 6 N log 2 N 2 displaystyle M leq frac 5N 2 6N log 2 N 2 nbsp FFT implementations and processing platforms have a significant impact on the relative performance Some FFT implementations 11 perform internal complex number calculations to generate coefficients on the fly significantly increasing their cost K per unit of work FFT and DFT algorithms can use tables of pre computed coefficient values for better numerical efficiency but this requires more accesses to coefficient values buffered in external memory which can lead to increased cache contention that counters some of the numerical advantage Both algorithms gain approximately a factor of 2 efficiency when using real valued rather than complex valued input data However these gains are natural for the Goertzel algorithm but will not be achieved for the FFT without using certain algorithm variants which specialised for transforming real valued data See also editBluestein s FFT algorithm chirp Z Frequency shift keying FSK Phase shift keying PSK References edit Goertzel G January 1958 An Algorithm for the Evaluation of Finite Trigonometric Series American Mathematical Monthly 65 1 34 35 doi 10 2307 2310304 JSTOR 2310304 Mock P March 21 1985 Add DTMF Generation and Decoding to DSP mP Designs PDF EDN ISSN 0012 7515 also found in DSP Applications with the TMS320 Family Vol 1 Texas Instruments 1989 Chen Chiouguey J June 1996 Modified Goertzel Algorithm in DTMF Detection Using the TMS320C80 DSP PDF Application Report Texas Instruments SPRA066 Schmer Gunter May 2000 DTMF Tone Generation and Detection An Implementation Using the TMS320C54x PDF Application Report Texas Instruments SPRA096a Cheng Eric Hudak Paul January 2009 Audio Processing and Sound Synthesis in Haskell PDF archived from the original PDF on 2017 03 28 Gentleman W M 1 February 1969 An error analysis of Goertzel s Watt s method for computing Fourier coefficients The Computer Journal 12 2 160 164 doi 10 1093 comjnl 12 2 160 Stoer J Bulirsch R 2002 Introduction to Numerical Analysis Springer ISBN 9780387954523 Goertzel s Algorithm Cnx org 2006 09 12 Retrieved 2014 02 03 Electronic Engineering Times Connecting the Global Electronics Community EE Times Retrieved 2014 02 03 Elmenreich Wilfried August 25 2011 Efficiently detecting a frequency using a Goertzel filter Retrieved 16 September 2014 Press Flannery Teukolsky Vetterling 2007 Chapter 12 Numerical Recipes The Art of Scientific Computing Cambridge University PressFurther reading editProakis J G Manolakis D G 1996 Digital Signal Processing Principles Algorithms and Applications Upper Saddle River NJ Prentice Hall pp 480 481 Bibcode 1996dspp book PExternal links editGoertzel Algorithm at the Wayback Machine archived 2018 06 28 A DSP algorithm for frequency analysis The Goertzel Algorithm by Kevin Banks Retrieved from https en wikipedia org w index php title Goertzel algorithm amp oldid 1211384489, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.