0% found this document useful (0 votes)
6 views29 pages

Talgo Py M

The document discusses working with polynomials, focusing on coefficient-based representation and common operations such as addition, evaluation, and multiplication. It introduces polynomial evaluation techniques, including direct evaluation and Horner's method, which optimizes the process to O(n) time complexity. Additionally, it covers multi-point polynomial evaluation using the Vandermonde matrix and methods to reduce computational effort for evaluating polynomials at multiple points.

Uploaded by

manishbojja56
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views29 pages

Talgo Py M

The document discusses working with polynomials, focusing on coefficient-based representation and common operations such as addition, evaluation, and multiplication. It introduces polynomial evaluation techniques, including direct evaluation and Horner's method, which optimizes the process to O(n) time complexity. Additionally, it covers multi-point polynomial evaluation using the Vandermonde matrix and methods to reduce computational effort for evaluating polynomials at multiple points.

Uploaded by

manishbojja56
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Contents

1 Working with polynomials

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 1 / 13


Working with polynomials

Section outline

evaluation
Solving
1 Working with polynomials T (n) = 2T (n/2) + bn + c
Coefficient based Multi-point polynomial
representation evaluation by DC
Multi-point polynomial

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 2 / 13


Working with polynomials Coefficient based representation

Coefficient based representation


Consider polynomials of degree n − 1 (coefficients in array):
A(x) = a0 + a1 x + a2 x 2 + . . . + an−1 x n−1
B(x) = b0 + b1 x + b2 x 2 + . . . + bn−1 x n−1
Coefficients are often real numbers (float)

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 3 / 13


Working with polynomials Coefficient based representation

Coefficient based representation


Consider polynomials of degree n − 1 (coefficients in array):
A(x) = a0 + a1 x + a2 x 2 + . . . + an−1 x n−1
B(x) = b0 + b1 x + b2 x 2 + . . . + bn−1 x n−1
Coefficients are often real numbers (float)
Common operations on these are:
Addition
Evaluation at a given set of points
Multiplication

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 3 / 13


Working with polynomials Coefficient based representation

Coefficient based representation


Consider polynomials of degree n − 1 (coefficients in array):
A(x) = a0 + a1 x + a2 x 2 + . . . + an−1 x n−1
B(x) = b0 + b1 x + b2 x 2 + . . . + bn−1 x n−1
Coefficients are often real numbers (float)
Common operations on these are:
Addition
Evaluation at a given set of points
Multiplication
Addition is easily done:
A(x) + B(x) =
(a0 + b0 ) + (a1 + b1 )x + (a2 + b2 )x 2 + . . . + (an−1 + bn−1 )x n−1
TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 3 / 13


Working with polynomials Coefficient based representation

Coefficient based representation


Consider polynomials of degree n − 1 (coefficients in array):
A(x) = a0 + a1 x + a2 x 2 + . . . + an−1 x n−1
B(x) = b0 + b1 x + b2 x 2 + . . . + bn−1 x n−1
Coefficients are often real numbers (float)
Common operations on these are:
Addition
Evaluation at a given set of points
Multiplication
Addition is easily done:
A(x) + B(x) =
(a0 + b0 ) + (a1 + b1 )x + (a2 + b2 )x 2 + . . . + (an−1 + bn−1 )x n−1
Number of steps is proportional to the degree of the polynomials TE
OF
TECHNO
LO

GY
ITU
IAN INST

KH
ARAGPUR
TAdd (n) ∈ O(n)

IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 3 / 13


Working with polynomials Coefficient based representation

Polynomial evaluation
Given A(x) = a0 + a1 x + a2 x 2 + . . . + an−1 x n−1 , how do we
evaluate it at a given value of x?

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 4 / 13


Working with polynomials Coefficient based representation

Polynomial evaluation
Given A(x) = a0 + a1 x + a2 x 2 + . . . + an−1 x n−1 , how do we
evaluate it at a given value of x?
n(n − 1)
Direct evaluation would involve multiplications and n − 1
2
additions, so may be done in O(n2 ) steps

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 4 / 13


Working with polynomials Coefficient based representation

Polynomial evaluation
Given A(x) = a0 + a1 x + a2 x 2 + . . . + an−1 x n−1 , how do we
evaluate it at a given value of x?
n(n − 1)
Direct evaluation would involve multiplications and n − 1
2
additions, so may be done in O(n2 ) steps
Factorisation helps to reduce the number of multiplications
A(x) = a0 + (a1 + (a2 + . . . + an−1 x) x · · · ) x [Horner’s method]
Time complexity of this scheme is:

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 4 / 13


Working with polynomials Coefficient based representation

Polynomial evaluation
Given A(x) = a0 + a1 x + a2 x 2 + . . . + an−1 x n−1 , how do we
evaluate it at a given value of x?
n(n − 1)
Direct evaluation would involve multiplications and n − 1
2
additions, so may be done in O(n2 ) steps
Factorisation helps to reduce the number of multiplications
A(x) = a0 + (a1 + (a2 + . . . + an−1 x) x · · · ) x [Horner’s method]
Time complexity of this scheme is: O(n), actually Θ(n)
float horner(float *A, int deg, float x) {
float sum = A[deg]; // an−1 is in A[deg]
while (deg) {
sum *= x; deg--;
sum += A[deg];
} // a0 is in A[0]
return sum; TE
OF
TECHNO
LO

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

}
19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 4 / 13


Working with polynomials Multi-point polynomial evaluation

Multi-point polynomial evaluation


Evaluation of A(x) at points xi , 0 ≤ i < n may be represented as
x02 . . . x0n−1
    
y0 1 x0 a0
 y1   1 x1 x12 . . . x1n−1   a1
 
 =  .. ..
   
 .. .. .. ..   .. 
 .   . . . . .   . 
yn−1 2 n−1 an−1
1 xn−1 xn−1 . . . xn−1
This may be represented more compactly as y = V(x)a, V being
the Vandermonde matrix in x
Can evaluate y in Θ(n2 ) time by n applications of Horner’s method

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 5 / 13


Working with polynomials Multi-point polynomial evaluation

Multi-point polynomial evaluation


Evaluation of A(x) at points xi , 0 ≤ i < n may be represented as
x02 . . . x0n−1
    
y0 1 x0 a0
 y1   1 x1 x12 . . . x1n−1   a1
 
 =  .. ..
   
 .. .. .. ..   .. 
 .   . . . . .   . 
yn−1 2 n−1 an−1
1 xn−1 xn−1 . . . xn−1
This may be represented more compactly as y = V(x)a, V being
the Vandermonde matrix in x
Can evaluate y in Θ(n2 ) time by n applications of Horner’s method
We may reduce our effort to compute A(1) A(−1) as follows:
AE (x) = a0 + a2 x + a4 x 2 + . . . half size of A(x)
2
AO (x) = a1 + a3 x + a5 x + . . . half size of A(x)
A(x) = AE (x 2 ) + xAO (x 2 )
A(1) = AE (1) + AO (1)
A(−1) = AE (1) − AO (1)
Evaluation is achieved at two points at almost half the effort TE
OF
TECHNO
LO

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

However, time (∝ |points|) is needed for combining the results


yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 5 / 13


Working with polynomials Multi-point polynomial evaluation

Multi-point polynomial evaluation (contd.)


Similarly, A(1), A(ı), A(−1) A(−ı) may be computed as follows:
A(1) = AE (1) + AO (1) A(ı) = AE (−1) + ıAO (−1)
A(−1) = AE (1) − AO (1) A(−ı) = AE (−1) − ıAO (−1)

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 6 / 13


Working with polynomials Multi-point polynomial evaluation

Multi-point polynomial evaluation (contd.)


Similarly, A(1), A(ı), A(−1) A(−ı) may be computed as follows:
A(1) = AE (1) + AO (1) A(ı) = AE (−1) + ıAO (−1)
A(−1) = AE (1) − AO (1) A(−ı) = AE (−1) − ıAO (−1)
Further, AE (1) and AE (−1) may be recursively computed in terms
of AEE (1) and AEO (1); similarly, AO (1) and AO (−1) using AOE (1)
and AOO (1)
At each stage the problem of evaluating a polynomial of degree
n − 1 at n points is achieved through evaluating two polynomials of
degree n2 − 1 at n2 points
Time (∝ |points|) is needed for combining the results

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 6 / 13


Working with polynomials Multi-point polynomial evaluation

Multi-point polynomial evaluation (contd.)


Similarly, A(1), A(ı), A(−1) A(−ı) may be computed as follows:
A(1) = AE (1) + AO (1) A(ı) = AE (−1) + ıAO (−1)
A(−1) = AE (1) − AO (1) A(−ı) = AE (−1) − ıAO (−1)
Further, AE (1) and AE (−1) may be recursively computed in terms
of AEE (1) and AEO (1); similarly, AO (1) and AO (−1) using AOE (1)
and AOO (1)
At each stage the problem of evaluating a polynomial of degree
n − 1 at n points is achieved through evaluating two polynomials of
degree n2 − 1 at n2 points
Time (∝ |points|) is needed for combining the results
This suggests that if n = 2d and we want to evaluate A(x) of
degree n − 1 at suitably chosen n points, we might be able to
develop a divide
( and conquer strategy
a   n=1
So, T (n) = n TE
OF
TECHNO
LO

GY
ITU
+ bn + c n > 1, n = 2d , d ≥ 0

IAN INST

KH
ARAGPUR
2T

IND
 

19 5 1

2
yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 6 / 13


Working with polynomials Solving T (n) = 2T (n/2) + bn + c

Solving T (n) = 2T (n/2) + bn + c


(
a   n=1
T (n) = n
2T + bn + c n > 1, n = 2d , d ≥ 0
2

8.0 b × 8.0 × 1 + c × 1

4.0 4.0 b × 4.0 × 2 + c × 2

2.0 2.0 2.0 2.0 b × 2.0 × 4 + c × 4

1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 a×8

Total: 8 × 3 × b + 7 × c + 8 × a
If n = 2d , summation is: 2d (db + a + c) − c
Asymptotic bound: T (n) ∈ Θ(n lg n) (Θ notation to be studied TE
OF
TECHNO
LO

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

later)
19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 7 / 13


Working with polynomials Solving T (n) = 2T (n/2) + bn + c

Multi-point polynomial evaluation by DC


Note that 1, i, −1, −i are the four roots of unity: ξ40 , ξ41 , ξ42 , ξ43
Now can we extend the computation to evaluate A(x) of degree 7
at 8 points: ξ80 , ξ81 , . . . , ξ87 ?
ℑ ℑ
ξ41 ξ82
ξ83 ξ81
α ξ84 α
ξ42 ξ40 ξ80
O ℜ O ℜ

ξ85 ξ87
ξ43 ξ86

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 8 / 13


Working with polynomials Solving T (n) = 2T (n/2) + bn + c

Multi-point polynomial evaluation by DC


Note that 1, i, −1, −i are the four roots of unity: ξ40 , ξ41 , ξ42 , ξ43
Now can we extend the computation to evaluate A(x) of degree 7
at 8 points: ξ80 , ξ81 , . . . , ξ87 ?
ℑ ℑ
ξ41 ξ82
ξ83 ξ81
α ξ84 α
ξ42 ξ40 ξ80
O ℜ O ℜ

ξ85 ξ87
ξ43 ξ86

2 2 2 ?
Eval AE (x) and AO (x) at: ξ80 , ξ81 , . . . , ξ87 ≡ ξ40 , ξ41 , . . . , ξ43 ?
Note, A(ξ80 ), A(ξ82 ), A(ξ84 ) and A(ξ86 ) already evaluated as A(1), TE
OF
TECHNO
LO

A(ı), A(−1) and A(−ı) (using AE (ξ40 ),AE (ξ42 ), AO (ξ40 ) and AO (ξ42 ))

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 8 / 13


Working with polynomials Solving T (n) = 2T (n/2) + bn + c

Multi-point polynomial evaluating (contd.)


ℑ ℑ
ξ82 ξ41
ξ83 ξ81
ξ84 α α
ξ80 ξ42 ξ40
O ℜ O ℜ

ξ85 ξ87
ξ86 ξ43

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 9 / 13


Working with polynomials Solving T (n) = 2T (n/2) + bn + c

Multi-point polynomial evaluating (contd.)


ℑ ℑ
ξ82 ξ41
ξ83 ξ81
ξ84 α α
ξ80 ξ42 ξ40
O ℜ O ℜ

ξ85 ξ87
ξ86 ξ43

A(ξ81 ) = AE ((ξ81 )2 ) + ξ81 AO ((ξ81 )2 )


= AE (ξ82 ) + ξ81 AO (ξ82 )
= AE (ξ41 ) + ξ81 AO (ξ41 )
5
2 2
A(ξ8 ) = AE ( ξ85 ) + ξ85 AO ( ξ85 )
= AE (ξ88+2 ) + ξ85 AO (ξ88+2 )
= AE (ξ82 ) + ξ85 AO (ξ82 ) TE
OF
TECHNO
LO

GY
ITU
IAN INST

KH
ARAGPUR
AE (ξ41 ) − ξ85 AO (ξ41 )

IND
=
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 9 / 13


Working with polynomials Multi-point polynomial evaluation by DC

Multi-point polynomial evaluation by DC


ℑ ℑ
ξ82 ξ41
ξ83 ξ81
ξ84 α α
ξ80 ξ42 ξ40
O ℜ O ℜ

ξ85 ξ87
ξ86 ξ43

A(ξ87 )
A(ξ83 ) 2 2
2 2 = AE ( ξ87 ) + ξ87 AO ( ξ87 )
= AE ( ξ83 ) + ξ83 AO ( ξ83 )
= AE (ξ88+6 ) + ξ87 AO (ξ88+6 )
= AE (ξ86 ) + ξ83 AO (ξ86 )
= AE (ξ86 ) + ξ87 AO (ξ86 )
= AE (ξ43 ) + ξ83 AO (ξ43 )
= AE (ξ43 ) − ξ87 AO (ξ43 )
TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 10 / 13


Working with polynomials Multi-point polynomial evaluation by DC

Multi-point polynomial evaluation by DC


ℑ ℑ
ξ82 ξ41
ξ83 ξ81
ξ84 α α
ξ80 ξ42 ξ40
O ℜ O ℜ

ξ85 ξ87
ξ86 ξ43

A(ξ87 )
A(ξ83 ) 2 2
2 2 = AE ( ξ87 ) + ξ87 AO ( ξ87 )
= AE ( ξ83 ) + ξ83 AO ( ξ83 )
= AE (ξ88+6 ) + ξ87 AO (ξ88+6 )
= AE (ξ86 ) + ξ83 AO (ξ86 )
= AE (ξ86 ) + ξ87 AO (ξ86 )
= AE (ξ43 ) + ξ83 AO (ξ43 )
= AE (ξ43 ) − ξ87 AO (ξ43 )
TECHNO
OF LO

Divde and conquer scheme considered works for n=8 (8 points)!


TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 10 / 13


Working with polynomials Multi-point polynomial evaluation by DC

Multi-point polynomial evaluation by DC (contd.)


2πr 2π
ı d ı
Let ξ2d = e 2d , a primitive root of x 2 − 1 = 0 (e.g. ξ2d = e 2d ), so
that, gcd(r , 2d ) = 1, therefore, r is odd (r = 2k + 1)
2πr
d ı
For d = 0, x 2 − 1 = 0 ≡ x − 1 = 0 and ξ2d = e 2d ≡ ξ1 = 1

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 11 / 13


Working with polynomials Multi-point polynomial evaluation by DC

Multi-point polynomial evaluation by DC (contd.)


2πr 2π
ı d ı
Let ξ2d = e 2d , a primitive root of x 2 − 1 = 0 (e.g. ξ2d = e 2d ), so
that, gcd(r , 2d ) = 1, therefore, r is odd (r = 2k + 1)
2πr
d ı
For d = 0, x 2 − 1 = 0 ≡ x − 1 = 0 and ξ2d = e 2d ≡ ξ1 = 1
 2πr 2d−1  2π(2k+1) 2d−1
2d−1 ı ı
ξ2d = e 2d = e 2d = eπ(2k+1)ı = eıπ = −1

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 11 / 13


Working with polynomials Multi-point polynomial evaluation by DC

Multi-point polynomial evaluation by DC (contd.)


2πr 2π
ı d ı
Let ξ2d = e 2d , a primitive root of x 2 − 1 = 0 (e.g. ξ2d = e 2d ), so
that, gcd(r , 2d ) = 1, therefore, r is odd (r = 2k + 1)
2πr
d ı
For d = 0, x 2 − 1 = 0 ≡ x − 1 = 0 and ξ2d = e 2d ≡ ξ1 = 1
 2πr 2d−1  2π(2k+1) 2d−1
2d−1 ı ı
ξ2d = e 2d = e 2d = eπ(2k+1)ı = eıπ = −1
2πr
ı d−1
gcd(r , 2d−1 ) = 1, so ξ22d = e 2d−1 is a primitive root of x 2 −1 = 0

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 11 / 13


Working with polynomials Multi-point polynomial evaluation by DC

Multi-point polynomial evaluation by DC (contd.)


2πr 2π
ı d ı
Let ξ2d = e 2d , a primitive root of x 2 − 1 = 0 (e.g. ξ2d = e 2d ), so
that, gcd(r , 2d ) = 1, therefore, r is odd (r = 2k + 1)
2πr
d ı
For d = 0, x 2 − 1 = 0 ≡ x − 1 = 0 and ξ2d = e 2d ≡ ξ1 = 1
 2πr 2d−1  2π(2k+1) 2d−1
2d−1 ı ı
ξ2d = e 2d = e 2d = eπ(2k+1)ı = eıπ = −1
2πr
ı d−1
gcd(r , 2d−1 ) = 1, so ξ22d = e 2d−1 is a primitive root of x 2 − 1 = 0
 2   2 
A ξ2kd = AE ξ2kd + ξ2kd AO ξ2kd , k = 0, . . . , 2d−1 − 1

 k k 
= AE ξ22d ) + ξ2kd AO ( ξ22d
= AE (ξ2kd−1 ) + ξ2kd AO (ξ2kd−1 )

TECHNO
OF LO
TE

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 11 / 13


Working with polynomials Multi-point polynomial evaluation by DC

Multi-point polynomial evaluation by DC (contd.)


2πr 2π
ı d ı
Let ξ2d = e 2d , a primitive root of x 2 − 1 = 0 (e.g. ξ2d = e 2d ), so
that, gcd(r , 2d ) = 1, therefore, r is odd (r = 2k + 1)
2πr
d ı
For d = 0, x 2 − 1 = 0 ≡ x − 1 = 0 and ξ2d = e 2d ≡ ξ1 = 1
 2πr 2d−1  2π(2k+1) 2d−1
2d−1 ı ı
ξ2d = e 2d = e 2d = eπ(2k+1)ı = eıπ = −1
2πr
ı d−1
gcd(r , 2d−1 ) = 1, so ξ22d = e 2d−1 is a primitive root of x 2 − 1 = 0
 2   2 
A ξ2kd = AE ξ2kd + ξ2kd AO ξ2kd , k = 0, . . . , 2d−1 − 1

 k k 
= AE ξ22d ) + ξ2kd AO ( ξ22d
= AE (ξ2kd−1 ) + ξ2kd AO (ξ2kd−1 )
   2   2 
k+2d−1 k+2d−1 k+2d−1 k+2d−1
A ξ2d = AE ξ2 d + ξ2d AO ξ2d
 k d  d−1
 k d 
= AE ξ22d ξ22d + ξ2kd ξ22d AO ξ22d ξ22d TE
OF
TECHNO
LO

GY
ITU
IAN INST

KH
ARAGPUR
= AE (ξ2kd−1 ) − ξ2kd AO (ξ2kd−1 )

IND
 

19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 11 / 13


Working with polynomials Multi-point polynomial evaluation by DC

Multi-point polynomial evaluation by DC (contd.)


When d = 0, the coefficients may be directly returned (base case)
Evaluation of A(x) at points ξ2i d , 0 ≤ i < 2d may be represented as

0 0 2
  d
0 2 −1


y0
 1 ξ ξ . . . ξ  
 2d 2d
2
2d
2d −1  a0
  1 ξ 1d ξ21d . . . ξ21d
 
 y1  
 a1 
2
 =  .. .. .. .. ..
    
 ..  .
 . 
 .   . . . . .  . 
 d 2  d 2d −1 
y2d −1 a2d −1
 d
1 ξ22d −1 ξ22d −1 ... ξ22d −1
We compare this with the definitions of FFT and IFFT
ı ı
−ȷ( 2πk
N )
+ȷ( 2πk
N )
FFTN (k , f ) = N−1 IFFTN (k, f ) = N−1
P P
ı=0 f (n)e ı=0 f (n)e

FFT was invented by Carl Friedrich Gauss and then re-invented


and popularised after 160 years in 1965 by James William Cooley
and John Tukey
By comparison, the evaluation of the polynomial at the roots of
unity may be represented more compactly as y = G2d a, G2d being TE
OF
TECHNO
LO

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

the inverse Fourier transform matrix in ξ2d


19 5 1

yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 12 / 13


Working with polynomials Multi-point polynomial evaluation by DC

Multi-point polynomial evaluation by DC (contd.)


gfft(int n, complex A[], complex F[], int s) {
// FFT: s-=1; IFFT: s=+1
int j, k, sft=n/2; complex omegak, omega;
if (n == 1) { F[0]=A[0]; return } // base case
complex E[n/2], O[n/2], EF[n/2], OF[n/2];
for (j=k=0; k<n; j++,k+=2) {
E[j]=A[k]; O[j]=A[k+1]; // separate out odd/even
}
gfft(n/2, E, EF, s); // solve subproblem recursively
gfft(n/2, O, OF, s); // solve subproblem recursively

omegak = omega = es n i ; // use Euler’s formula
k )
for (k=0; k<n/2; k++, omegak*=omega) { // with A(ξn/2
F[k] = EF[k] + omegak*OF[k]; // compute A(ξnk )
k +n/2
F[k+sft] = EF[k] - omegak*OF[k]; // and A(ξn )
} TE
OF
TECHNO
LO

GY
ITU
IAN INST

KH
ARAGPUR
IND
 

19 5 1

} yog, kms kOflm^

CM (IIT Kharagpur) Algorithms March 21, 2024 13 / 13

You might also like