Академический Документы
Профессиональный Документы
Культура Документы
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
FFT
Polynomials
Polynomial:
p( x ) 5 2 x 8 x 2 3x 3 4 x 4
In general,
n 1
p ( x ) ai x
i 0
or
p( x ) a0 a1 x a2 x an 1 x
2
FFT
n 1
Polynomial Evaluation
Horners Rule:
n 1
p( x ) ai x
i 0
Given x, we can evaluate p(x) in O(n) time using the equation
p( x ) a0 x ( a1 x ( a2 x ( an 2 xan 1 ) ))
Eval(A,x):
[Where A=(a0,a1,a2,,an-1)]
Else,
Let A=(a1,a2,,an-1)
time]
return a0+x*Eval(A,x)
FFT
Polynomial
Multiplication
Problem
Given coefficients (a ,a ,a ,,a ) and (b ,b ,b ,,b
0
n-1
n-1
n 1
Horners rule doesnt help, since
p( x ) q( x ) ci x
i 0
where
ci a j bi j
j 0
FFT
FFT
n = 1
The numbers 1, , 2, , n-1 are all distinct
Example 1:
x
1
2
3
4
5
6
7
8
9
10
x^2
1
4
9
5
3
3
5
9
4
1
x^3
1
8
5
9
4
7
2
6
3
10
x^4
1
5
4
3
9
9
3
4
5
1
x^5
1
10
1
1
1
10
10
10
1
10
x^6
1
9
3
4
5
5
4
3
9
1
x^7
1
7
9
5
3
8
6
2
4
10
x^8
1
3
5
9
4
4
9
5
3
1
x^9
1
6
4
3
9
2
8
7
5
10
Z*11:
x^10
1
1
1
1
1
1
1
1
1
1
Properties of
Primitive
Roots
of root
Unity
Inverse Property:
If is a primitive
of unity, then
-1
=n-1
n 1
Proof: = =1
n-1
kj
1
(
1
(
1
)
1
11
kj
Proof:
k
k
k
k
1
1
1 1
j 0
Reduction Property: If w is a primitve (2n)-th root of unity,
then 2 is a primitive n-th root of unity.
Proof:
n 1 By the cancellation property, for k=n/2:
0 ( n / 2 ) j 0 n / 2 0 n / 2 0 n / 2 ( n / 2)(1 n / 2 )
j 0
FFT
n-1
polynomial p(x)
The Discrete Fourier Transform is to evaluate p at the
values
1,,2,,n-1
n 1
We produce (y0,y1,y2ij,,yn-1), where yj=p(j)
y j ai
That is,
i 0
FFT
Correctness of the
inverse
DFT
The DFT and inverse DFT really are inverse operations
Proof: Let A=F -1F. We want to show that A=I, where
1 n 1 ki kj
A[i, j ]
n k 0
If i=j, then
1 n 1 ki ki 1 n 1 0 1
A[i, i ] n 1
n k 0
n k 0
n
1 n 1 ( j i ) k
A[i, j ]
0
n k 0
FFT
10
Convolution
The DFT and the
inverse DFT can be
used to multiply two
polynomials
[a0,a1,a2,...,an-1]
[b0,b1,b2,...,bn-1]
[a0,a1,a2,...,an-1,0,0,...,0]
[b0,b1,b2,...,bn-1,0,0,...,0]
DFT
DFT
[y0,y1,y2,...,y2n-1]
[z0,z1,z2,...,z2n-1]
Component
Multiply
[y0z0,y1z1,...,y2n-1z2n-1]
inverse DFT
[c0,c1,c2,...,c2n-1]
FFT(Convolution)
11
FFT
12
FFT
13
14
Java Example:
Multiplying
Big Integers
Setup: Define BigInt class, and include essential
parameters, including the prime, P, and primitive root of
unity, OMEGA.
10;
FFT
15
Java Integer
Multiply
Method
Use convolution to multiply two big integers, this and val:
FFT
16
FFT
17
Support Methods
for Java FFT in Z*p
FFT
18
Non-recursive FFT
There is also a non-recursive version of the
FFT
19
Experimental Results
Log-log scale shows traditional multiply runs in
O(n2) time, while FFT versions are almost linear
FFT
20