3
$\begingroup$

I'm stuck with the following exercise while self-studying the Discrete Fourier Transform:

Consider sampling exactly three cycles of a continuous $x(t)$ sinusoid resulting in an 8-point $x(n)$ time sequence whose 8-point DFT is the $X(m)$ shown in figure below. If the sample rate used to obtain $x(n)$ was 4000 Hz, write the time-domain equation for the discrete $x(n)$ sinusoid in trigonometric form. Show how you arrived at your answer

Real and Imaginary part of the DFT

From $f_{analysis}(m) = {{fs}\cdot{m}\over{N}} $, I know the "bins" 0 to 7 on the graphics are corresponding to the frequencies in Hz:

$$ \{ 0,500,1000,\boldsymbol{1500},2000,\boldsymbol{2500},3000,3500 \}$$

where the values in bold are corresponding to the non-zero terms.

I also feel like $x(t)$ is of the form:

$$x(t) = A_0\left(cos\left({2\pi}{1500}t\right)+sin\left({2\pi}2500{t}\right)\right)$$

But, (1) I'm not sure my intuition is right (2) I don't know how to prove it (3) I don't see how to calculate the amplitude $A_0$ (4) and finally, is finding $x(t)$ really the answer to the question of writing "the time-domain equation for the discrete 𝑥(𝑛) sinusoid in trigonometric form"

$\endgroup$
2
  • $\begingroup$ Take a look at: dsp.stackexchange.com/questions/59305/… $\endgroup$ Dec 12, 2019 at 19:57
  • $\begingroup$ The normalization of the DFT and the inverse DFT is a matter of choice. The most common convention is "1" for the forward and "1/N" for the reverse. This is the reverse of my preference, but I assumed your question was the common convention hence the "1/N" in my inverse DFT definition starting my answer. Mathematically, $1/ \sqrt{N}$ makes the DFT and its inverse unitary operations, but nobody does that. $\endgroup$ Dec 12, 2019 at 23:49

3 Answers 3

4
$\begingroup$

Here's the pure math:

$$ x[n] = \frac{1}{N} \sum_{k=0}^{N-1} X[k] e^{i \frac{2\pi}{N} nk } $$

$$ x[n] = \frac{1}{8} \left[ (5.657 + i 5.657) e^{i \frac{2\pi}{8} n 3 } +(5.657 - i 5.657) e^{i \frac{2\pi}{8} n 5 } \right] $$

$$ e^{i \frac{2\pi}{8} n 5 } = e^{-i \frac{2\pi}{8} n 3 } $$

$$ \begin{aligned} x[n] &= \frac{1}{8} \left[ (5.657 + i 5.657) e^{i \frac{3\pi}{4} n } + (5.657 - i 5.657) e^{-i \frac{3\pi}{4} n } \right] \\ &= \frac{1}{8} \left[ 5.657 \left( e^{i \frac{3\pi}{4} n } + e^{-i \frac{3\pi}{4} n } \right) + i 5.657 \left( e^{i \frac{3\pi}{4} n } - e^{-i \frac{3\pi}{4} n } \right) \right] \\ &= \frac{1}{8} \left[ 5.657 \left( 2 \cos \left( \frac{3\pi}{4} n \right) \right) + i 5.657 \left( 2i \sin \left( \frac{3\pi}{4} n \right) \right) \right] \\ &= \frac{5.657}{4} \left[ \cos \left( \frac{3\pi}{4} n \right) - \sin \left( \frac{3\pi}{4} n \right) \right] \\ &= \frac{5.657}{4} \sqrt{2} \left[ \frac{1}{\sqrt{2}} \cos \left( \frac{3\pi}{4} n \right) - \frac{1}{\sqrt{2}} \sin \left( \frac{3\pi}{4} n \right) \right] \\ &\approx 2 \left[ \cos\left( \frac{\pi}{4} \right) \cos \left( \frac{3\pi}{4} n \right) - \sin\left( \frac{\pi}{4} \right) \sin \left( \frac{3\pi}{4} n \right) \right] \\ &= 2 \cos\left( \frac{3\pi}{4} n +\frac{\pi}{4} \right) \\ \end{aligned} $$

$$ t = \frac{n}{4000} $$

$$ n = 4000 t $$

$$ \begin{aligned} x(t) &= 2 \cos\left( \frac{3\pi}{4} 4000t +\frac{\pi}{4} \right) \\ &= 2 \cos\left( 3000 \pi t +\frac{\pi}{4} \right) \\ &= 2 \cos\left( 1500 \cdot 2 \pi t +\frac{\pi}{4} \right) \\ \end{aligned} $$

Alternatively:

$$ \begin{aligned} x[n] &= \frac{5.657}{4} \sqrt{2} \left[ \frac{1}{\sqrt{2}} \cos \left( \frac{3\pi}{4} n \right) - \frac{1}{\sqrt{2}} \sin \left( \frac{3\pi}{4} n \right) \right] \\ &\approx 2 \left[ \sin\left( \frac{\pi}{4} \right) \cos \left( \frac{3\pi}{4} n \right) - \cos\left( \frac{\pi}{4} \right) \sin \left( \frac{3\pi}{4} n \right) \right] \\ &= 2 \sin\left( \frac{\pi}{4} - \frac{3\pi}{4} n \right) \\ &= -2 \sin\left( \frac{3\pi}{4} n - \frac{\pi}{4} \right) \\ &= 2 \sin\left( \frac{3\pi}{4} n - \frac{\pi}{4} + \pi \right) \\ &= 2 \sin\left( \frac{3\pi}{4} n + \frac{3\pi}{4} \right) \\ \end{aligned} $$


Thanks for the check mark. Here is a little more since this is such an important topic.

That was the pure math approach. You can also do it more conceptually with a few rules about how the DFT works.

First, you have 8 bins, so bin 4 is your Nyquist bin. In this problem, its value is zero. Had it not been, this would have been a more interesting problem. (Dig into the detail of this exchange to find out: How to get Fourier coefficients to draw any shape using DFT? )

Your DC bin is also zero.

For any real valued signal, the DC and Nyquist bins have to have zero imaginary component, and the upper half of the DFT is the complex conjugate mirror of the lower half. This is known as Hermitian symmetry.

$$ X[k] = X^*[N-k] $$

You can add any multiple of N to either index due to the periodicity of the DFT.

The values in your problem fit these criteria so you know you are looking at a real valued signal and only the lower half is significant.

The only non-zero bin value in the lower half is at 3. This means you have either 3 cycles per frame, or 5 cycles per frame (an alias), or any number 3+N or 5+N cycles per frame (more aliases). The problem specifies that there are three cycles per frame so this ambiguity is resolved.

The other big thing to know about a DFT is that a pure tone with a whole number of cycles per frame (k) will land in a single bin with the corresponding index.

If you signal is:

$$ x[n] = A \cos \left( \left[\frac{2\pi}{N}k \right] n + \phi \right) $$

where $ 0 < k < N/2 $

From this definition you can see the argument of the cosine function advances $\frac{2\pi}{N}k$ radians for every sample. For every $N$ samples, $k$ cycles ( $2\pi k$ radians) are completed.

There will be two non-zero bin values in the conventionally unnormalized DFT:

$$ X[k] = N \frac{A}{2} e^{i \phi} $$

and

$$ X[N-k] = N \frac{A}{2} e^{-i \phi} $$

Looking at just the kth bin:

$$ | X[k] | = N \frac{A}{2} $$

$$ \arg( X[k] ) = \phi $$

In your case:

$$ X[3] = 5.657 + i 5.657 $$

$$ |X[3]| = |5.657 + i 5.657| = 5.657\sqrt{2} = 8 \frac{A}{2} $$

$$ A = \frac{5.657\sqrt{2}}{4} \approx 2 $$

$$ \phi = \arg( X[3] ) = \arg(5.657 + i 5.657) = \operatorname{atan2}(5.657, 5.657) = \frac{\pi}{4} $$

Note $ \arg(x + i y) = \operatorname{atan2}(y, x) $

You can now plug these values into the signal definition:

$$ \begin{aligned} x[n] &= 2 \cos \left( \left[\frac{2\pi}{8}3 \right] n + \frac{\pi}{4} \right) \\ &= 2 \cos \left( \frac{3\pi}{4} n + \frac{\pi}{4} \right) \\ \end{aligned} $$

Notice that the DFT doesn't care about the sampling rate. That only comes in as a factor to convert your frequency from cycles per frame to cycles per unit dimension, usually seconds of time.

$$ \frac{3\pi}{4} \frac{radians}{sample} \cdot \frac{1}{2\pi} \frac{cycles}{radian} \cdot 4000 \frac{samples}{second} = 1500 \frac{cycles}{second} $$

Notice that the frequency conversion from radians per sample to cycles per second is independent of the DFT frame size.

Or you could have just plugged in $ n = 4000t$ like above.



In response to Dan's last comment under his answer (and food for thought for the OP):

"What it is" (definition) and "How you see it" (interpretation) are two different things. Yes, a FIR filter is a dot product. The result of the dot product is the output signal, making it a filter. For your DFT comparison, you added two elements, a shifting frame and an inverse DFT. Together they may function like a filter, but by definition, the DFT itself is not, and not identical to a FIR filter. Another way to put it, the output of a FIR is in the time domain and the output of the DFT is in the frequency domain (interpretations) even though the mathematical operations are identical (definitionally dot products).

The center-of-mass, aka centroid, interpretation sees the DFT as a weighted average calculation, where a set of Roots of Unity are being averaged and the weighting is the signal. It is a strong argument for a 1/N normalization factor. Spectral leakage is also very well understood in this model, check out the charts in the article.

The DFT can be interpreted through many different lenses, the Linear Algebra transformation probably being the most mathematically meaningful one. Obviously you don't have to know Linear Algebra to understand how the DFT behaves.

The DFT can definitely be seen as a bank, or array, of correlation measurements, using the engineering definition of correlation. Whereas, the math/stats definition is normalized giving a result of one when two signals are completely correlated. The existence of the engineering definition is something I learned here on DSP.SE, and something I think should have been given a different name.

One interpretation does not void another. It is just a different way of looking at the same thing.

P.S. There is a neat trick for calculating a one sample sliding DFT without having to recalculate it each time. I'm pretty sure Lyons wrote an article on it, I'd have to look.


To give some clarification to the distinctions of interpretation I am trying to highlight:

To see the DFT as a special case in a typical Linear Algerbra system of equations solution, take a look at my answer for:

Is there any algorithm to decompose a wave into a set of given frequencies?

This is nearly unrecognizable as being the same mathematical defintion (with a $1/N$ normalization) of the center of mass interpretation.

Here is Figure 12 from my Centroids article:

Figure showing DFT as polar graphs

This is very similar to the OP's case, being a pure real tone with exactly three cycles in the frame. The differences are the number of sample points, the amplitude, and a slight difference in the phase.

The graph of the figure is shown at the top. Notice the color gradient goes from green to red. The six polar graphs at the bottom represent bins zero (DC) through five. The graphs are produced by stretching the signal by a factor of the bin index and then wrapping them around the circle, aka polar graphing with different step sizes.

Which one of these is different from the others? The DC, of course, With a step size of zero, the signal stays on the real axis, and it can clearly be seen that the center of mass will also be on the real axis. In this case, at zero.

Actually, you can also say that bin 3 (the fourth graph) is also the different one, because it is the only one for which the center of mass (Centroid) is not zero. In fact it is $1/2$. Just as striking, the center of mass is located at one radian, just like the phase value in the definition.

Coincidence? I think not. Just a really cool different way to understand the DFT.

Does any one want to claim that these two interpretations resemble each other in any way? Does anybody think either is incorrect?

Nope, me neither.

As for the "filter bank" interpretation, some one else will have to justify that, as I've already said, I consider it very misleading, if not outright incorrect. Then again, perhaps I've never seen a proper explanation.

$\endgroup$
11
  • $\begingroup$ For your second line $$ e^{i \frac{2\pi}{8} n 5 } = -e^{-i \frac{2\pi}{8} n 3 } $$ $\endgroup$ Dec 12, 2019 at 22:44
  • $\begingroup$ @DanBoschen I disagree: $$ e^{i \frac{2\pi}{8} n 5 } e^{-i 2\pi n} = e^{i \frac{2\pi}{8} n (5-8) } = e^{-i \frac{2\pi}{8} n 3 } $$Five eights around the circle is the same as negative three eights. $\endgroup$ Dec 12, 2019 at 22:48
  • $\begingroup$ Yes I see! Then I have a sign error. $\endgroup$ Dec 12, 2019 at 22:56
  • 1
    $\begingroup$ @SylvainLeroux You're welcome. Next steps: I recommend that you follow the reference I included and the discussion about RB-J's assertion that the Nyquist bin "has to be split". I learned a lot from it and Olli's followup question. It should be, doesn't have to be. Check out my answer in dsp.stackexchange.com/questions/59305/… for the real valued case. Also, my article dsprelated.com/showarticle/771.php will give you true simplified equations for "leakage". My first four articles are most pertinent. $\endgroup$ Dec 14, 2019 at 12:56
  • 1
    $\begingroup$ @SylvainLeroux I have corresponded with Rick on occasion. He is a stand up guy with a solid reputation of being able to explain DSP concepts well. He also has a presence here at DSP.SE, dsp.stackexchange.com/users/15391/richard-lyons. $\endgroup$ Dec 14, 2019 at 15:44
4
$\begingroup$

(1) I'm not sure my intuition is right

Almost, but you're missing the fact that if you're sampling at 4000kHz, the signals alias; after sampling at 4000kHz, a sine wave at 1500Hz is indistinguishable from one at 2500Hz or 5500Hz, etc. Also, because the work is being done in complex numbers, negative frequencies have meaning: $e^{-j \omega t}$ is different from $e^{j \omega t}$

(2) I don't know how to prove it

Go back and study the Fourier Transform more. You want the Euler identity tattooed onto your frontal lobes: $e^{j \theta} = \cos \theta + j \sin \theta$. You also want the two offshoots of that: $$\cos \theta = \frac{e^{j \theta} + e^{-j \theta}}{2}$$ and $$\sin \theta = \frac{e^{j \theta} - e^{-j \theta}}{j2}$$

prove these to yourself. It'll help you out immensely later.

So (after you review the Fourier transform) you have a signal with a real part and an imaginary part: $$\sqrt{32} \left ( e^{j 2 \pi \frac{3}{8}n} + e^{j 2 \pi \frac{5}{8}n} \right) - j\sqrt{32} \left ( e^{j 2 \pi \frac{3}{8}n} - e^{j 2 \pi \frac{5}{8}n} \right)$$ Note that $2 \pi \frac{5}{8} n = 2 \pi (1 - \frac{3}{8}) n$ and recall that $e^{j 2\pi + \theta} = e^{j \theta}$; after some clever trig identities do these look like anything I've just shown you?

(3) I don't see how to calculate the amplitude A0

It should drop out of the calculations above.

(4) and finally, is finding x(t) really the answer to the question of writing "the time-domain equation for the discrete 𝑥(𝑛) sinusoid in trigonometric form"

Yes, but mind your aliasing!

$\endgroup$
4
  • $\begingroup$ Thanks, lot for the help @Tim. I didn't read the answer entirely yet because I would like to solve the problem with using a minimum number of clues--but damn.... aliasing! $\endgroup$ Dec 12, 2019 at 20:15
  • $\begingroup$ sin theta has the j in the denominator, right? $\endgroup$ Dec 12, 2019 at 20:22
  • $\begingroup$ @DanBoschen \@#\$%. Yes. Or I could be a smart*** and say that it has a $-j$ in the numerator. Editing... $\endgroup$
    – TimWescott
    Dec 12, 2019 at 21:03
  • $\begingroup$ Good we got each others backs. Our answers are awesome now! $\endgroup$ Dec 12, 2019 at 21:05
2
$\begingroup$

You are correct with the bins, except that each is of the form $$e^{j2\pi f t}$$

(For me life became so much easier with DSP when I stopped thinking of frequencies as sine waves and cosine waves but as phasors spinning in time on the complex plane, which is what the above exponential represents. Indeed each single impulse in the frequency domain is such a spinning phasor in the time domain-- and as Euler's identity shows, you need two such spinning phasors- to represent a cosine or sine).

Due to discrete time periodicity in the frequency domain, the bins also correspond to these frequencies:

$$\{0,500,1000,1500,2000,-1500,-1000,-500\}$$

With bin 3 = 1500 Hz and bin 5 = -1500 Hz. Together you get

$$5.657e^{j2\pi 1500 t} +5.657e ^{-j2\pi 1500 t} $$ which from Euler's identity is equal to $11.314cos(2\pi 1500 t)$!


UPDATE: As Tim Wescott pointed out in the comments, that covers your real part of X[m], the imaginary part would be a sine as $-11.314sin(2\pi 1500 t)$ by following Euler's identity for $sin(\theta)$.

This results in:

$$11.314 (cos(2\pi 1500 t) -sin (2\pi 1500 t)) = 16 cos(2\pi 1500 t + \pi/4)$$

Given the DFT as:

$$ X[k] = \sum_{n=0}^{N-1} x[n] e^{-i \frac{2\pi}{N} nk } $$

The signal would grow by a factor of N, or 8 is this case, so x[n] would be samples of

$$2 cos(2\pi 1500 t + \pi/4)$$


Basically the Discrete Fourier Transform's domain extends from 0 to the sampling rate $F_s$ (actually one sample less than $F_s$) as you have indicated, but also equivalently 0 to $F_s/2$ to -$F_s/2$ to 0 (and again one sample higher than $F_s/2$). The Matlab/Octave command FFTSHIFT does this operation for when you want DC to be in the middle of your plot and have the frequency axis extend to $\pm F_s/2$

This answer may help you to further understand what the frequency spectrum looks like for discrete time signals and it's periodicity:

What is normalized frequency

Below is how I demonstrate this periodicity visually. First understand that $e^{-j2\pi f t}$ is a spinning phasor with magitude one and rotating clockwise on a complex plane at rate f cycles/second. (With that too you should be able to see how Euler's Identity results in a real and sinusoidal waveform).

If we as in the graphic below had a fundamental phasor of $e^{j (2\pi/12)n}$ (Which you would have in a 12 point DFT), notice the following as you count by different increments k for $e^{j (2\pi/12)kn}$ as we vary k from 0 to 11:

k = 0: This results in $e^{j0}$ which is magitude 1 angle 0 (DC).

k = 1: Count through all 12 samples, take 12 samples to complete 1 cycle, normalized frequency is 1/12 cycles/sample

k = 2: Count through every other samples, and complete 2 cycles. Normalized frequency is 2/12 cycles/sample

k = 11: Count through 11 samples at a time, and complete 11 cycles. Normalized frequency is 11/12 cycles/sample

Note from the graphic that this case when k =11 is identical to k = -1, where it takes 12 samples to complete 1 cycle rotating in the opposite direction! So the normalized frequency of 11/12 cycles per sample is identical to the normalized frequency of -1/12 cycles/sample.

(NOTE: "Normalized Frequency" is determined by dividing by the sampling rate: when the frequency is at the sampling rate, the normalized frequency = 1. So you can multiply all the normalized frequencies above by the sampling rate to get frequency terms in Hz if that is easier to follow).
then as we count through n samples one at a time (as in the first bin in the DFT)

DFT periodicity

Also note that the Fourier Transform is just a correlation to each frequency (to correlate two functions, you multiply and integrate, or in discrete terms, multiply and accumulate). Look at the form for the Discrete Fourier Transform with relationship to the "spinning phasors" I describe above, and you will see that for each bin in frequency, you are correlating to that particular frequency!

$\endgroup$
24
  • 1
    $\begingroup$ You're still a bit off: $$ \begin{aligned} 2 \cos(2\pi 1500 t - \pi/4) &= 2 \left[ \cos(2\pi 1500 t ) \cos( \pi/4 ) + \sin(2\pi 1500 t ) \sin( \pi/4 ) \right] \\ &= 2 \left[ \cos(2\pi 1500 t ) \sqrt{2} / 2 + \sin(2\pi 1500 t ) \sqrt{2} / 2 \right] \\ &= \sqrt{2} \left[ \cos(2\pi 1500 t ) + \sin(2\pi 1500 t ) \right] \\ \end{aligned} $$ It should be $2\pi 1500 t + \pi/4$ for the cosine argument. Check out my alternative in my answer as well. $\endgroup$ Dec 12, 2019 at 23:36
  • 1
    $\begingroup$ My question gives you more of the intuitive explanation for that in terms of it being a correlation but it's simply the summation in the DFT expression. Consider the case of all 1's for x[n] like I did [1 1 1 1]-- the DFT for the first bin would be 1+1+1+1 = 4. So a DC value with "1" grew to a value 4 in the DFT output. The same thing would happen for any other tone that was on bin center for the same reason. $\endgroup$ Dec 12, 2019 at 23:38
  • 1
    $\begingroup$ @SylvainLeroux I agree with Cedron: $2\cos(2 \pi 1500 t + \pi/4)$ is the correct answer. Are you getting that too? If so, I suggest giving him that correct answer Check that you haven't marked off yet. It's a good and concise answer. $\endgroup$ Dec 12, 2019 at 23:44
  • 1
    $\begingroup$ @SylvainLeroux You got it right. It is so easy to slip a sign in this kind of math. $\endgroup$ Dec 13, 2019 at 0:10
  • 2
    $\begingroup$ Happy to help Sylvain- keep at it and you’ll be answering the questions soon! $\endgroup$ Dec 13, 2019 at 0:55

Your Answer

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

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