An Interactive Guide To The Fourier Transform - BetterExplained
An Interactive Guide To The Fourier Transform - BetterExplained
The Fourier Transform is one of deepest insights ever made. Unfortunately, the meaning is buried within dense equations:
Yikes. Rather than jumping into the symbols, let's experience the key idea rsthand. Here's a plain-English metaphor:
What does the Fourier Transform do? Given a smoothie, it nds the recipe.
How? Run the smoothie through lters to extract each ingredient.
Why? Recipes are easier to analyze, compare, and modify than the smoothie itself.
How do we get the smoothie back? Blend the ingredients.
The Fourier Transform takes a time-based pattern, measures every possible cycle, and returns the overall "cycle recipe"
(the amplitude, offset, & rotation speed for every cycle that was found).
Time for the equations? No! Let's get our hands dirty and experience how any pattern can be built with cycles, with live
simulations.
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 1/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
If all goes well, we'll have an aha! moment and intuitively realize why the Fourier Transform is possible. We'll save the detailed
math analysis for the follow-up.
Join 450k Monthly
This isn't a force-march through the equations, it's the casual stroll I wish I had. Onward!
Readers
Email Address
Join Newsletter!
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 2/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Why? Well, recipes are great descriptions of drinks. You wouldn't share a drop-by-drop analysis, you'd say "I had an
Email Address
orange/banana smoothie". A recipe is more easily categorized, compared, and modi ed than the object itself.
Join Newsletter!
So... given a smoothie, how do we nd the recipe?
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 3/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Email Address
Join Newsletter!
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 4/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Filters must be independent. The banana lter needs to capture bananas, and nothing else. Adding more oranges
should never affect the banana reading.
Join 450k Monthly
Filters must be complete. We won't get the real recipe if we leave out a
Readers
lter ("There were mangoes too!"). Our collection
of lters must catch every possible ingredient.
Enjoy the article? Keep reading to
Ingredients must be combine-able. Smoothies can be separated and re-combinedgain
without issue (Aunderstanding
an intuitive cookie? Not soof
math.
much. Who wants crumbs?). The ingredients, when separated and combined in any order, must make the same result.
Email Address
See The World As Cycles
The Fourier Transform takes a speci c viewpoint: What if any signal could be ltered into a bunch of circular paths?
Join Newsletter!
Whoa. This concept is mind-blowing, and poor Joseph Fourier had his idea rejected at rst. (Really Joe, even a staircase pattern
can be made from circles?)
And despite decades of debate in the math community, we expect students to internalize the idea without issue. Ugh. Let's
walk through the intuition.
The Fourier Transform nds the recipe for a signal, like our smoothie process:
Stop. Here's where most tutorials excitedly throw engineering applications at your face. Don't get scared; think of the examples
as "Wow, we're nally seeing the source code (DNA) behind previously confusing ideas".
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 5/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
If earthquake vibrations can be separated into "ingredients" (vibrations of different speeds & amplitudes), buildings can
be designed to avoid interacting with the strongest ones.
Join 450k Monthly
Readers
If sound waves can be separated into ingredients (bass and treble frequencies), we can boost the parts we care about, and
hide the ones we don't. The crackle of random noise can be removed. Maybe similar "sound recipes" can be compared
(music recognition services compare recipes, not the raw audio clips). Enjoy the article? Keep reading to
gain an intuitive understanding of
math.
If computer data can be represented with oscillating patterns, perhaps the least-important ones can be ignored. This
"lossy compression" can drastically shrink le sizes (and why JPEG and MP3 les are much smaller than raw .bmp or .wav
les). Email Address
If a radio wave is our signal, we can use lters to listen to a particular channel. In the smoothie
Joinworld, imagine each
Newsletter!
person paid attention to a different ingredient: Adam looks for apples, Bob looks for bananas, and Charlie gets cauli ower
(sorry bud).
The Fourier Transform is useful in engineering, sure, but it's a metaphor about nding the root causes behind an observed
effect.
A "sinusoid" is a speci c back-and-forth pattern (a sine or cosine wave), and 99% of the time, it refers to motion in one
dimension.
A "circle" is a round, 2d pattern you probably know. If you enjoy using 10-dollar words to describe 10-cent ideas, you
might call a circular path a "complex sinusoid".
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 6/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Labeling a circular path as a "complex sinusoid" is like describing a word as a "multi-letter". You zoomed into the wrong level of
detail. Words are about concepts, not the letters they can be split into!
Join 450k Monthly
Readers
The Fourier Transform is about circular paths (not 1-d sinusoids) and Euler's formula is a clever way to generate one:
Email Address
Join Newsletter!
Must we use imaginary exponents to move in a circle? Nope. But it's convenient and compact. And sure, we can describe our
path as coordinated motion in two dimensions (real and imaginary), but don't forget the big picture: we're just moving in a
circle.
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 7/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Let's say we're chatting on the phone and, like usual, I want us to draw the same circle simultaneously. (You promised!) What
should I say?
Join 450k Monthly
How big is the circle? (Amplitude, i.e. size of radius)
Readers
How fast do we draw it? (Frequency. 1 circle/second is a frequency of 1 Hertz (Hz) or 2*pi radians/sec)
Where do we start? (Phase angle, where 0 degrees is the x-axis) Enjoy the article? Keep reading to
gain an intuitive understanding of
math.
I could say "2-inch radius, start at 45 degrees, 1 circle per second, go!". After half a second, we should each be pointing to:
starting point + amount traveled = 45 + 180 = 225 degrees (on a 2-inch circle).
Email Address
Join Newsletter!
Every circular path needs a size, speed, and starting angle (amplitude/frequency/phase). We can even combine paths: imagine
tiny motorcars, driving in circles at different speeds.
The combined position of all the cycles is our signal, just like the combined avor of all the ingredients is our smoothie.
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 8/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Email Address
1
Total Parts Ticks Derive Running?
Join Newsletter!
(Based on this animation, here's the source code. Modern browser required. Click the graph to pause/unpause.)
The magnitude of each cycle is listed in order, starting at 0Hz. Cycles [0 1] means
0 amplitude for the 0Hz cycle (0Hz = a constant cycle, stuck on the x-axis at zero degrees)
1 amplitude for the 1Hz cycle (completes 1 cycle per time interval)
The blue graph measures the real part of the cycle. Another lovely math confusion: the real axis of the circle, which is
usually horizontal, has its magnitude shown on the vertical axis. You can mentally rotate the circle 90 degrees if you like.
The time points are spaced at the fastest frequency. A 1Hz signal needs 2 time points for a start and stop (a single
data point doesn't have a frequency). The time values [1 -1] shows the amplitude at these equally-spaced intervals.
Now let's add a 2Hz cycle to the mix. [0 1 1] means "Nothing at 0Hz, 1Hz of amplitude 1, 2Hz of amplitude 1":
Email Address
1
Total Parts Ticks Derive Running?
Join Newsletter!
Whoa. The little motorcars are getting wild: the green lines are the 1Hz and 2Hz cycles, and the blue line is the combined
result. Try toggling the green checkbox to see the nal result clearly. The combined " avor" is a sway that starts at the max and
dips low for the rest of the interval.
The yellow dots are when we actually measure the signal. With 3 cycles de ned (0Hz, 1Hz, 2Hz), each dot is 1/3 of the way
through the signal. In this case, cycles [0 1 1] generate the time values [2 -1 -1], which starts at the max (2) and dips low (-1).
Oh! We can't forget phase, the starting angle! Use magnitude:angle to set the phase. So [0 1:45] is a 1Hz cycle that starts at 45
degrees:
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 10/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
1
Total Parts Ticks Derive Running?
Email Address
This is a shifted version of [0 1]. On the time side we get [.7 instead of [1 -1],
because our cycle isn't exactly lined up with
-.7]
Join Newsletter!
our measuring intervals, which are still at the halfway point (this could be desired!).
The Fourier Transform nds the set of cycle speeds, amplitudes and phases to match any time signal.
Our signal becomes an abstract notion that we consider as "observations in the time domain" or "ingredients in the frequency
domain".
Enough talk: try it out! In the simulator, type any time or cycle pattern you'd like to see. If it's time points, you'll get a
collection of cycles (that combine into a "wave") that matches your desired points.
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 11/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Email Address
But… doesn't the combined wave have strange values between the yellow time intervals? Sure. But who's
Join to say whether a
Newsletter!
signal travels in straight lines, or curves, or zips into other dimensions when we aren't measuring it? It behaves exactly as we
need at the equally-spaced moments we asked for.
Although the spike seems boring to us time-dwellers (one data point, that's it?), think about the complexity in the cycle world.
Our cycle ingredients must start aligned (at the max value, 4) and then "explode outwards", each cycle with partners that
cancel it in the future. Every remaining point is zero, which is a tricky balance with multiple cycles running around (we can't
just "turn them off").
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 12/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
At time 0, the rst instant, every cycle ingredient is at its max. Ignoring the other time points, (4 ? ? ?) can be made from
4 cycles (0Hz 1Hz 2Hz 3Hz), each with a magnitude of 1 and phase of 0 (i.e., 1 + 1 + 1 + 1 = 4).
Join 450k Monthly
At every future point (t = 1, 2, 3), the sum of all cycles must cancel.
Readers
Here's the trick: when two cycles are on opposites sides of the circle (North & South, East & West,
Enjoy etc.) their
the article? combined
Keep reading to
position is zero (3 cycles can cancel if they're spread evenly at 0, 120, and 240 degrees). gain an intuitive understanding of
math.
Imagine a constellation of points moving around the circle. Here's the position of each cycle at every instant:
Email Address
Time 0 1 2 3
------------
Join Newsletter!
0Hz: 0 0 0 0
1Hz: 0 1 2 3
2Hz: 0 2 0 2
3Hz: 0 3 2 1
Notice how the the 3Hz cycle starts at 0, gets to position 3, then position "6" (with only 4 positions, 6 modulo 4 = 2), then
position "9" (9 modulo 4 = 1).
When our cycle is 4 units long, cycle speeds a half-cycle apart (2 units) will either be lined up (difference of 0, 4, 8…) or on
opposite sides (difference of 2, 6, 10…).
In my head, I label these signals as "time spikes": they have a value for a single instant, and are zero otherwise (the fancy name
Email Address
is a delta function.)
Join Newsletter!
Here's how I visualize the initial alignment, followed by a net cancellation:
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 14/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Email Address
Join Newsletter!
It seems the cycle ingredients should be similar to (4 0 0 0), but the cycles must align at t=1 (one second in the future). Here's
where phase comes in.
Imagine a race with 4 runners. Normal races have everyone lined up at the starting line, the (4 0 0 0) time pattern. Boring.
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 15/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
What if we want everyone to nish at the same time? Easy. Just move people forward or backwards by the appropriate distance.
Maybe granny can start 2 feet in front of the nish line, Usain Bolt can start 100m back, and they can cross the tape holding
Join 450k Monthly
hands.
Readers
Phase shifts, the starting angle, are delays in the cycle universe. Here's how we adjust the starting position to delay every cycle
1 second: Enjoy the article? Keep reading to
gain an intuitive understanding of
A 0Hz cycle doesn't move, so it's already aligned math.
A 1Hz cycle goes 1 revolution in the entire 4 seconds, so a 1-second delay is a quarter-turn. Phase shift it 90 degrees
backwards (-90) and it gets to phase=0, the max value, at t=1. Email Address
A 2Hz cycle is twice as fast, so give it twice the angle to cover (-180 or 180 phase shift -- it's across the circle, either way).
A 3Hz cycle is 3x as fast, so give it 3x the distance to move (-270 or +90 phase shift) Join Newsletter!
If time points (4 0 0 0) are made from cycles [1 1 1 1], then time points (0 4 0 0) are made from [1 1:-90 1:180 1:90]. (Note:
I'm using "1Hz", but I mean "1 cycle over the entire time period").
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 16/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Email Address
Join Newsletter!
Test your intuition: Can you make (0 0 4 0), i.e. a 2-second delay? 0Hz has no phase. 1Hz has 180 degrees, 2Hz has 360 (aka 0),
and 3Hz has 540 (aka 180), so it's [1 1:180 1 1:180].
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 17/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Email Address
Here's the conversion from "math English" to full math:
Join Newsletter!
A few notes:
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 18/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Email Address
Onward
Join Newsletter!
This was my most challenging article yet. The Fourier Transform has several avors (discrete/continuous/ nite/in nite), covers
deep math (Dirac delta functions), and it's easy to get lost in details. I was constantly bumping into the edge of my knowledge.
But there's always simple analogies out there -- I refuse to think otherwise. Whether it's a smoothie or Usain Bolt & Granny
crossing the nish line, take a simple understanding and re ne it. The analogy is awed, and that's ok: it's a raft to use, and
leave behind once we cross the river.
I realized how feeble my own understanding was when I couldn't work out the transform of (1 0 0 0) in my head. For me, it was
like saying I knew addition but, gee whiz, I'm not sure what "1 + 1 + 1 + 1" would be. Why not? Shouldn't we have an intuition
for the simplest of operations?
That discomfort led me around the web to build my intuition. In addition to the references in the article, I'd like to thank:
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 19/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Enjoy
Today's goal was to experience the Fourier Transform. We'll save the advanced analysis for nextthe article? Keep reading to
time.
gain an intuitive understanding of
Happy math. math.
Email Address
Appendix: Projecting Onto Cycles
Stuart Rif e has a great interpretation of the Fourier Transform: Join Newsletter!
Imagine spinning your signal in a centrifuge and checking for a bias. I have a correction: we must spin backwards (the exponent
in the equation above should be $e^{-i 2 \pi...}$). You already know why: we need a phase delay so spikes appear in the future.
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 20/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
The Fourier Transform is about cycles added to cycles added to cycles. Try making a "time spike"
Email by setting a amplitude of 1 for
Address
every component (press Enter after inputting each number). Fun fact: with enough terms, you can draw any shape, even Homer
Simpson. Join Newsletter!
Check out http://www.jezzamon.com/fourier/ for a great tool to draw any shape using epicycles.
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 21/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Email Address
Join Newsletter!
Appendix: Article With R Code Samples
João Neto made a great writeup, with technical (R) code samples here:
http://www.di.fc.ul.pt/~jpn/r/fourier/fourier.html
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 22/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Email Address
Email Address Join Newsletter
Join Newsletter!
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 23/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
LOG IN WITH
Enjoy the article? Keep reading to
OR SIGN UP WITH DISQUS ?
gain an intuitive understanding of
Name math.
Great question. We can't directly add amplitudes and angles, we need to use trig to figure out their combined effect when they're added.
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 25/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
q y p g , g g y
For example:
Join 450k Monthly
* Drive 3 miles at a 30 degree angle [assume 0 degrees is horizontal] * Then, drive 4 miles at a 50 degree angle.
Readers
What is your final position, the combined effect? (It's unlikely to be exactly 7 miles away, or at 80 degrees, right?)
Using trig, we can combine the horizontal and vertical coordinates: Enjoy the article? Keep reading to
x position: 3*cos(30) + 4*cos(50) = 5.169 miles horizontal gain an intuitive understanding of
y position: 3*sin(30) + 4*sin(50) = 4.564 miles vertical math.
Put back as amplitude/angle, this is:
Where W is change of basis matix. If you take the hermitian transpose of W (which is orthomormal) we can rearrange to get the synthasis
formula:
x=Hermitian(W)X.
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 26/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
From symmetry of values in W we just to take the complex conjugate of W. Hence the difference in sign in the two formulas.
Respect for the time and effort required to make the difficult seem trivial
△ ▽ • Reply • Share ›
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 28/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
I am very much impressed by the way it is explained . It is very easy to understand FT.Thanks
△ ▽ • Reply • Share ›
Join 450k Monthly
Bob Tivnan • a year ago
Readers
You sir have a gift. I have been teaching math for twenty years, and I have heard countless explanations of Fourier series. This is hands down
the most elegant and accessible explanation I have ever heard. Thank you for your contribution- it will impact my own teaching.
△ ▽ • Reply • Share › Enjoy the article? Keep reading to
gain an intuitive understanding of
Patrick Andrade • a year ago
math.
Congratulations for this explanation... It was very clear. I'd like know if you used some specific software to make that animations or if it was
made with pure javascript language..
△ ▽ • Reply • Share ›
Email Address
Kalid > Patrick Andrade • a year ago
The animation was in plain javascript (you can view source on the animation). Join Newsletter!
△ ▽ • Reply • Share ›
"When our cycle is 4 units long, cycle speeds a half-cycle apart (2 units) will either be lined up (difference of 0, 4, 8…) or on opposite sides
(difference of 2, 6, 10…)."
In particular, what does "cycle speeds a half-cycle apart" even mean? That sounds like a grammatical typo!
△ ▽ • Reply • Share ›
kalid > Redu • a year ago Enjoy the article? Keep reading to
I'm using "Hz" loosely here to mean "cycle during the signal" and not "cycles per second". gain an intuitive
So here, understanding
a 1Hz component of
finishes a single
revolution over the duration of the signal. math.
△ ▽ • Reply • Share ›
thank you
△ ▽ • Reply • Share › Email Address
Time 0 1 2 3
------------
0Hz: 0 0 0 0
1Hz: 0 1 2 3
2Hz: 0 2 0 2
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 32/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
2Hz: 0 2 0 2
3Hz: 0 3 2 1
You mention that each cell there represents the position of the cycle at the instant. Join 450k Monthly
I couldnt quite get it. For instance, let us take the 2Hz cycle at time 1. Its position is "2"... but "2" what? Readers
Does it refer to the x-axis or to the y-axis? I find it confusing because the x-axis represents amplitude, and the y-axis represents time. Hence,
the "2" probably does not refer to any of them... Is it perhaps the phase?
Enjoy the article? Keep reading to
△ ▽ • Reply • Share ›
gain an intuitive understanding of
math.
Load more comments
Email Address
ALSO ON BETTEREXPLAINED DISCUSSIONS
Einstein’s Theory of Special Relativity (MetaLearn Podcast) Learning Math: Find The ImpliedJoin
Subject
Newsletter!
4 comments • a year ago 21 comments • 8 months ago
Anatoli — Honestly, I've got more insight from this comment rather than Richard Ruff — As always, a stimulating idea to ponder on first thing in
from the podcast itself. the day! Thanks Kalid, beautifully written, beautifully …
✉ Subscribe d Add Disqus to your siteAdd DisqusAdd 🔒 Disqus' Privacy PolicyPrivacy PolicyPrivacy
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 33/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Email Address
Join Newsletter!
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 34/35
20/2/2019 An Interactive Guide To The Fourier Transform – BetterExplained
Email Address
Join Newsletter!
https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/ 35/35