DC4: FFT Part 1 Flashcards
What divide and conquer algorithm do we use for polynomial multiplication?
Fast Fourier Transform (FFT)
If we multiply polynomials A(x) and B(x), both degree n-1, what degree is the resulting polynomial C(x)
A(x) = a_0 + a_1x^1 + … + a_(n-1)x^(n-1)
B(x) = b_0 + b_1x^1 + … + b_(n-1)b^(n-1)
C(x) = A(x) B(x), i.e.,
C(x) = c_0 + c_1x^1 + … + c_(2n-2)x^(2n-2)
So, the degree of C(x) is 2n-2
How do we compute coefficient c_k from the coefficients of A(x) and B(x)?
c_k = a_0b_k + a_1b_(k-1) + … + a_k * b_0
(Like the dot product of a[0:k] and b[k:0])
What is the convolution of coefficient vectors a and b?
c = a * b = the coefficients of C(x), where C(x) = A(x) B(x)
What is the time complexity of FFT? What about the naive algorithm for computing the convolution of A(x) and B(x)?
FFT is O(n log n), but the naive is O(n^2)
What are the two natural representations of polynomial A(x)?
1) coefficients a = [a_0, …, a_(n-1)]
2) values = A(x_1), …, A(x_(n))
How many values are needed to uniquely determine a polynomial of degree n-1?
n
What does FFT actually do to a polynomial?
FFT converts the coefficient representation of a polynomial to its value representation and vice versa.
Why do we care about the value representation of a polynomial?
While coefficients are a more natural representation, values are more convenient for multiplying polynomials.
So how will we use FFT to accomplish polynomial multiplication? (not the algorithm, but the big picture)
1) Use FFT to convert coefficients to values
2) Use values to perform polynomial multiplication
3) Then use FFT to convert back to coefficients
How does polynomial multiplication work with the values representation? i.e., why is it so easy?
Given polynomials A(x) and B(x), both of degree n-1, their product C(x) is of degree 2n-2. To compute C(x), we evaluation A(x) and B(x) at 2n points:
A(x_1), …, A(x_2n)
B(x_1), …, B(x_2n)
Then compute C(x) at each of those points:
C(x_i) = A(x_i) B(x_i)
This gives us 2n points, two more than we need to uniquely determine C(x).
What is the time complexity of polynomial multiplication using values?
Each multiplication at a point x_i is O(1), so the total time complexity is O(n) since we do this for 2n points.
What is the plus-minus property?
For some set of points x_1, …, x_2n,
x_(n+1) = - x_1
x_(n+1) = - x_2
etc.
This way, the squares of opposite points like x_1 and x_(n+1) are equal. This lets us compute half the values during the “divide” step of FFT while still getting the 2n points we need to determine the polynomial C(x).
What is the value of the plus-minus property for FFT?
FFT is a D&C algorithm. The division step is where we calculate A(x) = A_even(x^2) + x*A_odd(x^2).
Without the plus-minus property, A_even() and A_odd() have degree n/2 - 1, so the degree decreased by a factor of two, but we would still need to evaluate them at n points.
The plus-minus property is what lets us cut the number of points at which we need to evaluate our subproblems, and therefore truly reduce our subproblems to half the input size.
Why does A(x) = A_even(x^2) + x*A_odd(x^2)?
A_even(y) = a_0 + a_2 * y + … + a_(n-2) * y^((n-2)/2)
Note that if we let y = x^2, then each coefficient matches the correct exponent(a_2 gets x^2 for example). We can do this while still keeping the degree of A_even() down to (n-2)/2, which is necessary for halving the subproblem for D&C.
A_odd() works the same way, but only if we divide it by x, i.e. pull x out and put it in front algebraically. Then a_1 gets x^0 instead of x^1 for example.