Hi Omer. Thank you for clarifying. This is actually a tricky point about the discrete Fourier transform that I really should have gone into more detail about in the course. I’m pretty sure this issue has come up in the past, but I probably should have a dedicated video about it.

You are correct about this example, and I should have noticed it myself given the plots.

But you are not correct in general – it turns out that whether the frequencies are N/2 or N/2+1 depends on whether the signal has an odd or even number of points. Consider the following code in MATLAB (I’ll paste the Python code later):

```
srate = 1000;
time = (0:srate)/srate;
signal = sin(15*2*pi*time);
hz1 = linspace(0,srate,length(signal)+1);
hz2 = linspace(0,srate,length(signal));
x = abs(fft(signal)) / length(signal);
plot(hz1(1:end-1),x,'bs-', hz2,x,'rs-')
axis([14.9 15.1 .49 .51])
```

Clearly, this is a signal at exactly 15 Hz, so its amplitude spectrum should have a peak at 15.00000 Hz. This produces the following graph:

The red line is correct while the blue line is incorrect. But the blue line follows your code, which you clearly showed was correct in my example!

Now let’s try a small modification to make the signal have an even length:

`time = (0:srate-1)/srate;`

That gives the following graph:

Now the blue line (your suggestion) is correct while the red line is incorrect.

In practical applications, this rarely (if ever) matters, because the signals tend to be relatively long, so the frequencies for N/2 vs. N/2+1 are the same within several degrees of precision, typically a much higher precision than is necessary in the application. In the little example code that you pasted, the effect is really observable because the signal has only 6 points.

But anyway, your larger point is correct, which is that this is a subtle but important part of the discrete Fourier transform and I don’t discuss it in the course. I should really make a video about this point. And I’ll also fix the code in that example and re-upload.

Thanks again for the detailed post!