Beruflich Dokumente
Kultur Dokumente
and
Applications to
Multiplication
Analysis of Algorithms
Prepared by
Reading Selection:
CLR,
Chapter
30
Topics
and
Readings:
Advanced Material :
jp
0 for 1 p n
j=0
Example:
2 i/n
2 i/8
Fourier Matrix
1
1 1
M n ( ) = 1 2 2( n1)
n1
( n1)( n1)
given a =
a
n-1
n1
DFTn (a) = M( ) x a
f0
= where
f
n-1
n-1
fi =
ik
a
k
k=0
-1
1 -ij
Theorem M( ) =
n
proof We must show M( ) M( )-1 = I
-1
ij
1
n
n-1
ik -kj
k=0
1
=
n
n-1
k(i-j)
k=0
0 if i-j 0
=
1 if i-j = 0
n-1
Fourier Transform is
Polynomial Evaluation at the
Roots
of Unity
Input a column
n-vector a = (a0, , an-1)T
Output an n-vector (f0, , fn-1)T which are the
values polynomial f(x)at the n roots of unity
f0
n-1
f(x) = a j x j
j=0
Algorithm FFTn
'
0
'
n
1
2
T
f ,..., f FFTn (( a1 , a3 ,..., an 1 ) )
2
n
[3] For i=0, ..., 1 do f i f i' i fi"
2
f n f i' i f i"
"
0
"
n
1
2
i+
FFT Circuit
(also known as Butterfly
Network)
a0
f
a
M M ( 2 ) 2 DFT ((a , a ,..., a )T )
n
n
0
2
n2
M
2
2
'
fn
1
a
2
n 2
"
a1
f0
a
M M ( 2 ) 3 DFT ((a , a ,..., a )T )
n
n
1
3
n 1
M
2
2
f n"
1
a
2
n 1
'
0
Note: f
'
n
i
2
'
i
=f , f
"
n
i
2
n
f , i=0, ..., 1
2
"
i
n
1
2 2
But n =1, so ( )
= n ( 2 )i 2i
n
for i=0, ..., 1
2
Thus, f i = f + f
'
i
and f
i+
'
=
f
n
i +
i+
n
2
f i"
=f - f
'
i
n
for i=0, ..., 1
2
"
i
n
2 2
"
i
n
for i=0, ..., 1
2
n
2
since ( ) n 1, so = -1
Multipoint Polynomial
Evaluation
n1
Input polynomial f ( x)
i
a
x
i
i 0
Multipoint Polynomial
Evaluation (contd)
Summary of FFT:
method f ( x ) f '( y ) x f "( y )
where y x 2
f '( x), f "( x) both degree halved
needed to only evaluate at half as many points
f ( x) ai xi
and point x0
i 0
output
k
d
f ( x)
k
f ( x)
x x0 for k 0,..., n 1
dx
f ( x) ci ( x x0 )i
i 0
Then
f ( k) ( x0 ) k!ck
Advanced Material:
Further Applications of FFT
1) Convolution: Products and Powers of
Polynomials
Used for for Integer Multiplication
Algorithms
Also used for Filtering on infinite
input streams
2) Division and Inverse of Polynomials
3) Multipoint Evaluation and
Interpolation
n-1
Where
ci = a jbi-j
j=0
define ak = bk = 0
if k< 0 or k>n
a b = FFT
-1
2n
FFT
2n
p(x) = a i x i
i=0
n-1
q(x) = b j x j
j=0
2n-2
n-1
i=0
j=0
Products of m Polynomials
n-1
m(n-1)
k=1
i=0
Pk (x) =
ci x i , where ci = a k,jk
k=1
jk =1
a1 a 2 ... a m =
FFTn-1m FFTn m (a1 ) FFTn m (a 2 ) ... FFTn m (a m )
Wrapped Convolutions
a = (a0, a1, , an-1)T , b = (b0, b1, , bn-1)T
Positive wrapped convolution is
c = (c0, c1, , cn-1)T
i
n-1
j=0
j=i+1
ci = a jbi-j + a jb n+i-j
Negative wrapped convolution is
d = (d0, d1, , dn-1)T
i
n-1
j=0
j=i+1
di = a jbi-j - a jb n+i-j
Application of Wrapped
Convolution to Modular
n-1
Polynomial
Products
i
p(x) = a i x
i=0
n-1
q(x) = b j x
j=0
n-1
-1
n
c = FFT
FFT
(b)
n
n
n
b = b , b , ...,
a = a 0 , a1 , ..., a n-1
n-1
n-1
b n-1
Integer Multiplication by
Polynomial Product (solved via
FFT)
Input n bit integers a,b
define polynomials degree k = n/L
k-1
a(x) = a i x ,
i
0 ai 2
i=0
k-1
b(x) = bi x i ,
0 bi 2L
i=0
so a = a(2 ), b = b(2 )
Integer Multiplication by
Polynomial Product (contd)
Idea
1) Compute c(x) = a(x) b(x)
by convolution
2) Evaluate c(2L) = a b
O(n(logn) 2 ) use L = n
Schnage-Strassen Mult Algorithm
O(n(logn)(loglogn)) use L = n
and wrapped convolution
Pollard Multiplication
Algorithm
n = kL, L = 1 + log k
1) Choose primes P1, P2, P3 where
P1 P2 P3 4 k
and Pi = i 2 + 1, i = O(1)
L
Pollard Multiplication
Algorithm (contd)
3) Evaluate C(2L)
Time Bounds
recursive mults
FFT
k =
s
2
(s-1)
2
if s even
else
FFT
Schnage-Strassen
Multiplication Algorithm
(2) Compute C(x) mod (xk+1) modulo
(22L+1) by wrapped convolution
Requires only k recursive mults on 2L bit
numbers
Time
recursive mults
FFT
Prepared by