{"id":276,"date":"2015-05-29T06:38:48","date_gmt":"2015-05-29T05:38:48","guid":{"rendered":"http:\/\/www.billconnelly.net\/?p=276"},"modified":"2025-07-05T04:15:10","modified_gmt":"2025-07-05T03:15:10","slug":"visualizing-how-ffts-work","status":"publish","type":"post","link":"https:\/\/www.billconnelly.net\/?p=276","title":{"rendered":"Visualizing how FFTs work."},"content":{"rendered":"<p>A lot of scientists have performed Fast Fourier Transforms at some point, and those that haven&#8217;t, probably are going to in future, or at the very least, have read a paper using it. I&#8217;d used them for years before I ever began to think about how they algorithm actually worked. However, if you&#8217;ve ever looked it up, unless math is your first language, the explanation probably didn&#8217;t help you a lot. Normally you either get an explanation along the lines of &#8220;FFTs convert the signal from the time domain to the frequency domain&#8221; or you just get this:<\/p>\n<div align=\"center\">$latex X_{(k)}\\ = \\sum_{n=0}^{N-1} x_{(n)} \\cdot e^{-2 \\pi i k n \/ N}  &#038;s=2$<\/div>\n<p>However, the other day I came across an amazing explanation of the algorithm, and I really wanted to share it. While I might not be able to get you to the point that you completely understand the FFT, I think think it might seriously enhance your understanding.<br \/>\n<!--more--><\/p>\n<p>So the first thing, I kind of lied to you. I&#8217;m not going to show you how the <strong>F<\/strong>FT algorithm works. I&#8217;m going to show you how discrete Fourier Transforms works. The FFT is just a fast way of computing the DFT.<\/p>\n<p>So the beautiful explanation I read came from <a href=\"http:\/\/blog.revolutionanalytics.com\/2014\/01\/the-fourier-transform-explained-in-one-sentence.html\" target=\"_blank\" rel=\"noopener\">here<\/a>. They color code the equation to show you how the various parts work.<\/p>\n<p><a href=\"http:\/\/www.billconnelly.net\/wp-content\/uploads\/2015\/05\/DFT.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.billconnelly.net\/wp-content\/uploads\/2015\/05\/DFT.png\" alt=\"DFT\" width=\"377\" height=\"166\" class=\"aligncenter size-full wp-image-277\" srcset=\"https:\/\/www.billconnelly.net\/wp-content\/uploads\/2015\/05\/DFT.png 377w, https:\/\/www.billconnelly.net\/wp-content\/uploads\/2015\/05\/DFT-300x132.png 300w\" sizes=\"(max-width: 377px) 100vw, 377px\" \/><\/a><\/p>\n<p>A lot of that may not be immediately obvious, though realizing that $latex e^{2 \\pi i x} $ carves out a circle in the imaginary plane is a great start. The real beauty comes from the following textual explanation:<\/p>\n<blockquote><p> Imagine an enormous speaker, mounted on a pole, playing a repeating sound. The speaker is so large, you can see the cone move back and forth with the sound. Mark a point on the cone, and now rotate the pole. Trace the point from an above-ground view, if the resulting squiggly curve is off-center, then there is frequency corresponding the pole&#8217;s rotational frequency is represented in the sound. <\/p><\/blockquote>\n<p>There is an animation demonstrating that on the above page, but I felt a full interactive version might be helpful.<\/p>\n<p>Enter in some details for two sine waves that will be summed to make your signal (graph to the left). The script will then play this waveform into our &#8220;rotating speaker&#8221; (graph to the right) which will rotate at increasing frequencies. After the waveform is played in, a red line will show up, representing a vector for the mean position of our &#8220;speaker&#8221;. The length of this vector represents the magnitude of our signal at that frequency and the angle represents the phase. The magnitude of the signal is then presented on the bottom graph, which is our DFT. Note how if you change the amplitude of your input sine waves, the length of the vector gets longer, if you change the phase, the vector points in a different direction and if you change the frequency, the vector only has a significant length when then &#8220;speaker&#8221; is rotating at that frequency.  The cool thing is, while there is a lot of unnecessary graphics, the meat of this function performs a real DFT, albeit incredible slowly.<br \/>\n<script src=\"http:\/\/www.billconnelly.net\/scripts\/autoresize.js\" type=\"text\/javascript\"><\/script><iframe loading=\"lazy\" id=\"iframe1\" style=\"overflow: hidden; width: 100%;\" src=\"http:\/\/www.billconnelly.net\/scripts\/FFT.html\" width=\"100%\" height=\"150\" scrolling=\"no\" onload=\"sizeFrame()\"><\/iframe><\/p>\n<p>If you really want to know how FFTs work, rather than DFTs, I think <a href=\"https:\/\/jakevdp.github.io\/blog\/2013\/08\/28\/understanding-the-fft\/\" target=\"_blank\" rel=\"noopener\">this<\/a> explanation is particularly good.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A lot of scientists have performed Fast Fourier Transforms at some point, and those that haven&#8217;t, probably are going to in future, or at the very least, have read a paper using it. I&#8217;d used them for years before I ever began to think about how they algorithm actually worked. However, if you&#8217;ve ever looked&hellip;<a href=\"https:\/\/www.billconnelly.net\/?p=276\">Read more <span class=\"screen-reader-text\">Visualizing how FFTs work.<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4,5,10,3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=\/wp\/v2\/posts\/276"}],"collection":[{"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=276"}],"version-history":[{"count":9,"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=\/wp\/v2\/posts\/276\/revisions"}],"predecessor-version":[{"id":810,"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=\/wp\/v2\/posts\/276\/revisions\/810"}],"wp:attachment":[{"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.billconnelly.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}