Fast Fourier Transform
Please let me off the waitlist for this class.
Last updated
Please let me off the waitlist for this class.
Last updated
Suppose we have two input polynomials,
such that
Given ints , and we want Given the coefficients, we want to compute the coefficients of the product polynomial.
First, we have the straight-forward algorithm. We have
Total time to compute this is since we need to loop over to . Computing each of requires flops, meaning we're gonna have flops.
Second, we have a Karatsuba related approach. Recall that we have
We can split this up into lows and highs as we did for integer multiplication, that is
Finally, we have an even faster approach using polynomial interpolation.
Clarification: The Discrete Fourier Transform is a matrix, and the Fast Fourier Transform is an algorithm.
Here is a diagram,
Of course, since we're looking for even powers, we'd have to split the matrix up between the even and odd powers, and rearrange the coefficient vector accordingly.
It's the same as last time — you'd get four recursive polynomial multiplications to do with half the degree, but applying the Karatsuba trick, we'd only have three polynomial multiplications, meaning we'd have, just like Karatsuba,
Polynomial intermolation states that a degree polynomial can be uniquely determined by its evaluation on distinct points (refer to CS 70, Lagrange interpolation)
Instead of directly computing the coefficients of C, we can determine . We can therefore compute the evaluation of and on distinct points each, then multiply them, and then just interpolate them to find
In order to increase the efficiency of our algorithm, we can choose our points as , et cetera, because then the computation for the even powers would be the same, saving us a lot of resources.
The main issue, is, this only works at the top level of recursion; that is, the second level is all squares, meaning there can be no negatives. However, we can use complex numbers to get around this. The main question is, which complex numbers do we use? We can start from bottom up. We start off with one, which we can split into and . is split into and , and we already know what splits into. We continue until we reach a set of points to use for our interpolation.
We call these roots of one the th complex roots or unity. In other words, the solutions to . For even , the numbers are plus-minus paired, and their squares are the th roots of unity.
Of course, in order to pull this off, we split into its odd and even powers, such that this trick can be used for both.
We factor out from (the odd powers) so the powers inside become even. We can therefore write our function as
For a polynomial with degree , we can represent the set of polynomials as a matrix-vector equation. The matrix is called a Vandermonde matrix, which we will call
Using this same model we can represent the FFT as
Inversion is possible —