I want to stress that this is not a coding problem, my problem is that i don't fully understand the mathematics surrounding the subject and that's why I believe I have a problem.
I was given an assignment to choose a song (I chose the song Stricken by disturbed), perform fast fourier transform on the song, this will shift us from time domain to frequency domain.
Now I was asked to remove the first $10000$ frequencies. if $f(t)$ describes the signal of the song, and $\hat f(u)$ describes the fourier transform of the signal, then define $\hat g(u)$ such that $g(u)=0$ for all $u \in [0,10000]$ and $\hat g(u)=\hat f(u)$ otherwise.
After I removed the first $10000$ frequencies, I was asked to do something else that the teacher kept hidden from us and wanted us to figure out ourselves what we need to do, then perform an inverse fourier transform on $\hat g(u)$ to get $g(t)$. If the hidden action was performed correctly, than $g(t)$ should be strictly real.
So the goal of this exercise is to find out what the hidden action is.
Here is what I think:
The problem with removing the first $10000$ frequencies is that the magnitude is no longer even.
We know for sure, that if $f(t)$ is strictly real, then $|\hat f(u)|$ is even. For example, this is a graph of the magnitude of the fourier transform as a function of frequency, of the song i sampled
Now if I change the first $10000$ values of the fourier transform, the magnitude of transform as function of frequency looks like
You can clearly see that now the magnitude is not an even function. So there is no way that the inverse transform will be a real function.
However, if we now also remove the last $10000$ frequencies, the magnitude should be an even function.
And the graph shows that it is. However, when I calculate the inverse transform, it is not a real function. So something is wrong or missing.
Here is the code that I wrote:
As you can see, after invoking the inverse fourier transform, i get a function that is not real. Why? What am I missing?