Why does Discrete Fourier Transform of $\sin^2(x)$ seemingly have an extra frequency component compared to $|\sin x|$?

180 Views Asked by At

I'm trying to better understand Fourier Transform.

In python, I took the fourier transform of $\sin^2(x)$ and $|\sin(x)|$ and plotted the absolute value of the coefficients to see which frequencies are in the signal. The plot of $\sin^2(x)$ makes sense to me. But I'm wondering why do I see an extra value at the fourth frequency bin for $|\sin(x)|$?

I mean both signals have the same frequency, so why is the Fourier Transform telling me that there is a component of another frequency?

plot |sin(x)|plot sin^2(x)

1

There are 1 best solutions below

2
On

It's confusing to say that the functions "have the same frequency", since both are composed of multiple sinusoidal frequency components, which are what the Fourier transform shows you. Both functions do have the same period, which is half that of $\sin x$; this implies that all of their odd-frequency components will be $0$, but it doesn't imply anything about the even-frequency components above 2, which reflect the shape of the periodic signal.

Looking at the (non-transformed) plots, you can see that the difference $|\sin x|-\sin^2x$ oscillates four times between $0$ and a fixed positive value. This means to get from $\sin^2$ to $|\sin x|$, you need to add a signal of the form $a+b\sin(4x)$. The $a$ part increases the frequency-0 component of the Fourier transform and the $b$ part increases the frequency-4 component.