Académique Documents
Professionnel Documents
Culture Documents
Polynomials
Real polynomial p in one variable x:
p(x) = anxn + an-1xn-1 + ... +a1x1 + a0
Algorithms Theory
a0 ,..., an R, an 0: coefficients of p
degree of p: highest power of x in p (= n)
Example:
p(x) = 3x3 15x2 + 18x
2. Operations on polynomials
Operations on polynomials
p, q R[ x]
2. Multiplication:
p( x ) = an x n + K + a1 x1 + a0
q( x ) = bn x n + K + b1 x1 + b0
ci =
j =0
i = 0,...,2n.
an+1 = K = a2 n = 0, bn+1 = K = b2 n = 0
p( x ) + q( x ) = (an x n + K + a0 ) + (bn x n + K + b0 )
= (an + bn )x n + K + (a1 + b1 )x1 + (a0 + b0 )
a j bi j
Operations on polynomials
3. Representation of polynomials
p(x) R[x]
1. Coefficient representation
Running time: O(n)
p( x ) = an x n + K + a1 x1 + a0
Example:
p( x ) = 3 x 3 15 x 2 + 18 x
Representation of polynomials
Representation of polynomials
3. Point-value representation
p(x) R[x]
Interpolation lemma:
Any polynomial p(x) R[x] of degree n is uniquely defined by
n+1 pairs (xi, p(xi)), where i = 0,...,n and xi xj for i j.
p( x ) = an ( x x1 )K( x xn )
Example:
The polynomial
Example:
p( x ) = 3 x( x 2 )( x 3)
p( x ) = 3x( x 2 )( x 3)
Operations on polynomials
Operations on polynomials
Addition:
p + q = ( x0 , y0 + z0 ), ( x1 , y1 + z1 ),K, ( xn , yn + zn )
Coefficient representation
Addition:
O(n)
Multiplication:
O(n2)
Evaluation at x0 : O(n)
p q = ( x0 , y0 z0 ), ( x1 , y1 z1 ),K, ( xn , yn zn )
(Condition: n degree(pq))
Point-value representation
p = ( x0 , y0 ), ( x1 , y1 ),K, ( xn , yn )
q = ( x0 , z0 ), ( x1 , z1 ),K, ( xn , zn )
Evaluation at point x: ??
Convert polynomial to coefficient representation
(interpolation)
Polynomial multiplication
10
Divide-and-conquer approach
Idea: (assume n is even)
p( x ) = a0 + a1 x + K + an 1 x n 1
= a0 + a 2 x 2 + K + a n 2 x n 2 +
( x , p( x ))
i
x0 , x1 , K , x2 n 1
und
a1 x + a3 x 3 + K + an 1 x n 1
( x , q( x ))
i
Pointwise multiplication
x a1 + a3 x 2 + K + an 1
( )(
(x )(
= a0 + a 2 x 2 + K + a n 2 x 2
( )
( )
n2 )/ 2
n2 )/ 2
= p0 x 2 + xp1 x 2
Interpolation
pq of degree 2n-2, 2n-1 coefficients
11
12
Representation of p(x)
n = e2i / n
i = 1
e2i = 1
83
n , n ,K, n
0
DFTn ( p ) = ( p( n0 ), p( n1 ),K, p( nn 1 ))
n 1
Example: n = 4
81
84
80 = 1
85
86
41 = e 2i / 4 = cos( / 2) + i sin( / 2) = i
42 = (e2i / 4 ) = cos + i sin = 1
2
87
43 = (e 2i / 4 ) = cos(3 / 2 ) + i sin (3 / 2 ) = i
3
13
14
41 = i
42 = 1
40 = 1
43 = i
15
16
Polynomial multiplication
Cancellation lemma:
For any integers n > 0, k 0 and d > 0 we have:
Evaluation:
2n point-value pairs
i
2n
, p( 2i n )) and ( 2i n , q( 2i n ))
dndk = nk
Pointwise multiplication
2n point-value pairs
Proof:
, pq( 2i n ))
2n
Interpolation
pq of degree 2n-2, 2n-1 coefficients
Therefore:
17
2nn = 21 = 1
18
DFTn ( p ) = ( p( n0 ), p( n1 ),K, p( nn 1 ))
p( x ) = a0 + a1 x + K + an 1 x n 1
= a0 + a 2 x 2 + K + a n 2 x n 2 +
a1 x + a3 x 3 + K + an 1 x n 1
( )(
(x )(
= a0 + a 2 x 2 + K + a n 2 x 2
x a1 + a3 x 2 + K + an 1
( )
( )
= p0 x + xp1 x
2
n 2 )/ 2
n 2 )/ 2
p0 ( x ) = a0 + a2 x + K + an 2 x ( n 2 ) / 2
p1 ( x ) = a1 + a3 x + K + an1 x ( n 2 ) / 2
Winter term 07/08
19
20
p( nk ) = p0 (( nk ) ) + nk p1 (( nk )
2
p0 nk / 2
if
=
k n / 2
p0 n / 2
if
) + p ( ),
p ( 40 ) = p0 ( 20 ) + 40 p1 ( 20 )
k < n/2
+ nk p1 nk /2n / 2 ,
p ( 41 ) = p0 ( 21 ) + 41 p1 ( 21 )
k
n
k
n/2
p ( 42 ) = p0 ( 20 ) + 42 p1 ( 20 )
k n/2
p ( 43 ) = p0 ( 21 ) + 43 p1 ( 21 )
21
Computation of DFTn
22
A further improvement
DFT ( p ) = ( p( ), p( ),K, p(
n
n 1
))
( )
p0 nk/ 2 + nk p1 nk/ 2
p =
p0 nk/2n / 2 + nk p1 nk/2n / 2
k
n
if k < n/ 2
p0 nk / 2 + nk p1 nk/ 2
=
p0 nk/2n / 2 nk n / 2 p1 nk /2n / 2
if k n / 2
if k < n/ 2
if k n / 2
DFTn(p)k =
( DFTn / 2 ( p0 ), DFTn / 2 ( p0 )) k +
n ( DFTn / 2 ( p1 ), DFTn / 2 ( p1 )) k
k
23
p0 ( nk/ 2 ) + nk p1 ( nk/ 2 ) = p( nk )
p0 ( nk/ 2 ) nk p1 ( nk/ 2 ) = p( nk + n / 2 )
24
A further improvement
Example:
Algorithm: FFT
Input: Array a containing the n coefficients of a polynomial p and n = 2k
Output: DFTn(p)
p ( 40 ) = p0 ( 20 ) + 40 p1 ( 20 )
1.
2.
3.
4.
p ( 41 ) = p0 ( 21 ) + 41 p1 ( 21 )
p ( 42 ) = p0 ( 20 ) 40 p1 ( 20 )
p ( 43 ) = p0 ( 21 ) 41 p1 ( 21 )
n = e2i/n
6. = 1
5.
7.
8.
9.
10.
11.
Winter term 07/08
25
FFT: Example
for k = 0 to n/2 1 do
d k = d k[0 ] + d k[1]
d k + n / 2 = d k[0 ] d k[1]
= n
/* = nk*/
return d
26
7. Analysis
p( x ) = 3 x 3 15 x 2 + 18 x + 0
d2 = -15 1 * 21 = -36
k=1;=i
d1 = 15 + i*15
d3 = 15 i*15
FFT(a, 4)
if n = 1 then /* p is constant */
return a
d[0] = FFT([a0, a2, ... , an-2 ], n/2)
d[1] = FFT([a1, a3, ... , an-1], n/2)
T(1) = O(1)
T(n) = 2 T(n/2) + O(n)
= O(n log n)
27
28
Polynomial multiplication
Interpolation
Input:
i
2n
, p( 2i n )) and ( 2i n , q( 2i n ))
Pointwise multiplication
2n point-value pairs
i
2n
, pq( 2i n ))
p( x0 ) = a0 + a1 x0 + K + an1 x0n 1 = y0
p( x1 ) = a0 + a1 x1 + K + an1 x1n1 = y1
p( x2 ) = a0 + a1 x2 + K + an1 x2n1 = y2
M
M
p( xn1 ) = a0 + a1 xn1 + K + an1 xnn11 = yn1
Interpolation
pq of degree 2n-2, 2n-1 coefficients
29
Interpolation
30
Interpolation
Matrix notation:
System of equations
1 x0 L x0n 1 a0 y0
1 x1 L x1n 1 a1 y1
M = M
M
n 1
1 x
a yn 1
x
L
n 1
n 1 n 1
n 1
1 x0 L x0 a0 y0
n 1
1 x1 L x2 a1 y1
M = M
n 1
1 xn1 L xn1 an1 yn1
xi = ni
Definition:
Vn = ( nij )i , j , a = (ai ),
Vn a = y
31
y = ( yi )
a = Vn1 y
32
Interpolation
Interpolation
Consider the entry of Vn1Vn in line i and column j :
Theorem:
For any 0 i, j n 1 we have:
(V )
1
Proof:
ij
Vn1 =
n
1
n
n ij
n
ij
n
We have to show:
(V
n ij
1
n
i , j
i
n
L
L
i ( n 1)
n
M
L
33
Interpolation
34
Interpolation
(V
Vn )ij =
n 1
n ik
k =0
njk =
Summation lemma:
For any integer n > 0, l 0 with n
1 n1 ( i + j ) k
n
n k =0
n 1
l:
n 1
Case 1: i = j
k =0
n 1
1
1
n(i + j )k = n0k = 1
n
n k =0
k =0
lk
n
=0
Proof:
( ) 1 = ( ) 1 = 0
(
)
1
1
i.e. (n 1) i + j n 1
thus n /| i + j :
n 1
k =0
1 n 1 (i + j )k
n
=0
n
k =0
L
L
Lij
Vn1Vn = I n
Case 2: i j,
L
1
L j
n
2j
L n( n 1) j
35
l k
n
l n
n
l
n
n l
n
l
n
36
Interpolation
Interpolation
ai = Vn1 y
y0
1 ni
ni (n 1) y1
,K,
= ,
n M
n n
y
n 1
n 1
= yk
k =0
a=
a=
ik
n
n 1
n 1
1
(r ( n0 ), r ( n1 ),K, r ( n( n1) ))
n
( )
1 n 1
yk ni
n k =0
(( ) (
38
1
a = (r ( n0 ), r ( n1 ),K, r ( n( n1) ))
n
( ))
1
r nn , r nn 1 , K , r n1
n
1
( DFTn (r )) n i
n
1
a0 = ( DFTn (r )) 0
n
Winter term 07/08
37
ai =
r ( x ) = y0 + y1 x + y2 x 2 + L + yn1 x n1
a=
1
n
since
nn = 1
2n point-value pairs
i
2n
, p( 2i n )) und ( 2i n , q( 2i n ))
Pointwise multiplication
2n point-value pairs
(i 0)
i
2n
, pq( 2i n ))
39
40