I am doing an FFT on a cosine wave which has an amplitude of 1. The FFT is amplitude is not 1 but over 30,000. What am I missing here?

It's from the GNU Radio FFT wiki page:

enter image description here

enter image description here


1 Answer 1


Consider the formula for the DFT (which the FFT efficiently computes as an algorithm):

$$X(k) = \sum_{n=0}^{N-1}x(n)e^{-j2\pi nk/N}$$

Notice that it is a summation over $N$ samples total. Also note using Euler's formula that a cosine function can be expressed as two exponential terms (that are visible in the DFT result) as:

$$x[n] = cos(2\pi f n + \theta) = \frac{1}{2}e^{j(2\pi f n + \theta)} + \frac{1}{2}e^{-j(2\pi f n + \theta)}$$

Observe how in the DFT equation that we multiply the two exponential terms in x[n] by $e^{-j2\pi nk/N}$, that latter which is a phase rotation (the exponents which is the phase add in the product, and generally the term $e^{j\phi}$ is simply a complex vector with magnitude $1$ and angle $\phi$ just in case there was any confusion in that; $e^{j\phi}$ is simply a phase rotation). For each of those two exponential terms, there is a value of $k$ that would cause one of them to rotate to the same phase for every $n$, which then would grow to the large value in the summation. Given the OP's summation has grown to approximately 34,000, and that the magnitude of each of the exponential terms is $1/2$, suggests that there are approximately 68,000 total samples in the DFT assuming no windowing is also applied to the signal (which would then require even more samples due to the amplitude reduction through windowing). For every bin in the DFT result, this is the correlation to $e^{j\omega_k n}$ (a spinning phasor at frequency $\omega_k$, with $\omega_k = 2\pi k/N$), and sinusoidal functions have two such terms as given my Euler's formula: The worlds should now align.

$f$ is the fractional frequency term typically given as a value between $0$ and $0.5$ for the form in the equation above, where it represents the continuous time frequency divided by the sampling rate. Here we see further the values for k where that occurs:

When $k = Nf$

$$X(k=Nf) = \sum_{n=0}^{N-1}x(n)e^{-j2\pi fn}$$

$$ = \sum_{n=0}^{N-1}\bigg( \frac{1}{2}e^{j(2\pi f n + \theta)} + \frac{1}{2}e^{-j(2\pi f n + \theta)} \bigg)e^{-j2\pi fn}$$

$$ = \frac{1}{2}\sum_{n=0}^{N-1}e^{j\theta} + \frac{1}{2}\sum_{n=0}^{N-1}e^{-j(4\pi fn + \theta)}$$

The first term grows to $\frac{N}{2}e^{j\theta}$ in the summation while most of the individual phasors in the second term will cancel leaving either zero or small residual depending on the value for $f$.

Similarly consider when $k=N(1-f)$

$$X(k=N(1-f)) = \sum_{n=0}^{N-1}x(n)e^{-j2\pi(1-f)n}$$ $$ = \sum_{n=0}^{N-1}x(n)e^{-j2\pi n}e^{+j2\pi fn} = \sum_{n=0}^{N-1}x(n)e^{+j2\pi fn}$$

$$ = \sum_{n=0}^{N-1}\bigg( \frac{1}{2}e^{j(2\pi f n + \theta)} + \frac{1}{2}e^{-j(2\pi f n + \theta)} \bigg)e^{+j2\pi fn} $$

$$ = \frac{1}{2}\sum_{n=0}^{N-1}e^{4\pi fn + \theta} + \frac{1}{2}\sum_{n=0}^{N-1}e^{-j\theta}$$

  • $\begingroup$ Yes thankyou -.- long day. forgot to divide by the length of the transform. And removing the window applied by the GNU radio block also was needed. $\endgroup$ Aug 19, 2020 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.