Skip to content

Commit b6fad2c

Browse files
committed
adding a little more information to FFT
1 parent 16a9b26 commit b6fad2c

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed
Loading

chapters/computational_mathematics/cooley_tukey.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## What Makes a Fourier Transform Fast?
22

3-
If there were ever an algorithm to radically change the landscape of computer science and engineering by making seemingly impossible possible, it would be the Fast Fourier Transform (FFT). On the surface, the algorithm seems like a simple application of recursion, and in principle, that is exactly what it is; however, the Fourier Transform is no ordinary transform -- it allows researchers and engineers to easily bounce back and forth between real space and frequency space.
3+
If there were ever an algorithm to radically change the landscape of computer science and engineering by making seemingly impossible possible, it would be the Fast Fourier Transform (FFT). On the surface, the algorithm seems like a simple application of recursion, and in principle, that is exactly what it is; however, the Fourier Transform is no ordinary transform -- it allows researchers and engineers to easily bounce back and forth between real space and frequency space and is the heart of many physics and engineering applications.
44

55
Now, I know this seems underwhelming, just a neat trick to show friends on a Sunday night when everyone's bored, but the sheer number of engineering applications that use frequency space is overwhelming! From calculating superfluid vortex positions to super-resolution imaging, Fourier Transforms lie at the heart of many scientific disciplines and are essential to many algorithms we will cover later in this book.
66

7-
Simply put, the Fourier Transform is a beautiful application of complex number systems; however, it would never be used today if not for the ability to quickly perform the operation through the use of the Fast Fourier Transform, first introduced by the great Frederick Gauss in 1805 and later independently discovered by James Cooley and John Tukey in 1965{{ "ct1965" | cite }}. Gauss (of course) already had too many things named after him and Cooley and Tukey both had cooler names, so the most common algorithm for FFT's today is known as the Cooley-Tukey algorithm.
7+
Simply put, the Fourier Transform is a beautiful application of complex number systems; however, it would rarely be used today if not for the ability to quickly perform the operation through the use of the Fast Fourier Transform, first introduced by the great Frederick Gauss in 1805 and later independently discovered by James Cooley and John Tukey in 1965{{ "ct1965" | cite }}. Gauss (of course) already had too many things named after him and Cooley and Tukey both had cooler names, so the most common algorithm for FFT's today is known as the Cooley-Tukey algorithm.
88

99
### What is a Fourier Transform?
1010

@@ -74,9 +74,44 @@ Recursion!
7474

7575
### The Cooley-Tukey Algorithm
7676

77-
In some sense, I may have oversold this algorithm. In fact, I definitely have. It's like I have already given you the punchline to a joke and am now getting around to explaining it. Oh well.
77+
In some sense, I may have oversold this algorithm. In fact, I definitely have. It's like I have already given you the punchline to a joke and am now getting around to explaining it. Oh well. The problem with using a standard DFT is that it requires a large matrix multiplication, which is a prohibitively complex operation. The trick to the Cooley-Tukey algorithm is recursion. In particular, we split the matrix we wish to perform the FFT on into two parts: one for all elements with even indices and another for all odd indices. We then proceed to split the array again and again until we have a manageable array size to perform a DFT (or similar FFT) on. With recursion, we can reduce the complexity to $\sim O(n \log n)$, which is a feasible operation.
78+
79+
For me, it is usually easist to think of the Cooley-Tukey algorithm as a method to circumvent a complicated matrix multiplication rather than a method to perform a Fourier Transform; however, this is only because Fourier Transforms seem like mathematical magic. Matrix multiplications do not.
80+
81+
In the end, the code looks like:
82+
```
83+
# Implementing the Cooley-Tukey Algorithm
84+
function cooley_tukey(x)
85+
N = length(x)
86+
87+
#println(N)
88+
89+
if(N%2 !=0)
90+
println("Must be a power of 2!")
91+
exit(0)
92+
end
93+
if(N <= 2)
94+
#println("DFT_slow")
95+
return DFT(x)
96+
else
97+
x_even = cooley_tukey(x[1:2:N])
98+
x_odd = cooley_tukey(x[2:2:N])
99+
n = 0:N-1
100+
#n = n'
101+
half = div(N,2)
102+
factor = exp(-2im*pi*n/N)
103+
return vcat(x_even + factor[1:half] .* x_odd,
104+
x_even + factor[half+1:N] .* x_odd)
105+
end
106+
107+
end
108+
```
78109

79110
### Butterfly Diagrams
111+
As another note, the Cooley-Tukey algorithm is often described pictorially in the form of *Butterfly Diagrams*. These show where each element in the array go before, during, and after the FFT. In this diagram, we see an initial array `x` split into even and odd parts and then concatenated into `X` as seen above.
112+
![Butterfly Diagram](butterfly_diagram.png)
113+
114+
I will update this section in the near future with more information, so stay tuned for more!
80115

81116
### Bibliography
82117

0 commit comments

Comments
 (0)