TITLE: Concrete FFT polynomial multiplication example
QUESTION [27 upvotes]: I have read a number of explanations of the steps involved in multiplying two polynomials using fast fourier transform and am not quite getting it in practice. I was wondering if I could get some help with a concrete example such as:
$$
p(x) = a_0 + a_2x^2 + a_4x^4 + a_6x^6 
$$
$$
q(x) = b_0 + b_4x^4 + b_6x^6 + b_8x^8
$$
Since the $p(x)$'s degree is not a power of 2, do I pad it with zero coefficient terms and evaluate it as a degree 8 polynomial as well? I noticed that these polynomials don't have values for the odd terms; does this still multiply in O(nlog(n)) time complexity? I was unsure how to split it up.
When do I begin evaluating each term at the 8th roots of unity? i.e., $e^{\frac{i\pi k}{8}}$ for $k \in 2,4,6$.
Essentially, I seem to understand each component of component of the fft multiplication when I read it but I am yet to see a step by step concrete example of its process.
Can someone outline the steps for the multiplication of the above polynomials (or a similar simple multiplication) using fft? It would help me a lot.

REPLY [3 votes]: You should read "Introduction to algorithms" [CLRS] it explains every process of the algorithm and proof the necesary lemma/theorems to derive it.
for example it answers your question:
"How are the roots of unity for each polynomial used to reduce the problem size?"
The basic idea is that it uses a divide and conquer approach (nlogn part) based on the halving and cancellation lemmas.
The roots of unity are used only to get the polynomials in their point-value representation (any different points could be used to get such representation) but these allow to apply conveniently the theorems above and get the asymptotic complexity desired.
"do I pad it with zero coefficient terms and evaluate it as a degree 8 polynomial as well? ".
Taking 2 polynomials in their point-value representation and leting $x_k$ be the points you are going to evaluate both $ 0 \leq k \leq n$ will yield $n+1$ point-value pairs, but you need $2n + 1$ pairs to interpolate a unique polynomial of degree $2n$ (the degree of the product polynomial of both of degree $n$). So you must extend the point-value representations of the polynomials to a $2n + 1$ point-value pairs each.
"When do I begin evaluating each term at the 8th roots of unity?"
http://imgur.com/NlZzXv0
This picture answers you "when" (line 4).
and is not only evaluated the 8th roots of unity it's also evaluated the 4th roots of unity, 2nd roots of unity. (divide and conquer... O(nlgn)) the size of vector $\vec{a}$ is reduced by a half as you can notice.
"I noticed that these polynomials don't have values for the odd terms; does this still multiply in O(nlog(n)) time complexity? "
Keep in mind that this notation only states an upper bound for the algorithm, this means that if your polynomials have "some" terms the upper bound will be the same as if it has "all" the terms.
If you truly grasp the algorithm and theory behind this (fairly easy but long enough for a simple answer in here IMO) you would be able to "see" the process and answer your doubts such as "when" and "how", "do I ..." and "complexity".
Good luck and keep learning.