# How the FFT takes a cosine or sine and outputs the frequencies of the complex form?

If i take the Fast Fourier Transform (FFT) of a cosine function, what has turned this cosine function into its complex exponential form which consists of $$e^{i \omega t} + e^{-i \omega t}$$ ?

Because on its own, cosine has a single frequency at omega, but the FFT must be interpreting cosine as a sum of its complex exponential because its output is amplitudes at frequencies $$-\omega$$ and $$\omega$$. So whats going on here?

I will try to explain it in an intuitive, not rigorous way.

The main idea behind the Fourier Transform is to "project" one signal $$s(t)$$ on another $$\phi(t)$$. If the projection is not zero, then $$\phi(t)$$ is "included" in $$s(t)$$, in the sense that you can write $$s(t)$$ as $$s(t) = A\phi(t) + \text{other signals},$$ with $$A \neq 0$$.

The projection is defined as $$A = \int_{-\infty}^\infty s(t) \phi^*(t)\,dt.$$

You can of course project $$s(t)$$ on multiple signals; you can find the projection on $$\theta(t)$$ $$B = \int_{-\infty}^\infty s(t) \theta^*(t)\,dt$$ and then you can say that $$s(t) = B\theta(t) + \text{other signals}.$$

In the case when the projection of $$\phi(t)$$ on $$\theta(t)$$ is zero (in this case they are said to be orthogonal), you can go further and say that $$s(t) = A\phi(t) + B\theta(t) + \text{other signals}.$$ Since you found two components of $$s(t)$$, you can expect the "other signals" portion of this last equation to be "smaller" (have less energy) than when you project on $$\phi(t)$$ or $$\theta(t)$$ alone.

Now, what Fourier says is that if you project your signal on the set $$\lbrace e^{j\omega t} \rbrace$$, the "other signals" part of the equations above will be zero. So, this set is special: it's said to be a "complete" basis for all signals (it's not the only complete basis, though).

So, if you look at the Fourier Transform integral, you'll notice that it is projecting your time-domain signal on this complete set. It turns out that, when you project the cosine $$\cos(\omega_0 t)$$ on this set of exponentials, you get exactly two projections that are not zero. This means that the cosine can be written as the sum of these two projections.

• Intuitive, that’s very good! – Gilles Oct 25 '18 at 18:13

The function $$x(t)=\cos(\omega_0t)$$ has a Fourier transform that doesn't consist of only one impulse at $$\omega=\omega_0$$. In fact, it consists of two impulses: that one and another one at $$\omega = -\omega_0$$.

This can be seen from Euler's formula:

$$\cos(\omega_0t) = \frac{e^{j\omega_0t}+e^{-j\omega_0t}}{2}$$

There it is clear where the two impulses come from.

What you seem to be missing in your two questions is an understanding of Euler's Equation:

$$e^{i\theta} = \cos(\theta) + i \cdot \sin(\theta)$$

Loosely, conceptually, it says that the trigonometric functions are actually exponential in nature. Specifically, it describes a conversion of a distance along the circumference of the unit circle in the complex plane $$(\theta)$$ to the underlying complex value in the form of $$a+bi$$. My first blog article, The Exponential Nature of the Complex Unit Circle tries to intuitively explain how this equation defines a point on the unit circle.

Now go the same distance along the circumference in the other direction and you get to the complex conjugate point.

$$e^{-i\theta} = \cos(\theta) - i \cdot \sin(\theta)$$

Add the two values and you get a real number.

$$e^{i\theta} + e^{-i\theta} = 2\cos(\theta)$$

From there, the value of $$\cos$$ can be solved for and you get the cosine equation.

$$\cos(\theta) = \frac{ e^{i\theta} + e^{-i\theta} }{ 2 }$$

What the complex value in the DFT bin means is the topic of my second blog article.

You other question doesn't specify the continuous vs. discrete cases. There is a Fourier Transform is each. The DFT is the one for the latter. In the discrete case, only the sinusoidal signals with a whole number of cycles within the sample frame will have only the bins corresponding to the frequency have non-zero values. If there are not a whole number of cycles the bins neighboring the closest frequency bin will have tapering values. This is called leakage.