Goertzel algorithm magnitude I'm reading a Goertzel algorithm paper and an embedded article. I have several questions:


I don't understand why the the magnitude is calculated as follows:


$$\text{Magnitude} = y^2[n-2] + y^2[n-1] - a * y[n-2]y[n-1]$$
where $a$ is some coefficient. Can someone elaborate on why this is the expression?


Minimum block size If I have a sampling rate of 4000 Hz and target frequency of 50 Hz, what is the minimum block size?
If block size more that magnitude will more accurate right?
[1] It's a notch filter. It attenuates everything but the frequency component you're interested in. The output is summed up over some time to make the tone detection more reliable.
[2] There's no minimum block size. There's a requirement about the amount of time spent summing up the output. What you'll see is that the summed output over say 205 samples (at fs 8000kHz), grows much more if the input contains the frequency component you're interested in detecting.