Professional Documents
Culture Documents
Fourier Tutorial
Fourier Tutorial
Okay, whats the value of the complex exponential when t = ? Well, using Eulers formula:
1 = =
i t i
e e
Okay, whats the value of this expression when t = 3/2? Well, using Eulers formula:
( ) ( ) ( ) ( ) ( ) i i i i i i e e e e e
i i i
i
t i
= = = = = =
= = = * 1 * * 1
3
3
3
3
2
1
2
3 )
2
3
(
Okay, whats the value of this expression when t = 2? Well, using Eulers formula:
( ) ( ) 1 1
2
2
2
= = = =
i i t i
e e e
Okay, whats the value of the complex exponential when t = 5/2? Well, using Eulers
formula:
( ) ( ) ( ) ( ) ( ) i i i i i i i e e e e e
i i i
i
t i
= = = = = =
= = = * 1 * 1 * * * 1
5
5
5
5
2
1
2
5 )
2
5
(
</ boring algebra >
Now lets make a table of those results, and a nice pretty plot:
Value of t Result (value of e
it
) Real part of result Imaginary part of result
0/2 1 1 0
1/2 i 0 1*i
2/2 -1 -1 0
3/2 -i 0 -1*i
4/2 1 1 0
5/2 i 0 1*i
So lets plot the real part of our result (because imaginary numbers are too much to deal with
right now):
Values of the complex exponential
-1.5
-1
-0.5
0
0.5
1
1.5
0 1 2 3 4 5 6 7 8 9
x
e
-
j
w
t
Does that plot remind you of anything? Eh? Eh? Maybe it reminds you of cos(x):
-1.5
-1
-0.5
0
0.5
1
1.5
0 1 2 3 4 5 6 7 8 9
x
c
o
s
(
x
)
In fact if you plugged all the values you wanted into the complex exponential (e
it
), the real part
of your results would look just like a cosine wave. The complex part, it turns out, would look
just like a sine wave at the same frequency! How bloody sweet is that?
So whats up with and t, which I tied together? Hopefully you see where Im going with
this really is usually used to represent the frequency of my complex exponential, and t is the
input variable. So if e
it
is the cosine wave we just walked through, e
2it
is a cosine wave with
twice the frequency. Ill leave it as an exercise for you to plug in values and convince yourself
of that if you so desire.
So what we have, from all this, what I want you to believe, is that
e
it
is sort of like a cosine wave with frequency
which, by the well-known handwaving theorem, translates to
e
it
is a cosine wave with frequency
Now were ready to move on to the Fourier Transform itself.
4) Least deep and most incomplete explanation ever proposed why the Fourier
Transform works.
Okay, now equipped with our deep belief that e
it
is a cosine wave with frequency (if you
skipped here from the beginning, I hope you believe that), lets pretend were otherwise high
school algebra students, and engage in a little dialog with a random dude.
Random dude: I need to know how many 7s there are in 49.
High school algebra student: Duh, just divide 49 by 7. There are seven 7s in 49.
Random dude: I need to know how many xs there are in y.
High school algebra student: Duh, just divide y by x. There are y/x xs in y.
Random dude: I need to know how much of the frequency 23Hz there is in my signal x(t).
High school algebra student: Duh, just divide x(t) by 23Hz. There is x(t)/23Hz amount of
23Hz in your signal.
Now this student may not even know what hertz means, but this is a great intuition sort of
how would we divide x(t) by a signal representing a certain frequency (in this case 23Hz)?
Well, now that we believe that e
it
is a cosine wave with frequency , I bet we can use that
how about this:
t i
t i
e t x
e
t x
= = ) (
) (
in x(t) frequency with signal of amount
This is a nonsense mathematical expression, but its really getting close to the formula for the
Fourier transform unfortunately, this is an expression that looks at a single value of t. And
that doesnt make sense; a single value of x(t) is just a number, and it doesnt have frequency
components. What I really want to know is what the amount of signal with frequency there is
in my entire x(t). So what if we integrate this over all values of t?
=
=
= =
t
t
t i
t i
dt e t x
e
t x
) (
) (
in x(t) frequency with signal of amount
Is it could it be is that the Fourier Transform? It damn sure looks like the formula at the top
of this document that I stole from wikipedia. Lets just finish this up by replacing amount of
signal with frequency in x(t) by the more conventional notation X():
=
=
=
t
t
t i
dt e t x X
) ( ) (
So how does this related to the fft(x) function that I like to call all the time in Matlab or some
other library? This formula takes the signal x(t) and tells me how much of one frequency there is
in that whole signal. The usual implementation of a Fourier Transform does this for lots and lots
of frequencies (often you just tell it how many you want), and returns a table of X() values for
different frequencies. This is exactly what the plot is in section 1.
Hopefully that at least helps you remember the basic concepts of the Fourier Transform; Im
going to touch briefly on the inverse Fourier Transform.
5) Least deep and most incomplete explanation ever proposed on why the inverse
Fourier Transform works.
Actually, scratch that, thats too much, lets do this
5) A good way to remember what the inverse Fourier Transform looks like if you
bought into Section 4.
The inverse Fourier Transform is the opposite of the Fourier Transform. If Im the magic IFT
oracle, you would give me a bunch of frequency/amplitude pairs in other words, youre saying:
heres how much of each frequency live in some signal. I would then tell you what the original
signal was.
So this is the opposite of the Fourier Transform. With no regards to mathematical depth, whats
the opposite of this?
=
=
=
t
t
t i
dt e t x X
) ( ) (
How about we just switch all the ts and s, and turn the inside of the integral upside-down:
=
=
=
d e X t x
t i
) ( ) (
This is very very close to the conventional representation for the IFT, which includes a
normalization factor and looks like this:
=
=
=
d e X t x
t i
) (
2
1
) (
I have been very careless with absolute values here, so you can just trust that the 1/2 is
necessary just to make sure that if I put x(t) into a Fourier Transform and take the IFT of the
result, I get x(t) back.
6) What did we leave out?
Lets see aside from all mathematical depth and justification, the most important omission
here is that my logic which is really more like a pneumonic device completely ignores phase
and completely ignores the complex part of the FT. This is okay for two reasons (1) this is
just a basic intuition and a way of remembering what the FT looks like, and (2) many folks who
are likely to read this document use the FT often just for computing power spectra (which is
defined as the magnitude of the real part of the FFT of a signal). Phase? What phase. We dont
need no stinking phase. Complex part? What complex part. We dont need no stinking
complex part.
Also, to be clear, throughout this document I used notation consistent with the continuous
Fourier Transform, but as far as understanding, recognizing, and remembering the basic formula,
this all applies just fine to the discrete Fourier Transform (DFT and IDFT) and the discrete-time
Fourier Transform (DTFT and IDTFT), whose typical formulas look very very much like the FT
and IFT Ive presented here.
Appendix A: Matlab code
%Qui ck demonst r at i on of usi ng t he Four i er t r ansf or mi n Mat l ab
%t o measur e t he f r equency cont ent of a si gnal .
%
%Dan Mor r i s, 2006
%ht t p: / / cs. st anf or d. edu/ ~dmor r i s
%Number of poi nt s we' l l have i n our si gnal
N = 1024;
%The t i me of our " r ecor di ng i nt er val " , abi t r ar i l y 10 seconds
T = 10;
%Def i ne t i me a t i me axi s
t = [ 0: N- 1] / N;
%Conver t t i me t o seconds
t = t *T;
%Let ' s add t oget her t hr ee si ne waves wi t h di f f er ent f r equenci es and
%ampl i t udes
f 1 = 2; a1 = 7;
f 2 = 3; a2 = 11;
f 3 = 5; a3 = 13;
%Def i ne our t est f unct i on
f = a1*si n( 2*pi *f 1*t ) + a2*si n( 2*pi *f 2*t ) + a3 * si n( 2*pi *f 3*t ) ;
%Pl ot our t est f unct i on and make i t l ook pr et t y
f i gur e( 1) ;
pl ot ( t , f ) ;
xl = xl abel ( ' Ti me ( s) ' ) ;
set ( xl , ' Font Si ze' , 15) ;
yl = yl abel ( ' Si gnal ( made- up uni t s) ' ) ;
set ( yl , ' Font Si ze' , 15) ;
t l = t i t l e( ' Made- up si gnal f or demonst r at i ng f f t ' ) ;
set ( t l , ' Font Si ze' , 15) ;
set ( gcf , ' MenuBar ' , ' none' ) ;
%%
%Take t he f our i er t r ansf or mof our si gnal , t hen t ake i t s magni t ude,
%si nce f or t oday, we' r e not i nt er est ed i n phase. To conver t t o t he
%ampl i t udes we pr ovi ded i n our or i gi nal si gnal , di vi de by N/ 2; t hat ' s j ust
%t he Mat l ab convent i on f or t he f f t f unct i on.
p = abs( f f t ( f ) ) / ( N/ 2) ;
%We' r e onl y i nt er est ed i n posi t i ve f r equenci es f or t hi s demonst r at i on, so
%onl y use t he second hal f of t he st uf f we got back f r omf f t ( ) . The f i r st
%hal f cont ai ned negat i ve f r equenci es.
p = p( 1: N/ 2) ;
%Fi nd t he cor r espondi ng f r equency i n Hz ( we get f r equenci es back f r omFFT
%i n r adi ans)
f r eq = [ 0: N/ 2- 1] / T;
%Pl ot our Four i er component s and make t heml ook pr et t y
f i gur e( 2) ;
%pl ot t he power
pl ot ( f r eq, p) ;
xl = xl abel ( ' Ti me ( s) ' ) ;
set ( xl , ' Font Si ze' , 15) ;
yl = yl abel ( ' Si gnal ( made- up uni t s) ' ) ;
set ( yl , ' Font Si ze' , 15) ;
t l = t i t l e( ' Four i er component s of our si gnal ' ) ;
set ( t l , ' Font Si ze' , 15) ;
set ( gcf , ' MenuBar ' , ' none' ) ;
%Zoomi n on an i nt er est i ng r ange of t he gr aph
xl i m( [ 0, 10] ) ;