FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and...

36
FFT Example Evaluate the polynomial: P(x) = 1+3x+5x 2 +7x 3 +8x 4 +6x 5 +3x 6 +2x 7 at points ω 0 , ω 1 , ω 2 , ω 3 , ω 4 , ω 5 , ω 6 , ω 7 where ω k =e i2πk/8 , k = 0, 1, 2 … 7

Transcript of FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and...

Page 1: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

FFT Example Evaluate the polynomial: P(x) = 1+3x+5x2+7x3+8x4+6x5+3x6+2x7 at points ω0, ω1, ω2, ω3, ω4, ω5, ω6, ω7 where ωk=ei2πk/8 , k = 0, 1, 2 … 7

Page 2: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

FFT Example Evaluate the polynomial: P(x) = 1+3x+5x2+7x3+8x4+6x5+3x6+2x7 at points ω0, ω1, ω2, ω3, ω4, ω5, ω6, ω7 where ωi=e2πi/8 , i = 0, 1, 2 … 7

Page 3: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

1st step: Divide Evaluate the polynomial: P(x) = 1+3x+5x2+7x3+8x4+6x5+3x6+2x7 at points ω0, ω1, ω2, ω3, ω4, ω5, ω6, ω7 where ωk=ei2πk/8 , k = 0, 1, 2 … 7 Recursively solve the following problems and combine the solutions. 1)  Evaluate Pe(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1,

2, 3

2) Evaluate Po(x) = 3+7x+6x2+2x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3

Page 4: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

1st step: Divide Evaluate the polynomial: P(x) = 1+3x+5x2+7x3+8x4+6x5+3x6+2x7 at points ω0, ω1, ω2, ω3, ω4, ω5, ω6, ω7 where ωk=ei2πk/8 , k = 0, 1, 2 … 7 Recursively solve the following problems and combine the solutions. 1)  Evaluate Pe(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1,

2, 3 Note: Pe(x2) = 1+5x2+8x4+3x6

2) Evaluate Po(x) = 3+7x+6x2+2x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3 Note: xPo(x2) = 3x+7x3+6x5+2x7

Page 5: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

1st step: Divide Evaluate the polynomial: P(x) = 1+3x+5x2+7x3+8x4+6x5+3x6+2x7 at points ω0, ω1, ω2, ω3, ω4, ω5, ω6, ω7 where ωk=ei2πk/8 , k = 0, 1, 2 … 7 Recursively solve the following problems and combine the solutions. 1)  Evaluate Pe(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1,

2, 3 Note: Pe(x2) = 1+5x2+8x4+3x6

2) Evaluate Po(x) = 3+7x+6x2+2x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3 Note: xPo(x2) = 3x+7x3+6x5+2x7

Page 6: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

1st step: Divide Evaluate the polynomial: P(x) = 1+3x+5x2+7x3+8x4+6x5+3x6+2x7 at points ω0, ω1, ω2, ω3, ω4, ω5, ω6, ω7 where ωk=ei2πk/8 , k = 0, 1, 2 … 7 Recursively solve the following problems and combine the solutions. 1)  Evaluate Pe(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1,

2, 3 Note: Pe(x2) = 1+5x2+8x4+3x6

2) Evaluate Po(x) = 3+7x+6x2+2x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3 Note: xPo(x2) = 3x+7x3+6x5+2x7

Page 7: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

1st step: Divide Evaluate the polynomial: P(x) = 1+3x+5x2+7x3+8x4+6x5+3x6+2x7 at points ω0, ω1, ω2, ω3, ω4, ω5, ω6, ω7 where ωk=ei2πk/8 , k = 0, 1, 2 … 7 Recursively solve the following problems and combine the solutions. 1)  Evaluate Pe(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1,

2, 3

2) Evaluate Po(x) = 3+7x+6x2+2x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3

Page 8: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

1st step: Divide Evaluate the polynomial: P(x) = 1+3x+5x2+7x3+8x4+6x5+3x6+2x7 at points ω0, ω1, ω2, ω3, ω4, ω5, ω6, ω7 where ωk=ei2πk/8 , k = 0, 1, 2 … 7 Recursively solve the following problems and combine the solutions. 1)  Evaluate Pe(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1,

2, 3

2) Evaluate Po(x) = 3+7x+6x2+2x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3

Page 9: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

1st step: Divide Evaluate the polynomial: P(x) = 1+3x+5x2+7x3+8x4+6x5+3x6+2x7 at points ω0, ω1, ω2, ω3, ω4, ω5, ω6, ω7 where ωk=ei2πk/8 , k = 0, 1, 2 … 7 Recursively solve the following problems and combine the solutions. 1)  Evaluate Pe(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1,

2, 3

2) Evaluate Po(x) = 3+7x+6x2+2x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3

Page 10: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate Q(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3 (ω0 = 1, ω1 = i, ω2 = -1, ω3 = -i ) Solve the sub-problems: 1)  Evaluate Qe(x) = 1+8x at points ωk=ei2πk/2 , k = 0, 1

2) Evaluate Qo(x) = 5+3x at points ωk=ei2πk/2 , k = 0, 1

Page 11: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate Q(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3 (ω0 = 1, ω1 = i, ω2 = -1, ω3 = -i ) Solve the sub-problems: 1)  Evaluate Qe(x) = 1+8x at points ωk=ei2πk/2 , k = 0, 1

2) Evaluate Qo(x) = 5+3x at points ωk=ei2πk/2 , k = 0, 1

Page 12: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate Q(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3 (ω0 = 1, ω1 = i, ω2 = -1, ω3 = -i ) Solve the sub-problems: 1)  Evaluate Qe(x) = 1+8x at points ωk=ei2πk/2 , k = 0, 1

2) Evaluate Qo(x) = 5+3x at points ωk=ei2πk/2 , k = 0, 1

Page 13: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate R(x) = 1+8x at points ωk=ei2πk/2 , k = 0, 1 (ω0=1, ω1=-1)

Solve the sub-problems: 1)  Evaluate Re(x) = 1 at point ω0=ei2π*0/1 =1 2)  Evaluate Ro(x) = 8 at point ω0=ei2π*0/1 =1

Page 14: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate R(x) = 1+8x at points ωk=ei2πk/2 , k = 0, 1 (ω0=1, ω1=-1)

Solve the sub-problems: 1)  Evaluate Re(x) = 1 at point ω0=ei2π*0/1 =1 Re(1) = 1 2)  Evaluate Ro(x) = 8 at point ω0=ei2π*0/1 =1

Page 15: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate R(x) = 1+8x at points ωk=ei2πk/2 , k = 0, 1 (ω0=1, ω1=-1)

Solve the sub-problems: 1)  Evaluate Re(x) = 1 at point ω0=ei2π*0/1 =1 Re(1) = 1 2)  Evaluate Ro(x) = 8 at point ω0=ei2π*0/1 =1 Ro(1) = 8

Page 16: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate R(x) = 1+8x at points ωk=ei2πk/2 , k = 0, 1 (ω0=1, ω1=-1)

Solve the sub-problems: 1)  Evaluate Re(x) = 1 at point ω0=ei2π*0/1 =1 Re(1) = 1

2)  Evaluate Ro(x) = 8 at point ω0=ei2π*0/1 =1 Ro(1) = 8

Combine the solutions:

Page 17: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate R(x) = 1+8x at points ωk=ei2πk/2 , k = 0, 1 (ω0=1, ω1=-1)

Solve the sub-problems: 1)  Evaluate Re(x) = 1 at point ω0=ei2π*0/1 =1 Re(1) = 1

2)  Evaluate Ro(x) = 8 at point ω0=ei2π*0/1 =1 Ro(1) = 8

Combine the solutions: R(1) = Re(12) + 1* Ro(12) = 1 + 8 = 9 R(-1) = Re((-1)2) – 1*Ro((-1)2) = 1 - 8 = -7

Page 18: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate R(x) = 1+8x at points ωk=ei2πk2 , k = 0, 1 (ω0=1, ω1=-1)

Solve the sub-problems: 1)  Evaluate Re(x) = 1 at point ω0=ei2π*0/1 =1 Re(1) = 1

2)  Evaluate Ro(x) = 8 at point ω0=ei2π*0/1 =1 Ro(1) = 8

Combine the solutions: R(1) = Re(12) + 1* Ro(12) = 1 + 8 = 9 R(-1) = Re((-1)2) – 1*Ro((-1)2) = 1 - 8 = -7

Page 19: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate R(x) = 1+8x at points ωk=ei2πk/2 , k = 0, 1 (ω0=1, ω1=-1)

Solve the sub-problems: 1)  Evaluate Re(x) = 1 at point ω0=ei2π*0/1 =1 Re(1) = 1

2)  Evaluate Ro(x) = 8 at point ω0=ei2π*0/1 =1 Ro(1) = 8

Combine the solutions: R(1) = Re(12) + 1* Ro(12) = 1 + 8 = 9 R(-1) = Re((-1)2) – 1*Ro((-1)2) = 1 - 8 = -7

Page 20: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate Q(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3 (ω0 = 1, ω1 = i, ω2 = -1, ω3 = -i ) Solve the sub-problems: 1)  Evaluate Qe(x) = 1+8x at points ωk=ei2πk/2 , k = 0, 1 : Qe(1) =

9 , Qe(-1) = -7 ✔

2) Evaluate Qo(x) = 5+3x at points ωk=ei2πk/2 , k = 0, 1

Page 21: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate Q(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3 (ω0 = 1, ω1 = i, ω2 = -1, ω3 = -i ) Solve the sub-problems: 1)  Evaluate Qe(x) = 1+8x at points ωk=ei2πk/2 , k = 0, 1 : Qe(1) =

9 , Qe(-1) = -7

2)  Evaluate Qo(x) = 5+3x at points ωk=ei2πk/2 , k = 0, 1 Similarly we get: Qo(1) = 8 , Qo(-1) = 2

Page 22: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate Q(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3 (ω0 = 1, ω1 = i, ω2 = -1, ω3 = -i ) Solve the sub-problems: 1)  Evaluate Qe(x) = 1+8x at points ωk=ei2πk/2 , k = 0, 1 : Qe(1) =

9 , Qe(-1) = -7

2)  Evaluate Qo(x) = 5+3x at points ωk=ei2πk/2 , k = 0, 1 Similarly we get: Qo(1) = 8 , Qo(-1) = 2 Combine the solutions: Q(1) = Qe(12) + 1 * Q0(12) = 9 + 8 = 17 Q(-1) = Qe((-1)2) - 1 * Q0((-1)2) = 9 - 8 = 1 Q(i) = Qe(i2) + i * Q0(i2) = = Qe(-1) + i * Q0(-1) = -7 + 2i Q(-i) = Qe((-i)2) - i * Q0((-i)2) = = Qe(-1) - i * Q0(-1) = -7 -2i

Page 23: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate Q(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3 (ω0 = 1, ω1 = i, ω2 = -1, ω3 = -i ) Solve the sub-problems: 1)  Evaluate Qe(x) = 1+8x at points ωk=ei2πk/2 , k= 0, 1 : Qe(1) =

9 , Qe(-1) = -7

2)  Evaluate Qo(x) = 5+3x at points ωk=ei2πk/2 , k = 0, 1 Similarly we get: Qo(1) = 8 , Qo(-1) = 2 Combine the solutions: Q(1) = Qe(12) + 1 * Q0(12) = 9 + 8 = 17 Q(-1) = Qe((-1)2) - 1 * Q0((-1)2) = 9 - 8 = 1 Q(i) = Qe(i2) + i * Q0(i2) = = Qe(-1) + i * Q0(-1) = -7 + 2i Q(-i) = Qe((-i)2) - i * Q0((-i)2) = = Qe(-1) - i * Q0(-1) = -7 -2i

Page 24: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate the polynomial: P(x) = 1+3x+5x2+7x3+8x4+6x5+3x6+2x7 at points ω0, ω1, ω2, ω3, ω4, ω5, ω6, ω7 where ωk=ei2πk/8 , k = 0, 1, 2 … 7 Recursively solve the following problems and combine the solutions. 1)  Evaluate Pe(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1,

2, 3 Pe(1) = 17, Pe(-1) = 1 , Pe(i) = -7 + 2i, Pe(-i) = -7 -2i ✔

2) Evaluate Po(x) = 3+7x+6x2+2x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3

Page 25: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Recursively solve the sub-problems

Evaluate the polynomial: P(x) = 1+3x+5x2+7x3+8x4+6x5+3x6+2x7 at points ω0, ω1, ω2, ω3, ω4, ω5, ω6, ω7 where ωk=ei2πk/8 , k = 0, 1, 2 … 7 Recursively solve the following problems and combine the solutions. 1)  Evaluate Pe(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1, 2,

3 Pe(1) = 17, Pe(-1) = 1 , Pe(i) = -7 + 2i, Pe(-i) = -7 -2i

2) Evaluate Po(x) = 3+7x+6x2+2x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3

Similarly we get: Po(1) = 18, Po(-1) = 0 , Po(i) = -3 + 5i, Po(-i) = -3 -5i

Page 26: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

2nd step: Combine Evaluate the polynomial: P(x) = 1+3x+5x2+7x3+8x4+6x5+3x6+2x7 at points ω0, ω1, ω2, ω3, ω4, ω5, ω6, ω7 where ωk=ei2πk/8 , k = 0, 1, 2 … 7 Recursively solve the following problems and combine the solutions. 1)  Evaluate Pe(x) = 1+5x+8x2+3x3 at points ωk=ei2πk/4 , k = 0, 1,

2, 3 Pe(1) = 17, Pe(-1) = 1 , Pe(i) = -7 + 2i, Pe(-i) = -7 -2i

2)  Evaluate Po(x) = 3+7x+6x2+2x3 at points ωk=ei2πk/4 , k = 0, 1, 2, 3 Po(1) = 18, Po(-1) = 0 , Po(i) = -3 + 5i, Po(-i) = -3 -5i

Page 27: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Putting it all (back) together 1. Divide 2. Conquer 3.   Combine

Page 28: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Polynomial Evaluation Input: Output: *which is the same as:

Evaluate!

ok, how about just getting the subproblems?

Page 29: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Pull even terms

Pull odd terms

We’ve split the polynomial!

Page 30: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

First Subproblem Evaluate:

For:

But we don’t have to evaluate at each of these points – only their squares

Page 31: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Polynomial Evaluation Input: Output: *which is the same as:

But we’ve already solved this! !!!!!!!!!!!!!!!!!!!

Page 32: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Polynomial Evaluation Input: Output:

Page 33: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Polynomial Evaluation Input:

We have all the pieces, so what is:

Page 34: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Polynomial Evaluation Input:

Page 35: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Polynomial Evaluation Input:

Page 36: FFT Example - cs170/fa14/tutorials/tutorial2.pdf · Recursively solve the following problems and combine the solutions. 1) Evaluate P e(x) = 1+5x+8x2+3x3 at points ...

Polynomial Evaluation Input: