The Fast Fourier Transform (FFT) is an efficient algorithm for computing the Discrete Fourier Transform (DFT) that reduces computational complexity from O(n²) to O(n log n) by exploiting the periodic nature of sinusoids through recursive decomposition into even and odd index summations, followed by combining intermediate results with exponential factors to compute all frequency bins.
Understanding the FFT Algorithm: A Step-by-Step Guide
Added:hi everyone today I'm going to describe to you as simply as possible how the fast 48 transform works now I expect that you have either seen my discret 48 transform video already or are just familiar with the discret 48 transform the fast 48 transform or fft is really a quick smart way to do the DFT a note in syntax in my last video I used X subk to refer to a frequency bin but over here I used capital F subk because I feel f is a more apt syntax to describe a frequency bin and it also distinguishes it from X which I use for samples so I have in front of you the equation for the discret 48 transform if you have n samples say 100 samples of a signal you're going to end up with 100 frequency bins and likewise with each frequency bin you're going to have to calculate a sum of a 100 different values so what you end up with is n SAR number of operations for this complexity if you have just one sample uh you're just going to get one operation if you have two samples you're going to calculate two frequency bins with two s two values summed together in each one for four operations and with three samples you're going to get three frequency bins with three in each for nine so the complexity like I said is n s if we for instance want to do something reasonable like a chart 0 to 20,000 Hertz with one Hertz spacing that's going to end up with 400 million operations and say you can do one operation a minute that'll end up you'll end up with 760 years in order to compute that however if we can change that complexity to an end log 2N complexity for the same problem we're going to end up with only 28,600 operations and as a result only 198 days as opposed to the 760 years that we would otherwise the trick to speeding up the DFT is to take advantage of the periodic nature of sinusoids we can first divide up the DFT into an even index summation and an odd index summation where the sub subscripts for the even index sample is 2m and for the odd index sample is 2 m + 1 so now we have a DFT as a sum of two smaller summations each half the size of the original let's move the two in the numerator to the denominator for both the even and the odd index and we can simplify the odd index term by Distributing out a constant which we can move to the front of the summation shown in green and we can call this constant C subk and now you noticed that the exponential turns in both the even and odd index summations look identical there's something tricky about this particular exponential if we expand using Oilers formula into cosine and sign terms you'll note that K runs from0 to n which is the total number of s samples that we have take a look at what happens when the value of K is larger than n /2 if we Define r as r = k - n / 2 and R runs from 1 to n /2 we can distribute the numerator divide out the N / two and we can find that there is a -2 Pi term in the operand of the co cosine now every time that you add a multiple of 2 pi to the oper end of the cosine you end up with simply the cosine of the function without the 2 pi multiple so every time your K value is larger than n /2 it's simply a repeat of the K value minus n /2 this is what is called a symmetry identity and it can be noted in the cosine sign and as a result the exponential terms because K runs from 0 to n everything repeats after k equals n /2 and the total number of operations is effectively haved we can repeat this process and divide each of these even and odd index summations into their own even and odd index summation every time you split the summation you are having the number of operations to calculate the DFT let's look at an extremely examp simple example say we are sampling a one Hertz sine wave with an amplitude of one if our sampling frequency is four Hertz and the number of samples we take is four we can get the following values if we sample at the right time we start off with our DFT equation which we split into the even and odd segments this split makes the range go from 0 to n /2 minus one since we have four samples we are running from m m equal 0 to to m = 1 we can split one more time so that the summation runs from 0 to zero result in just one sample because the summations are over one term and are equal to zero the exponential terms within each summation drops to one thus the white outline portions refer each to just one sample point we can begin calculating the zeroth frequency bin because k equals z all the exponential terms in green simply equal one so the zero frequency bin is always just the sum of all the samples here here the sum equals z I'm going to call the even portion of the equation f subz e for even and F sub z o for odd this will be used later when you use the Symmetry relation in the first tier of the split now let's try to calculate the first frequency bin now the exponential terms have a value other than one so we must include them in the equation of course you'll use use Oilers formula to convert the exponential terms into complex signs and cosin which we can get values from also don't forget that the E the exponential term that you have to multiply by the entire sum in the first tier split by doing this sum we get -2 J we're going to save the intermediate summations here also remembering not to include the exponential term from the first tier split like I mentioned before the Symmetry relation exists due to the sinusoidal exponential term which results in the sum simply becoming a repeat for all K larger than n /2 from the previous steps I've recorded the even and odd sums and now all we have to do is simply reuse them again when we calculate F sub 2 and f sub3 as a result F sub 2 is simply equal to the sum of the even and odd summations of f Sub 0 similarly f sub3 is simply equal to the sum of the even and oddd summations of f sub one the extra exponential term in green is going to change depending on what K value we have so that's the only distinguishing factor between the first half and the second half of the frequency bins once we calculate that we can sum everything together and and we've completed all the frequency bins F0 through F3 this is exactly what we expect because we have a one Hertz sine wave and we get a value in the first frequency bin of -2 J which once added once added together equals 4J and equals an amplitude of one once averaged check out my DFT video if that doesn't make sense to you I will now go over a recursive method to program the fft algorithm this is not the most space or speed efficient way to program the fft but it's the easiest way to put together one that works the function will recursively split the samples all the way until we have only one sample left and then work backwards through each level combining the values until we arrive at our frequency bins here I've used C++ to write out the algorithm but using something like python will be much simpler as you don't have to declare variables first we need to declare the fft function which outputs a complex vector and also takes a complex Vector as an input here I'm passing the vector called samples which contains all the samples which had earlier denoted as X first we find n which is the number of samples that we have in our Vector array then we write the condition which executes when all the recursive even and odd splits reduces the sample set to a single sample if we are not yet at a single sample we split the samples again into even and odd arrays we place these even samples into an even array and the odd samples into an odd array then we recursively run all the above lines until we end up with just one sample now that we're done with the recursion We Begin combining the values at each level remembering to multiply by the green exponential here we take advantage of the Symmetry relation so that all frequencies bins larger than n /2 we simply use the same value but make an adjustment using the comp exponential and the result is you get all the frequency bins
Up Next

Fourier Transform & FFT: An Intuitive Introduction
@gallamine
324K views•2014-09-08

Gain Recalibration in Hippocampal Path Integration: Math Theory
@1024kyz
144 views•2020-07-02

Discrete Fourier Transform Step-by-Step Tutorial
@SimonXu
974.5K views•2015-08-03

The Mathematical Impossibility of Accurate World Maps
@Vox
23.3M views•2016-12-02
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Mathematics





















![Denoising Data with FFT [Matlab]](https://i.ytimg.com/vi_webp/c249W6uc7ho/maxresdefault.webp)

















