TOC prev next

Part 2 - complex sinusoids

Before getting into details of forward and inverse dft we shall talk about complex sinusoids.

Continuous complex sinusoid

A general formula for a complex sinusoid is

$$csin(f,t) = a * e^{j*2\pi * ft}$$

But knowing formula and knowing how it looks like are two different things, so here are some plots.

Complex sinusoid plotted in 2D scaled by different factors a=1, 2, 5

Complex sinusoid plot in 3D space (2 dimensions for complex valued points and 3rd dimension for time) with frequency f=3.

These complex sinusoids are continuous functions without bounded ranges of their arguments, so we won't be dealing with them. DFT uses a discretized version of these.

Discrete complex sinusoids

Complex sinusoid (csin) as used by DFT is given by

$$csin(k,n) = e^{j*2\pi * k/N * n}$$

Because of variable $N$, complex sinusoids used by DFT always depend directly on the length of a signal. Also range of values for two parameters $k,n$ depends directly on $N$.

If discrete csin is plotted in 2D it gives

This shows that csin is perfectly cyclic (as it is a sampled circle).

Often I will talk about k-th csin or csin with k-th frequency. This is just a complex sinusoid with constant parameter $k$ eg. 1st csin = csin(1,n), 5th csin = csin(5,n) etc. To see how k-th sinusoid looks like we need to plot it in 3D.

Below are 3D plots of discrete complex sinusoids with 64 points ($N=64, n=0,1,..,N-1$) for different values of k

$k=1$

$k=2$

$k=3$

You can clearly see that increasing k increases number of loops that csin does but keeps number of samples the same, and so it increases frequency of csin.

But you shall remember that frequency of csin is not in Hz or any other real world unit.

Computing values of a complex sinusoid

As csin() is given by the formula

$$csin(k,n) = e^{j*2\pi * k/N * n}$$

it requires a complex exponentiation to compute its values. If you wish to know how is it even possible how to calculate such thing you can look at a proof of Euler's formula at Julius Smith webpage which explains all the details.

Fortunately for us there is a super important formula called Euler's formula that states

$$e^{j\phi} = cos(\phi) + j*sin(\phi)$$

where $\phi$ is an angle in radians.

By substituting $\phi$ by values used by our csin() we get

$$e^{j*2\pi * k/N * n} = cos(2\pi * k/N * n) + j*sin(2\pi * k/N * n)$$

Thanks to this formula we can compute values by hand or use computer to do the job.

So let's compute a few values for some reasonable (to do by hand) values of N=4.

For $k=0$ $$e^{j*2\pi * 0/4 * n} = cos(2\pi * 0/4 * n) + j*sin(2\pi * 0/4 * n) = \\ cos(0) + j*sin(0) = 1 + j*0 = 1$$

 

For $k=1, n=0$ $$e^{j*2\pi * 1/4 * 0} = cos(2\pi * 1/4 * 0) + j*sin(2\pi * 1/4 * 0) = \\ cos(0) + j*sin(0) = 1 + j*0 = 1$$

 

For $k=1, n=1$ $$e^{j*2\pi * 1/4 * 1} = cos(2\pi * 1/4 * 1) + j*sin(2\pi * 1/4 * 1) = \\ cos(2\pi * 1/4) + j*sin(2\pi * 1/4) = 0 + j*1 = j$$

 

For $k=1, n=2$ $$e^{j*2\pi * 1/4 * 2} = cos(2\pi * 1/4 * 2) + j*sin(2\pi * 1/4 * 2) = \\ cos(2\pi * 2/4) + j*sin(2\pi * 2/4) = -1 + j*0 = -1$$

 

For $k=1, n=3$ $$e^{j*2\pi * 1/4 * 3} = cos(2\pi * 1/4 * 3) + j*sin(2\pi * 1/4 * 3) = \\ cos(2\pi * 3/4) + j*sin(2\pi * 3/4) = 0 + j*(-1) = -j$$

next part