FFT and Algebraic Computation
FFT and Algebraic Computation
• Given two polynomial A(x) and B(x), find the product C(x) =
A(x)*B(x).
• At a glance, it looks like points 2 and 3 from the Algorithm takes O(n2) time.
– However, the FFT will allow us to quickly move from coefficient
representation of polynomial to the point-value representation, and back,
for our cleverly chosen set of m points.
– Doesn’t work for arbitrary m points. The special points will turn out to be
the roots of unity.
Roots of Unity
• The roots of unity of order n are those numbers whic
h, when raised to the n th power, we get 1 ("unity").
They're also called "n th roots of unity".
– There are exactly n such numbers, one of which is alw
ays the number 1 itself.
– When n=2, they are 1 and −1 .
• What’s nice is that the effort spent computing A(x) will give us A(-x)
almost for free. So, we need to specially choose m points that will
have the property: the 2nd half of points are the negative of the 1st
half.
• We use complex numbers for this (roots of unity).
Fast Fourier Transform (FFT)
• The problem of evaluating A(x) at ωn^0 , ωn^1 , … , ωn^n−1 r
educes to
1. evaluating the degree-bound n/2 polynomials Aeven(x) and
Aodd(x) at the points (ωn^0)^2 ,(ωn^1)^2 , … , (ωn^n−1)
^2.
2. 2. combining the results by A(x) = Aeven(x2) + xAodd(x2).
• Why bother?
– The list (ωn^0)^2 ,(ωn^1)^2 , … , (ωn^n−1)^2 does not c
ontain n distinct values, but n/2 complex n/2-th roots of unit
y.
– Polynomials Aeven and Aodd are recursively evaluated at th
e n/2 complex n/2-th roots of unity.
– Subproblems have exactly the same form as the original pro
blem, but are half the size.
• Example:
• Algorithm:
• To apply this algorithm, ‘m’ should be a power of 2.We should pad extra
zeros to the polynomial to ensure that length of the array is a power of 2. This
algorithm returns an array of complex numbers which is then used for point-
wise multiplication.
• Below is the tree of input vectors to the recursive calls of the FFT procedure.
The initial invocation is for n = 8.
• Inverse Fourier Transform:
• Once we perform point-wise multiplication on the Fourier
Transforms of A and B and get C (an array of Complex
Numbers), we need to convert it back to coefficient form to get
the final answer.
• In matrix form:
• Let's use F to denote the matrix of primitive roots.
• It turns out that F^-1 looks the same. In place of ω, the inverse
Fourier Matrix uses ω^-1.
– if ω = a+ib => ω^-1 = a-ib
– if ω = e^2Πi/k => ω^-1 = e^-2Πi/k
• So, F^-1: