Polynomials and FFT
-
Upload
ivana-calhoun -
Category
Documents
-
view
75 -
download
3
description
Transcript of Polynomials and FFT
![Page 1: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/1.jpg)
Polynomials and FFT
Lecture 11
Prof. Dr. Aydın Öztürk
![Page 2: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/2.jpg)
Polynomials
A polynomial in the variable x is defined as
where are the
coefficiens of the polynomial.
1
0)(
n
j
jj xaxA
110 ,, naaa
![Page 3: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/3.jpg)
Polynomials(cont.)
A polynomial A(x) is said have degree k if its highest non-zero coefficient is ak.
Any integer strictly greather than the degree of a polynomial is a degree bound of that polynomial.
Therefore, the degree of a polynomial of degree bound n may be any integer between 0 and n-1.
![Page 4: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/4.jpg)
Polynomial addition
If A(x) and B(x) are polynomials of degree bound n, their sum is a polynomial C(x) s.t.
C(x)= A(x)+ B(x)
For all x underlying their field F that is if
jjj
jn
jj
jn
jj
jn
jj
bac
xcxC
xbxBxaxA
where
)(
then
)( and )(
1
0
1
0
1
0
![Page 5: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/5.jpg)
Polynomial addition(cont.)Example:
4674)(
then
542)(
91076)(
If
23
3
23
xxxxC
xxxB
xxxxA
![Page 6: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/6.jpg)
Polynomial multiplication
If A(x) and B(x) are polynomials of degree bound n, their product C(x) is a ppolynomial of degree-bound 2n-1 s.t.
C(x)= A(x) B(x)
for all x underlying their field F.
j
kkjkj
jn
jj
jn
jj
jn
jj
bac
xcxC
xbxBxaxA
0
22
0
1
0
1
0
where
)(
then
)( and )(
![Page 7: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/7.jpg)
Polynomial multiplication(cont.)Example:
45867520441412
)()()(
then
542)(
91076)(
If
23456
3
23
xxxxxx
xBxAxC
xxxB
xxxxA
![Page 8: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/8.jpg)
Representation of polynomials
![Page 9: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/9.jpg)
Coefficient representationA coefficient representation of a polynomial
of degree bound n is a vector of coefficients
)(1
0
jn
jj xaxA
),,( 110 naaa a
![Page 10: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/10.jpg)
Coefficient representation(cont.)A coefficient representation is convenient for
certain operations on polynomials.
Example: Evaluating A(x) at x0. Evaluation takes time Θ(n) when Horner’s rule is used:
))))((()( 1020201000 nn axaxaxaxaxA
![Page 11: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/11.jpg)
Point-value representation
A point-value representation of a polynomial A(x) of degree-bound n is a set of poin-value pairs.
s.t. all of the xk are distinct and
With Horners’ method, an n-point evaluation takes Θ(n2).
1,,1,0for )( nkxAy kk
)},(,),,(),,{( 111100 nn yxyxyx
![Page 12: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/12.jpg)
Point-value representation(cont.)
Addition based on point-value representation:
If we have a point value representation for A(x)
and for B(x)
Then a point-value representation for C(x)= A(x)+ B(x) is
)},(,),,(),,{( 111100 nn yxyxyx
)},(,),,(),,{( '11
'11
'00 nn yxyxyx
)},(,),,(),,{( '111
'111
'000 nnn yyxyyxyyx
![Page 13: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/13.jpg)
Point-value representation(cont.)
The time to add two polynomials of degree bound point-value representation is Θ(n).
![Page 14: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/14.jpg)
Point-value representation(cont.)
Multiplication based on point-value representation:
If we have a point value representation for A(x)
and for B(x)
then a point-value representation for C(x)= A(x)B(x) is
)},(,),,(),,{( 12121100 nn yxyxyx
)},(,),,(),,{( '1212
'11
'00 nn yxyxyx
)},(,),,(),,{( '111
'111
'000 nnn yyxyyxyyx
![Page 15: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/15.jpg)
Point-value representation(cont.)
The time to multiply two polynomials of degree bound point-value representation is Θ(n).
![Page 16: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/16.jpg)
Fast multiplication of polinomials
Can we use the linear-time multiplication method for polynomials in point-value form to expedite polynomial multiplication in coefficient form?
The answer hinges on our ability to convert a polynomial quickly from coefficient form to point-value form and vice-versa.
![Page 17: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/17.jpg)
Fast multiplication of polinomials
We can choose the evaluation points carefully, we can convert between representations in Θ(nlg n) time.
If we choose complex roots of unity as the evaluation points, we can produce a point-value representation by taking the Discrete Fourier Transform(DFT) of a coefficient vector
The inverse operation can be performed by taking the inverse DFT of point-value pairs in Θ(nlg n) time.
![Page 18: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/18.jpg)
Fast multiplication of polinomials
110
110
,,
,,
n
n
bbb
aaa
)(),(
)(),(
)(),(
12
122
12
12
02
02
nn
nn
nn
nn
BA
BA
BA
)(
)(
)(
122
12
02
nn
n
n
C
C
C
1210 ,, nccc Ordinary multiplication
Θ(n2 )
Θ(nlg n)
Pointwise multiplication
Θ(n)
Interpolation time
Θ(nlg n)
Coefficient
representation
Point-value
representation
![Page 19: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/19.jpg)
The DFT and FFT
In this section we define• Complex roots of unity,• Define the DFT • Show how the FFT computes the DFT
![Page 20: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/20.jpg)
Complex roots of unityA complex nth root of unity is a complex number ω s.t.
The n roots are:
To interpret this formula we use the defination of exponential of complex number:
1n
1,...,1,0for ,/2 nke nik
)sin()cos( uiueiu
![Page 21: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/21.jpg)
Complex roots of unity
The value is called the principal root of unity.
All of the other complex nth roots of unity are powers of .
The n complex nth roots of unity are:
nin e /2
,,,, 110 nnnn
n
![Page 22: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/22.jpg)
Complex roots of unity
Lemma-1: For any integers n ≥ 0 and d > 0,
Proof:
kn
kni
dkdnidkdn
w
e
e
)(
)(/2
/2
kn
dkdn
![Page 23: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/23.jpg)
Complex roots of unityCorollary: For any even integer n > 0,
Lemma-2: If n > 0 is even then the squares of the nth roots of unity are the (n/2)th roots of unity.
Proof: We have (by lemma-1)
122/ n
n
2
2
2
222/
)(
)(
kn
kn
nn
kn
nkn
nkn
kn
kn 2/
2)(
![Page 24: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/24.jpg)
Complex roots of unity
Lemma-3: For any integer n ≥ 1 and nonnegative integer k not divisible by n,
Proof:
0)(1
0
n
j
jnk
0
1
1)1(
1
1)(
1
1)()(
1
0
kn
k
kn
knn
kn
nkn
n
j
jnk
![Page 25: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/25.jpg)
The DFT
We wish to evaluate a polynomial
of degree bound n at
Without loss of generality, we assume that n is a power of 2.
(We canalways add new high order zero coefficient as necessary)
1
0)(
n
j
jj xaxA
,,,, 110 nnnn
![Page 26: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/26.jpg)
The DFT
Assume that A(x) is given in coefficient form
For k=0,1, ..., n-1 we define
The vector is called the Discrete Fourier Transform(DFT) of the coefficient vector We also write y=DFTn(a).
1
0
)(n
j
kjnj
knk
a
Ay
),,( 110 naaa a
),,( 110 nyyy y),,( 110 naaa a
![Page 27: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/27.jpg)
The FFT(cont.)Let
It follows that
12/1
2531
]1[
12/2
2420
]0[
)(
)(
n
n
nn
xaxaxaaxA
xaxaxaaxA
)()()( 2]1[2]0[ xxAxAxA
![Page 28: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/28.jpg)
The FFT(cont.)The problem of evaluating A(x) at
reduces to
1. Evaluating the degree-bound n/2 polynomials
and at the points
as
2. Combining the results.
110 ,,, nnnn
)(]0[ xA
)(]1[ xA 212120 )(,,)(,)( nnnn
)( knk Ay
![Page 29: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/29.jpg)
Recursive FFT
vector.a be toassumed is 14
13
12
11
12/010
)FFT(-RECURSIVE9
)FFT(-RECURSIVE8
),,,(7
),,,(6
15
4
3
12
][1
)FFT(-RECURSIVE
]1[]0[2/
]1[]0[
]1[]1[
]0[]0[
131]1[
220]0[
/2
yy
yyy
yyy
nk
ay
ay
aaaa
aaaa
e
a
n
alengthn
a
n
kknk
kkk
n
n
nin
return
do
tofor
returnthen
if
![Page 30: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/30.jpg)
Running time of RECURSIVE-FFT
We note that exclusive of the recursive calls, each invocation takes time Θ(n).
The recurrence for the running time is therefore
)lg(
)()2/(2)(
nn
nnTnT
![Page 31: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/31.jpg)
Interpolation
We can write the DFT as the matrix product y = Va that is
1
3
2
1
0
)1)(1()1(3)1(21
)1(3963
)1(2642
132
1
3
2
1
0
1
1
1
1
11111
nnn
nn
nn
nnn
nnnnn
nnnnn
nnnnn
n a
a
a
a
a
y
y
y
y
y
![Page 32: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/32.jpg)
Interpolation(cont.)
Theorem: For j,k=0,1, ..., n-1, the ( j,k) entry of the inverse of matrix is
Given the inverse matrix V -1, we have that
is given by
nkjn
kj /),( )(1 yDFT
n
1
0
1 n
k
kjnkj y
na
![Page 33: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/33.jpg)
Interpolation(cont.)
By using the FFT and the inverse FFT, we can transform a polynomial of degree-bound n back and forth between its coefficient representation and a point-value representation in time Θ(n lg n).
![Page 34: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/34.jpg)
Interpolation(cont.)
Theorem: For any two vectors a and b of length n is a power of 2,
Where the vectors a and b are padded with zero’s to length 2n and
. denotes the componentwise product of two 2n element vectors.
))()(( 221
2 baba nnn DFTDFTDFT
![Page 35: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/35.jpg)
Example
Multiply the following polynomials.
Run time:
432
2
2
67731
)()()(
321)(
21)(
xxxx
xBxAxQ
xxxB
xxxA
)( 2n
![Page 36: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/36.jpg)
Example
Multiply the polynomials in
The Discrete Fourier Transform(DFT) of the coefficient vectors:
DFT(a)=
[4.000, (-0.309 - 2.126i), (0.809 + 1.314i), (0.809 - 1.314i), ( -0.309+ 2.126i)]
DFT(b)=
[6.000, (-0.809 - 3.665i), (0.309 + 1.677i), (0.309 -1.677i), (-0.809 + 3.665i)]
Run time:
))log( nn
)0,0,3,2,1(
)0,0,2,1,1(
b
a
![Page 37: Polynomials and FFT](https://reader033.fdocuments.us/reader033/viewer/2022061616/56812a43550346895d8d6f9d/html5/thumbnails/37.jpg)
Example
DFT(a)∙DFT(b)=
[24.00, (-7.545 + 2.853i), (-1.954 + 1.763i), ( -1.954 - 1.763i), (-7.545 - 2.853i)]
6) 7 7 3 1(
))()((1
baba DFTDFTDFT