1 views

Uploaded by harshit

divide and conquer

- 7472 project2 trc
- MATH_C441_881
- 10_mathematics_SA_2_eBook_new.pdf
- A2T Midyr Exam Outline 2011
- A Level Maths C1-C4 Notes
- Difference of Roots
- 5.1-5.3 H WS Polynomials
- alg1m1l3- adding and subtracting polynomials 2
- pp2 y10 lesson plan
- Korner, T W - Coding and Cryptography
- polynomials study guide
- 25 factoring in algebra
- amc1511
- 2012mm1syllabus
- CSTM 0120 Course Policy (Fall 2014)
- STEP III
- On Quality of Service Optimization with Discrete QoS Options
- Remainder
- Jurdzinski - 2000 - A Discrete Strategy Improvement Algorithm for Solving Parity Games.ps
- Lect7Color.pdf

You are on page 1of 45

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials

Section outline

Multi-point polynomial

evaluation by DC

1 Working with polynomials Divide and Conquer

Coefficient based Strategy

representation Polynomial multiplication

Multi-point polynomial Polynomial multiplication by

evaluation DC (Karatsuba)

Solving Karatsuba multiplication

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

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Coefficient based representation

Consider polynomials of degree n 1 (coefficients in array):

A(x ) = a0 + a1 x + a2 + : : : + an

x2 1x

n 1

B (x ) = b0 + b1 x + b2 x 2 + : : : + bn 1x

n 1

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

TAdd (n) 2 O (n)

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Coefficient based representation

Consider polynomials of degree n 1 (coefficients in array):

A(x ) = a0 + a1 x + a2 + : : : + an

x2 1x

n 1

B (x ) = b0 + b1 x + b2 x 2 + : : : + bn 1x

n 1

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

TAdd (n) 2 O (n)

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Coefficient based representation

Consider polynomials of degree n 1 (coefficients in array):

A(x ) = a0 + a1 x + a2 + : : : + an

x2 1x

n 1

B (x ) = b0 + b1 x + b2 x 2 + : : : + bn 1x

n 1

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

TAdd (n) 2 O (n)

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Coefficient based representation

Consider polynomials of degree n 1 (coefficients in array):

A(x ) = a0 + a1 x + a2 + : : : + an

x2 1x

n 1

B (x ) = b0 + b1 x + b2 x 2 + : : : + bn 1x

n 1

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

TAdd (n) 2 O (n)

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

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 [Horners method]

Time complexity of this scheme is: O (n), actually (n)

float horner(float *A, int deg, float x) f

float sum = A[deg]; // an 1 is in A[deg]

while (deg) f

sum *= x; deg--;

sum += A[deg];

g // a0 is in A[0]

return sum; OF

TECHNO

LO

g

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

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 [Horners method]

Time complexity of this scheme is: O (n), actually (n)

float horner(float *A, int deg, float x) f

float sum = A[deg]; // an 1 is in A[deg]

while (deg) f

sum *= x; deg--;

sum += A[deg];

g // a0 is in A[0]

return sum; OF

TECHNO

LO

g

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

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 [Horners method]

Time complexity of this scheme is: O (n), actually (n)

float horner(float *A, int deg, float x) f

float sum = A[deg]; // an 1 is in A[deg]

while (deg) f

sum *= x; deg--;

sum += A[deg];

g // a0 is in A[0]

return sum; OF

TECHNO

LO

g

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Coefficient based representation

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 [Horners method]

Time complexity of this scheme is: O (n), actually (n)

float horner(float *A, int deg, float x) f

float sum = A[deg]; // an 1 is in A[deg]

while (deg) f

sum *= x; deg--;

sum += A[deg];

g // a0 is in A[0]

return sum; OF

TECHNO

LO

g

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation

Evaluation of A(x ) at points xi , 0 i < n may be represented as

2 3 2 32 3

y0 1 x0 x02 : : : x0n 1 a0

6 y1 7 6 1 x1 x12 : : : x1n 1 7 6

7 6 a1

7

7=6 . .

6 7 6 7

6 . .. .. .. 76 . 7

4 .. 5 4 .. .. . . . 5 4 .

. 5

yn 1 1 xn 1 xn2 1 : : : xnn 11 an 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 Horners method

We may reduce our effort to compute A(1) A( 1) as follows:

AE (x ) = a0 + a2 x + a4 x 2 + : : :

AO (x ) = a1 + a3 x + a5 x 2 + : : :

A(x ) = AE (x 2 ) + xAO (x 2 )

A(1) = AE (1) + AO (1)

A( 1) = AE (1) AO (1) TE

OF

TECHNO

LO

GY

ITU

IAN INST

KH

ARAGPUR

IND

Evaluation is achieved at two points at almost half the effort

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation

Evaluation of A(x ) at points xi , 0 i < n may be represented as

2 3 2 32 3

y0 1 x0 x02 : : : x0n 1 a0

6 y1 7 6 1 x1 x12 : : : x1n 1 7 6

7 6 a1

7

7=6 . .

6 7 6 7

6 . .. .. .. 76 . 7

4 .. 5 4 .. .. . . . 5 4 .

. 5

yn 1 1 xn 1 xn2 1 : : : xnn 11 an 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 Horners method

We may reduce our effort to compute A(1) A( 1) as follows:

AE (x ) = a0 + a2 x + a4 x 2 + : : :

AO (x ) = a1 + a3 x + a5 x 2 + : : :

A(x ) = AE (x 2 ) + xAO (x 2 )

A(1) = AE (1) + AO (1)

A( 1) = AE (1) AO (1) TE

OF

TECHNO

LO

GY

ITU

IAN INST

KH

ARAGPUR

IND

Evaluation is achieved at two points at almost half the effort

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation

Note that A(1), A({), A( 1) A( {) may be computed as follows:

A(1) = AE (1) + AO (1)

A( 1) = AE (1) AO (1)

A({) = 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) may be recursively computed in

terms of AOE (1) and AOO (1)

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) =

2T

n

2

+ bn + c n > 1; n = 2d ; d 0

Asymptotic bound: T (n) 2 (n lg n)

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation

Note that A(1), A({), A( 1) A( {) may be computed as follows:

A(1) = AE (1) + AO (1)

A( 1) = AE (1) AO (1)

A({) = 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) may be recursively computed in

terms of AOE (1) and AOO (1)

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) =

2T

n

2

+ bn + c n > 1; n = 2d ; d 0

Asymptotic bound: T (n) 2 (n lg n)

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation

Note that A(1), A({), A( 1) A( {) may be computed as follows:

A(1) = AE (1) + AO (1)

A( 1) = AE (1) AO (1)

A({) = 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) may be recursively computed in

terms of AOE (1) and AOO (1)

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) =

2T

n

2

+ bn + c n > 1; n = 2d ; d 0

Asymptotic bound: T (n) 2 (n lg n)

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

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

(

a n=1

T (n) =

2T

n

2

+ bn + c n > 1; n = 2d ; d 0

8.0 b 8:0 1:0 + c 1:0

Total: 8 3 b + 7 c + 8 a

If n = 2d , summation is: 2d (db + a + c ) c

Asymptotic bound: T (n) 2 (n lg n)

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

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

(

a n=1

T (n) =

2T

n

2

+ bn + c n > 1; n = 2d ; d 0

8.0 b 8:0 1:0 + c 1:0

Total: 8 3 b + 7 c + 8 a

If n = 2d , summation is: 2d (db + a + c ) c

Asymptotic bound: T (n) 2 (n lg n)

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

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

(

a n=1

T (n) =

2T

n

2

+ bn + c n > 1; n = 2d ; d 0

8.0 b 8:0 1:0 + c 1:0

Total: 8 3 b + 7 c + 8 a

If n = 2d , summation is: 2d (db + a + c ) c

Asymptotic bound: T (n) 2 (n lg n)

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

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

40 , 41 , 42 , 43

We want to compute A(x ) of degree 7 at 8 points: 80 ; 81 ; : : : ; 87

= =

1 82

4

83 81

84

42 40 80

O < O <

85 87

43 86

0

Eval AE (x ) and AO (x ) at 82 1 , . . . , 82 3 40 , 41 , . . . , 43

82 ,

Note, A(80 ), A(82 ), A(84 ) and A(86 ) already evaluated as A(1),

A({), A( 1) and A( {) using AE (40 ),AE (42 ), AO (40 ) and AO (42 )

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

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

40 , 41 , 42 , 43

We want to compute A(x ) of degree 7 at 8 points: 80 ; 81 ; : : : ; 87

= =

1 82

4

83 81

84

42 40 80

O < O <

85 87

43 86

0

Eval AE (x ) and AO (x ) at 82 1 , . . . , 82 3 40 , 41 , . . . , 43

82 ,

Note, A(80 ), A(82 ), A(84 ) and A(86 ) already evaluated as A(1),

A({), A( 1) and A( {) using AE (40 ),AE (42 ), AO (40 ) and AO (42 )

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

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

= =

82 41

83 81

84

80 42 40

O < O <

85 87

6

8 43

A(81 )= AE (82 ) + 8 AO (82 )

= AE (41 ) + 8 AO (41 )

2 2

A(8 ) =

5 AE ( 85 ) + 85 AO ( 85 )

= AE (88+2 ) + 85 AO (88+2 )

= AE (82 ) + 85 AO (82 )

= AE (41 ) 8 AO (41 )

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

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

= =

82 41

83 81

84

80 42 40

O < O <

85 87

6

8 43

A(81 )= AE (82 ) + 8 AO (82 )

= AE (41 ) + 8 AO (41 )

2 2

A(8 ) =

5 AE ( 85 ) + 85 AO ( 85 )

= AE (88+2 ) + 85 AO (88+2 )

= AE (82 ) + 85 AO (82 )

= AE (41 ) 8 AO (41 )

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation by DC

= =

2

41

83 8

81

84

80 42 40

O < O <

85 87

86 43

2 2

A(83 )= AE ( 83 ) + 83 AO ( 83 )

= AE (86 ) + 83 AO (86 )

= AE (43) + 83AO (43)

A(8 ) = AE ( 87 ) + 87 AO ( 87 )

7 2 2

= AE (86 ) + 87 AO (86 ) = AE (43) 83AO (43) TE

OF

TECHNO

LO

GY

ITU

IAN INST

KH

ARAGPUR

Divde and conquer works for n=8 (8 points)

IND

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation by DC

= =

2

41

83 8

81

84

80 42 40

O < O <

85 87

86 43

2 2

A(83 )= AE ( 83 ) + 83 AO ( 83 )

= AE (86 ) + 83 AO (86 )

= AE (43) + 83AO (43)

A(8 ) = AE ( 87 ) + 87 AO ( 87 )

7 2 2

= AE (86 ) + 87 AO (86 ) = AE (43) 83AO (43) TE

OF

TECHNO

LO

GY

ITU

IAN INST

KH

ARAGPUR

Divde and conquer works for n=8 (8 points)

IND

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation by DC

2

Let 2d = e 2d

i

; in general a primitive root of x 2

d

1 = 0, so that

= e , gcd(r ; 2d ) = 1, so r is odd (r = 2k + 1)

2 r

2d 2d

i

2 2 d 1

d 1

2 = e = e = e 2k 1 i = e2ki ei = 1

2 r 2 (2k +1)

2 d 1 i i ( + )

2d 2d

d

i

Also, gcd(r ; 2d 1 ) = 1, so 22 = e

2 r

is a primitive 2d 1 -th root

d

2d 1

of unity

A 2kd = AE kd 2 + 2kd AO 2kd 2 ; k = 0; : : : ; 2d

2

1 1

k

= AE 22d ) + 2kd AO ( 22d

k

2 2

A k +2d

2d

1

= AE 2d

k +2d 1 k +2d 1

2d

AO+ k +2d 1

2d

= AE 2d

2 k 2d

2d +

k 2d 1 A

d

2 2 d O 2 k 2d

2d 2

d

= ( ) ( )

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

AE 2kd 1 k A k

ARAGPUR

IND

2d O 2d 1

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation by DC

2

Let 2d = e 2d

i

; in general a primitive root of x 2

d

1 = 0, so that

= e , gcd(r ; 2d ) = 1, so r is odd (r = 2k + 1)

2 r

2d 2d

i

2 2 d 1

d 1

2 = e = e = e 2k 1 i = e2ki ei = 1

2 r 2 (2k +1)

2 d 1 i i ( + )

2d 2d

d

i

Also, gcd(r ; 2d 1 ) = 1, so 22 = e

2 r

is a primitive 2d 1 -th root

d

2d 1

of unity

A 2kd = AE kd 2 + 2kd AO 2kd 2 ; k = 0; : : : ; 2d

2

1 1

k

= AE 22d ) + 2kd AO ( 22d

k

2 2

A k +2d

2d

1

= AE 2d

k +2d 1 k +2d 1

2d

AO+ k +2d 1

2d

= AE 2d

2 k 2d

2d +

k 2d 1 A

d

2 2 d O 2 k 2d

2d 2

d

= ( ) ( )

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

AE 2kd 1 k A k

ARAGPUR

IND

2d O 2d 1

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation by DC

2

Let 2d = e 2d

i

; in general a primitive root of x 2

d

1 = 0, so that

= e , gcd(r ; 2d ) = 1, so r is odd (r = 2k + 1)

2 r

2d 2d

i

2 2 d 1

d 1

2 = e = e = e 2k 1 i = e2ki ei = 1

2 r 2 (2k +1)

2 d 1 i i ( + )

2d 2d

d

i

Also, gcd(r ; 2d 1 ) = 1, so 22 = e

2 r

is a primitive 2d 1 -th root

d

2d 1

of unity

A 2kd = AE kd 2 + 2kd AO 2kd 2 ; k = 0; : : : ; 2d

2

1 1

k

= AE 22d ) + 2kd AO ( 22d

k

2 2

A k +2d

2d

1

= AE 2d

k +2d 1 k +2d 1

2d

AO+ k +2d 1

2d

= AE 2d

2 k 2d

2d +

k 2d 1 A

d

2 2 d O 2 k 2d

2d 2

d

= ( ) ( )

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

AE 2kd 1 k A k

ARAGPUR

IND

2d O 2d 1

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation by DC

2

Let 2d = e 2d

i

; in general a primitive root of x 2

d

1 = 0, so that

= e , gcd(r ; 2d ) = 1, so r is odd (r = 2k + 1)

2 r

2d 2d

i

2 2 d 1

d 1

2 = e = e = e 2k 1 i = e2ki ei = 1

2 r 2 (2k +1)

2 d 1 i i ( + )

2d 2d

d

i

Also, gcd(r ; 2d 1 ) = 1, so 22 = e

2 r

is a primitive 2d 1 -th root

d

2d 1

of unity

A 2kd = AE kd 2 + 2kd AO 2kd 2 ; k = 0; : : : ; 2d

2

1 1

k

= AE 22d ) + 2kd AO ( 22d

k

2 2

A k +2d

2d

1

= AE 2d

k +2d 1 k +2d 1

2d

AO+ k +2d 1

2d

= AE 2d

2 k 2d

2d +

k 2d 1 A

d

2 2 d O 2 k 2d

2d 2

d

= ( ) ( )

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

AE 2kd 1 k A k

ARAGPUR

IND

2d O 2d 1

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation by DC

2

Let 2d = e 2d

i

; in general a primitive root of x 2

d

1 = 0, so that

= e , gcd(r ; 2d ) = 1, so r is odd (r = 2k + 1)

2 r

2d 2d

i

2 2 d 1

d 1

2 = e = e = e 2k 1 i = e2ki ei = 1

2 r 2 (2k +1)

2 d 1 i i ( + )

2d 2d

d

i

Also, gcd(r ; 2d 1 ) = 1, so 22 = e

2 r

is a primitive 2d 1 -th root

d

2d 1

of unity

A 2kd = AE kd 2 + 2kd AO 2kd 2 ; k = 0; : : : ; 2d

2

1 1

k

= AE 22d ) + 2kd AO ( 22d

k

2 2

A k +2d

2d

1

= AE 2d

k +2d 1 k +2d 1

2d

AO+ k +2d 1

2d

= AE 2d

2 k 2d

2d +

k 2d 1 A

d

2 2 d O 2 k 2d

2d 2

d

= ( ) ( )

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

AE 2kd 1 k A k

ARAGPUR

IND

2d O 2d 1

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation by DC

Evaluation of A(x ) at points 2i , 0 i < 2d may be represented as

2 3

d

d

2

y0

3

6

1 0

2d

0 2

2d

::: 20d 2 1

7

2

a0

3

6 d 76

6 y1 7 6 1 1 1 2 ::: 21d 2 1

76 a1 7

6

6

4

..

7

7

5

= 6

6 .. ..

2d

..

2d

.. .. 76

74 ..

7

7

5

. 6 . . . . . 7 .

4 2 2d 1 5

y2d a2d

22d 22d ::: 22d

d 1 d 1 d 1

1 1 1

the Fourier transform matrix in 2d

FFT was invented by Carl Friedrich Gauss

Re-invented and popularised after 160 years in 1965 by James

William Cooley and John Tukey TE

OF

TECHNO

LO

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Multi-point polynomial evaluation by DC

fft(int n, complex A[], complex F[]) f

int j, k, sft=n/2; complex omegak, omega;

if (n == 1) f F[0]=A[0]; return g // base case

complex E[n/2], O[n/2], EF[n/2], OF[n/2];

for (j=k=0; k<n; j++,k+=2) f

E[j]=A[k]; O[j]=A[k+1]; // separate out odd/even

g

fft(n/2, E, EF); // solve sub-problem recursively

fft(n/2, O, OF); // solve sub-problem recursively

2

omegak = omega = e n i ; // use Eulers formula

for (k=0; k<n/2; k++, omegak*=omega) f // with A(nk=2 )

F[k] = EF[k] + omegak*OF[k]; // compute A(nk )

F[k+sft] = EF[k] - omegak*OF[k]; // and A(n )

k +n=2

g

g

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Divide and Conquer Strategy

of the same type and of similarly sizes

2 Solve each subproblem recursively (the smallest possible size of a

subproblem is a base-case)

3 Combine these solutions into a solution for the main problem

A few examples:

Polynomial multiplication

Merge sort

Quick sort

Maximum Sum Subarray

Matrix Multiplication OF

TECHNO

LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Polynomial multiplication

Polynomial multiplication

P2 P

C (x ) = A(x )B (x ) = =

2n

ci xi , ci aj bi j

i =0

0 j ;i j n 1

[Note the convolution of the coefficients]

Time complexity of this scheme is: O (n2 ), actually (n2 )

float polyMul(float *A, *B, *C, int deg) f

int j, k;

for (j=0; j<=2*deg-2; j++) C[j] = 0;

for (j=0; j<=deg-1; j++)

for (k=0; k<=deg-1; k++)

C[j+k] += A[j] * B[k];

g

Can we do better than (n2 ), how could we do that?

Since the time grows with the degree, can we compute the TE

OF

TECHNO

LO

GY

ITU

product multiplying smaller polynomials?

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Polynomial multiplication

Polynomial multiplication

P2 P

C (x ) = A(x )B (x ) = =

2n

ci xi , ci aj bi j

i =0

0 j ;i j n 1

[Note the convolution of the coefficients]

Time complexity of this scheme is: O (n2 ), actually (n2 )

float polyMul(float *A, *B, *C, int deg) f

int j, k;

for (j=0; j<=2*deg-2; j++) C[j] = 0;

for (j=0; j<=deg-1; j++)

for (k=0; k<=deg-1; k++)

C[j+k] += A[j] * B[k];

g

Can we do better than (n2 ), how could we do that?

Since the time grows with the degree, can we compute the TE

OF

TECHNO

LO

GY

ITU

product multiplying smaller polynomials?

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Polynomial multiplication

Polynomial multiplication

P2 P

C (x ) = A(x )B (x ) = =

2n

ci xi , ci aj bi j

i =0

0 j ;i j n 1

[Note the convolution of the coefficients]

Time complexity of this scheme is: O (n2 ), actually (n2 )

float polyMul(float *A, *B, *C, int deg) f

int j, k;

for (j=0; j<=2*deg-2; j++) C[j] = 0;

for (j=0; j<=deg-1; j++)

for (k=0; k<=deg-1; k++)

C[j+k] += A[j] * B[k];

g

Can we do better than (n2 ), how could we do that?

Since the time grows with the degree, can we compute the TE

OF

TECHNO

LO

GY

ITU

product multiplying smaller polynomials?

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Polynomial multiplication

P2 P

C (x ) = A(x )B (x ) = =

2n

ci xi , ci aj bi j

i =0

0 j ;i j n 1

[Note the convolution of the coefficients]

Time complexity of this scheme is: O (n2 ), actually (n2 )

float polyMul(float *A, *B, *C, int deg) f

int j, k;

for (j=0; j<=2*deg-2; j++) C[j] = 0;

for (j=0; j<=deg-1; j++)

for (k=0; k<=deg-1; k++)

C[j+k] += A[j] * B[k];

g

Can we do better than (n2 ), how could we do that?

Since the time grows with the degree, can we compute the TE

OF

TECHNO

LO

GY

ITU

product multiplying smaller polynomials?

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Polynomial multiplication by DC (Karatsuba)

A(x ) = AL (x ) + x t AH (x ), AL (x ) = a0 + a1 x + : : : + at 1 x t 1,

AH (x ) = at + at +1 x + : : : + an 1 x n 1 t

jnk

t= , so that both AL (x ) and AH (x ) are nearly equal

2

Ideally, n is a power of 2, n = 2d ; d 0

Similarly, B (x ) = BL + x t BH , where BL BL(x ) and BH BH (x )

C (x ) = A(x )B (x ) = x 2t AH BH + (AH BL + ALBH ) + ALBL

xt

Smaller polynomials recursively multiplied until the degree

reduces to 0, when the coefficients are directly multiplied

(

a [n = 1]

TmulHL (n) = n

4TmulHL

2

+ bn + c [n > 1; n = 2d ; d 0]

Solution (by standard methods): TmulHL (n) 2 n2

TECHNO

OF LO

TE

GY

ITU

No improvement, but why? There are too many sub-problems

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Polynomial multiplication by DC (Karatsuba)

A(x ) = AL (x ) + x t AH (x ), AL (x ) = a0 + a1 x + : : : + at 1 x t 1,

AH (x ) = at + at +1 x + : : : + an 1 x n 1 t

jnk

t= , so that both AL (x ) and AH (x ) are nearly equal

2

Ideally, n is a power of 2, n = 2d ; d 0

Similarly, B (x ) = BL + x t BH , where BL BL(x ) and BH BH (x )

C (x ) = A(x )B (x ) = x 2t AH BH + (AH BL + ALBH ) + ALBL

xt

Smaller polynomials recursively multiplied until the degree

reduces to 0, when the coefficients are directly multiplied

(

a [n = 1]

TmulHL (n) = n

4TmulHL

2

+ bn + c [n > 1; n = 2d ; d 0]

Solution (by standard methods): TmulHL (n) 2 n2

TECHNO

OF LO

TE

GY

ITU

No improvement, but why? There are too many sub-problems

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Polynomial multiplication by DC (Karatsuba)

A(x ) = AL (x ) + x t AH (x ), AL (x ) = a0 + a1 x + : : : + at 1 x t 1,

AH (x ) = at + at +1 x + : : : + an 1 x n 1 t

jnk

t= , so that both AL (x ) and AH (x ) are nearly equal

2

Ideally, n is a power of 2, n = 2d ; d 0

Similarly, B (x ) = BL + x t BH , where BL BL(x ) and BH BH (x )

C (x ) = A(x )B (x ) = x 2t AH BH + (AH BL + ALBH ) + ALBL

xt

Smaller polynomials recursively multiplied until the degree

reduces to 0, when the coefficients are directly multiplied

(

a [n = 1]

TmulHL (n) = n

4TmulHL

2

+ bn + c [n > 1; n = 2d ; d 0]

Solution (by standard methods): TmulHL (n) 2 n2

TECHNO

OF LO

TE

GY

ITU

No improvement, but why? There are too many sub-problems

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Polynomial multiplication by DC (Karatsuba)

A(x ) = AL (x ) + x t AH (x ), AL (x ) = a0 + a1 x + : : : + at 1 x t 1,

jnk

t= , so that both AL (x ) and AH (x ) are nearly equal

2

Ideally, n is a power of 2, n = 2d ; d 0

Similarly, B (x ) = BL + x t BH , where BL BL(x ) and BH BH (x )

C (x ) = A(x )B (x ) = x 2t AH BH + (AH BL + ALBH ) + ALBL

xt

Smaller polynomials recursively multiplied until the degree

reduces to 0, when the coefficients are directly multiplied

(

a [n = 1]

TmulHL (n) = n

4TmulHL

2

+ bn + c [n > 1; n = 2d ; d 0]

Solution (by standard methods): TmulHL (n) 2 n2

TECHNO

OF LO

TE

GY

ITU

No improvement, but why? There are too many sub-problems

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Polynomial multiplication by DC (Karatsuba)

A(x ) = AL (x ) + x t AH (x ), AL (x ) = a0 + a1 x + : : : + at 1 x t 1,

jnk

t= , so that both AL (x ) and AH (x ) are nearly equal

2

Ideally, n is a power of 2, n = 2d ; d 0

Similarly, B (x ) = BL + x t BH , where BL BL(x ) and BH BH (x )

C (x ) = A(x )B (x ) = x 2t AH BH + (AH BL + ALBH ) + ALBL

xt

Smaller polynomials recursively multiplied until the degree

reduces to 0, when the coefficients are directly multiplied

(

a [n = 1]

TmulHL (n) = n

4TmulHL

2

+ bn + c [n > 1; n = 2d ; d 0]

Solution (by standard methods): TmulHL (n) 2 n2

TECHNO

OF LO

TE

GY

ITU

No improvement, but why? There are too many sub-problems

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Karatsuba multiplication

Karatsuba multiplication

C (x ) = A(x )B (x ) = x 2t AH BH

+ x t (AH BL + ALBH ) + ALBL

AH BL + AL BH = (AH + AL )(BH + BL ) AH BH AL BL

Store and reuse AH BH and AL BL computed earlier

Smaller polynomials recursively multiplied until the degree

reduces to 0, when the coefficients are directly multiplied

(

a [n = 1]

TmulHL (n) = n

0 0

3TmulHL

2

+ b n + c [n > 1; n = 2d ; d 0]

More polynomial additions, so the constants b0 and c 0 are

expected to be somewhat larger than before

Solution (by standard methods): TmulHL (n) 2 nlog2 3 ,

log2 3 = 1:58496 : : :

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Karatsuba multiplication

Karatsuba multiplication

C (x ) = A(x )B (x ) = x 2t AH BH

+ x t (AH BL + ALBH ) + ALBL

AH BL + AL BH = (AH + AL )(BH + BL ) AH BH AL BL

Store and reuse AH BH and AL BL computed earlier

Smaller polynomials recursively multiplied until the degree

reduces to 0, when the coefficients are directly multiplied

(

a [n = 1]

TmulHL (n) = n

0 0

3TmulHL

2

+ b n + c [n > 1; n = 2d ; d 0]

More polynomial additions, so the constants b0 and c 0 are

expected to be somewhat larger than before

Solution (by standard methods): TmulHL (n) 2 nlog2 3 ,

log2 3 = 1:58496 : : :

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Karatsuba multiplication

Karatsuba multiplication

C (x ) = A(x )B (x ) = x 2t AH BH

+ x t (AH BL + ALBH ) + ALBL

AH BL + AL BH = (AH + AL )(BH + BL ) AH BH AL BL

Store and reuse AH BH and AL BL computed earlier

Smaller polynomials recursively multiplied until the degree

reduces to 0, when the coefficients are directly multiplied

(

a [n = 1]

TmulHL (n) = n

0 0

3TmulHL

2

+ b n + c [n > 1; n = 2d ; d 0]

More polynomial additions, so the constants b0 and c 0 are

expected to be somewhat larger than before

Solution (by standard methods): TmulHL (n) 2 nlog2 3 ,

log2 3 = 1:58496 : : :

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

Working with polynomials Karatsuba multiplication

Karatsuba multiplication

+ x t (AH BL + ALBH ) + ALBL

AH BL + AL BH = (AH + AL )(BH + BL ) AH BH AL BL

Store and reuse AH BH and AL BL computed earlier

Smaller polynomials recursively multiplied until the degree

reduces to 0, when the coefficients are directly multiplied

(

a [n = 1]

TmulHL (n) = n

0 0

3TmulHL

2

+ b n + c [n > 1; n = 2d ; d 0]

More polynomial additions, so the constants b0 and c 0 are

expected to be somewhat larger than before

Solution (by standard methods): TmulHL (n) 2 nlog2 3 ,

log2 3 = 1:58496 : : :

TECHNO

OF LO

TE

GY

ITU

IAN INST

KH

ARAGPUR

IND

19 5 1

yog, km s kOflm^

- 7472 project2 trcUploaded byapi-376314311
- MATH_C441_881Uploaded bytourist101
- 10_mathematics_SA_2_eBook_new.pdfUploaded bychamarthi_r
- A2T Midyr Exam Outline 2011Uploaded bykahitchcock
- A Level Maths C1-C4 NotesUploaded bybloodyinspired
- Difference of RootsUploaded bySachin Chakradhar
- 5.1-5.3 H WS PolynomialsUploaded bykcarvey
- alg1m1l3- adding and subtracting polynomials 2Uploaded byapi-276774049
- pp2 y10 lesson planUploaded byapi-321025320
- Korner, T W - Coding and CryptographyUploaded bycliftoncage
- polynomials study guideUploaded byapi-310503032
- 25 factoring in algebraUploaded byapi-299265916
- amc1511Uploaded byMahnoor Abbas
- 2012mm1syllabusUploaded bySameer Sharma
- CSTM 0120 Course Policy (Fall 2014)Uploaded byCTL
- STEP IIIUploaded byhmphry
- On Quality of Service Optimization with Discrete QoS OptionsUploaded byNogbou Germain YAO
- RemainderUploaded bysoochin93
- Jurdzinski - 2000 - A Discrete Strategy Improvement Algorithm for Solving Parity Games.psUploaded byKernel5
- Lect7Color.pdfUploaded bybeepee14
- t 035169178Uploaded byAJER JOURNAL
- 15F Syllabus bUploaded byJen
- Computation Complexity Lctn - Laszlo LovaszUploaded byAnik
- ( ) Symbolic Analysis of Analog Circuits.pdfUploaded bymedelaid
- Math Study Guide Notes for Final Exam MCR3U Grade 11 FunctionsUploaded bySujith Nimalaraj
- call for papers,research paper publishing, where to publish research paper, journal publishing,how to publish research paper, Call For research paper,international journal,publishing a paper, IJEI, call for papers 2011,journal of science and technology, how to get a research paper published, publishing a paper, publishing of journal, reserach and review articles, engineering journal, International Journal of Engineering Inventions, hard copy of journal, hard copy of certificates, journal of engineering, online Submission, http://ijeijournal.com, ijei, Call for papers, research paper publishing, where to publish research paper, journal publishing, how to publish research paper, Call For research paper, international journal, publishing a paper" />Uploaded byInternational Journal of Engineering Inventions (IJEI)
- 1412.4980Uploaded byHamza Saad
- 19Uploaded byAsutosh Das
- Edexcel C1 ChecklistUploaded byParco300

- 500ch7Uploaded byAllan Sousa Soares
- CheckUploaded byharshit
- DB_ What is a DecibelUploaded byharshit
- 1Noise DescriptorsUploaded bymohanishmayank
- BJT FabricationUploaded byharshit
- Audio GramUploaded byharshit
- Audio GramUploaded byharshit
- Ad Mcm 1718 RenewUploaded byharshit
- Sweat Absorbing MaterialUploaded byharshit
- Get Syllabus PDFUploaded byharshit
- Crs Clock RecoveryUploaded byharshit
- Joint SheetUploaded byharshit
- Lec3 NoiseUploaded byharshit
- 1mUploaded byharshit
- current1uUploaded byharshit
- Neuralnetworksanddeeplearning ComUploaded byharshit
- BJT FabricationUploaded byharshit
- Hyperbolics MathUploaded byharshit
- Hyperbolics MathUploaded byharshit
- Tutorial 2-Equilibrium 1Uploaded bySai Krishna
- verilog (2)Uploaded byharshit
- lect10feb17980Uploaded byDiego Romé
- UntitledUploaded byharshit
- verilogUploaded byAizhar John Quindoza
- Tutorial_3.pdfUploaded byharshit
- The kronig-penney modelUploaded byChang Jae Lee
- Network Theory.pdfUploaded byharshit
- probability assignment-1.pdfUploaded byharshit
- Lecture 20Uploaded byharshit

- Course Outline MA 1050 2014_15_IIUploaded byAmanuel Q. Mulugeta
- Solving InequalitiesUploaded byBret Jones
- Sp14 Cs188 Lecture 9 -- Mdps IIUploaded bypandarean
- Business AnalyticsUploaded byNimah Saeed
- Course Material DMBAUploaded byKhan Shaad
- A new proof of Ohno Theorem on multiple zeta valuesUploaded byEvgeniy Ulanskiy
- FINAL RESEARCH-sr van.docxUploaded bymiaamore
- 122-330-1-PBUploaded byD.n.Prasad
- GetTRDoc.pdfUploaded byMarthita de Arenas
- Inferential StatisticsUploaded byxandercage
- Sampling DistributionUploaded byneeta
- Case Study 2Uploaded byZaima Liza
- t Series ChaosUploaded byTehran Davis
- Sequential ModularUploaded byniteeshasingh
- Sample of Assessment ToolsUploaded byDamaris Pandora Songcal
- Canonical Correlation AnalysisUploaded byBirat Sharma
- Advanced MathUploaded byshaira
- Text (2)Uploaded byJishan Ahmed
- e 0381038042Uploaded byInternational Journal of computational Engineering research (IJCER)
- IEOR4004-notes1Uploaded byPedro Carmona
- Testing the Difference Between Means of Two NormalUploaded byExcuse Me
- 215923770-Thomas-Hawkins-Lebesgues-Theory-of-Integration-Its-Origins-and-Development-1975.pdfUploaded bysoumensahil
- Expectation Value (Statisitic Formulae)Uploaded bycorporateboy36596
- Math - HW 5Uploaded byLogan Marlow
- Elliot Rottenberg Stock 1996 Efficient tests for an autoregressive unit root.pdfUploaded byArturoGarciaRivera
- Chapter 2 Stability Testing Routh HurwitzUploaded byAli Ahmad
- Itô's Stochastic Calculus and Its ApplicationsUploaded bykim haksong
- IntroRealAnal-ch04Uploaded bySouparna Banerjee
- MATH_F341_1472Uploaded byViral Jain
- Fem Project 1Uploaded byMainak Sarkar