1 Mathematical Algorithms 1. Arithmetic, (Pseudo) Random Numbers and all that 2. Evaluation & Multiplication of Polynomials I 3. Multiplication of Large.

Slides:



Advertisements
Similar presentations
DFT & FFT Computation.
Advertisements

1 Fast Multiplication of Large Numbers Using Fourier Techniques Henry Skiba Advisor: Dr. Marcus Pendergrass.
Digital Kommunikationselektronik TNE027 Lecture 5 1 Fourier Transforms Discrete Fourier Transform (DFT) Algorithms Fast Fourier Transform (FFT) Algorithms.
Fast Fourier Transform Lecture 6 Spoken Language Processing Prof. Andrew Rosenberg.
FFT1 The Fast Fourier Transform. FFT2 Outline and Reading Polynomial Multiplication Problem Primitive Roots of Unity (§10.4.1) The Discrete Fourier Transform.
Administrative Oct. 2 Oct. 4 – QUIZ #2 (pages of DPV)
VLSI Arithmetic. Multiplication A = a n-1 a n-2 … a 1 a 0 B = b n-1 b n-2 … b 1 b 0  eg)  Shift.
FFT1 The Fast Fourier Transform by Jorge M. Trabal.
Faster Multiplication, Powering of Polynomials
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Fast Fourier Transform Jean Baptiste Joseph Fourier ( ) These lecture.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 16: Application-Driven Hardware Acceleration (1/4)
Richard Fateman CS 282 Lecture 51 Faster Multiplication, Powering of Polynomials Lecture 5.
CSE 421 Algorithms Richard Anderson Lecture 13 Divide and Conquer.
CS2336: Computer Science II
The Fourier series A large class of phenomena can be described as periodic in nature: waves, sounds, light, radio, water waves etc. It is natural to attempt.
11/26/02CSE FFT,etc CSE Algorithms Polynomial Representations, Fourier Transfer, and other goodies. (Chapters 28-30)
Fast Fourier Transforms
DIVIDE & CONQUR ALGORITHMS Often written as first as a recursive algorithm Master’s Theorem: T(n) = aT(n/b) + cn i, for some constant integer i, and constants.
MA/CSSE 473 Day 03 Asymptotics A Closer Look at Arithmetic With another student, try to write a precise, formal definition of “t(n) is in O(g(n))”
IT253: Computer Organization
Great Theoretical Ideas in Computer Science.
Analysis of Algorithms
FFT1 The Fast Fourier Transform. FFT2 Outline and Reading Polynomial Multiplication Problem Primitive Roots of Unity (§10.4.1) The Discrete Fourier Transform.
Multiplication of signed-operands
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch]
5.6 Convolution and FFT. 2 Fast Fourier Transform: Applications Applications. n Optics, acoustics, quantum physics, telecommunications, control systems,
The Fast Fourier Transform
Advanced Algebraic Algorithms on Integers and Polynomials Prepared by John Reif, Ph.D. Analysis of Algorithms.
Karatsuba’s Algorithm for Integer Multiplication
Complexity 20-1 Complexity Andrei Bulatov Parallel Arithmetic.
Applied Symbolic Computation1 Applied Symbolic Computation (CS 300) Karatsuba’s Algorithm for Integer Multiplication Jeremy R. Johnson.
The Fast Fourier Transform and Applications to Multiplication
Number Systems. Prehistory Unary, or marks: / /////// = 7 /////// + ////// = ///////////// Grouping lead to Roman Numerals: VII + V = VVII = XII Better,
1 Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
CSE 421 Algorithms Lecture 15 Closest Pair, Multiplication.
Divide and Conquer Andreas Klappenecker [based on slides by Prof. Welch]
1 How to Multiply Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. integers, matrices, and polynomials.
Fast Fourier Transforms. 2 Discrete Fourier Transform The DFT pair was given as Baseline for computational complexity: –Each DFT coefficient requires.
Chapter 2. Divide-and-conquer Algorithms
Chapter 2 Divide-and-Conquer algorithms
DIGITAL SIGNAL PROCESSING ELECTRONICS
Analysis of Algorithms
Chapter 2 Divide-and-Conquer algorithms
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Polynomial + Fast Fourier Transform
Divide-and-Conquer Design
September 4, 1997 Applied Symbolic Computation (CS 300) Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
CSCE 411 Design and Analysis of Algorithms
Imaginary Numbers.
Communication costs of Schönhage-Strassen fast integer multiplication
Applied Symbolic Computation
Real-time double buffer For hard real-time
DFT and FFT By using the complex roots of unity, we can evaluate and interpolate a polynomial in O(n lg n) An example, here are the solutions to 8 =
Lecture #17 INTRODUCTION TO THE FAST FOURIER TRANSFORM ALGORITHM
Real-time 1-input 1-output DSP systems
September 4, 1997 Applied Symbolic Computation (CS 300) Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
Punya Biswas Lecture 15 Closest Pair, Multiplication
The Fast Fourier Transform
Fast Fourier Transformation (FFT)
September 4, 1997 Applied Symbolic Computation (CS 567) Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
Chapter 9 Computation of the Discrete Fourier Transform
Applied Symbolic Computation
Richard Anderson Lecture 14 Inversions, Multiplication, FFT
Time Complexity Lecture 14 Sec 10.4 Thu, Feb 22, 2007.
The Fast Fourier Transform
Lecture 15, Winter 2019 Closest Pair, Multiplication
CSC 380: Design and Analysis of Algorithms
Lecture 15 Closest Pair, Multiplication
Fast Polynomial and Integer Multiplication
Presentation transcript:

1 Mathematical Algorithms 1. Arithmetic, (Pseudo) Random Numbers and all that 2. Evaluation & Multiplication of Polynomials I 3. Multiplication of Large Integers 4. Strassen's algorithm for large Matrices 5. Zeros of Polynomials: Bisection vs Newton's method 6. Evaluation & Multiplication of Polynomials II 7. Fast Fourier Transforms 8. Interpolation/splines etc. 9. SHOULD BE A SEPARATE COURSE!!! Ari’s class: PHO 211 – 4/13/06

2 Adding, Multiplying and Evaluating Polynomials Why are polynomials so interesting? P N (x) = a 0 + a 1 x + a 2 x 2  a N x N Fit data d i = P N (x i ) by picking a i ’s Integer arithmetic base B is polynomial with x = B: e.g Integer decimal base (B=10) P N-1 (10) = a 0 + a a  a N-1 10 N-1 Fourier transform is P N-1 (x k ) with x k =  k N = exp[i k 2  /N] y k ´  l e ik n 2  /N a n ETC

3 Evaluation of p(x) = a 0 + a 1 x a N x N Method 1:  Compute x, x 2, x 3,...x N with N-1-mults plus N mults and N adds or 2N-1 mults and N adds Horner’s Method 2:  a 0 + x(a 1 + x (a 2 + x (a 3 +.a 4 x) ) ) for N = 4 N adds and N multiplies!  Evaluating it at N points is O(N 2 ) Special case: p(x) = x N do in Log(N) steps!  Consider N in binary base eg Cal x, x 2, x 4, x by repeated squaring and then multiply to get x N in O(Log 2 (N)) steps.

4 Polynomial Multiplication P(x) = a 0 + a 1 x a N x N and Q(x) = b 0 + b 1 x b N x N P(x) Q(x) = a 0 b 0 + (a 0 b 1 + a 1 b 0 )x + (a 0 b 2 + a 1 b 1 + a 2 b 0 )x a N b N x 2N  This is O(N 2 ): N-1 to get to x N and similarly for x N+1 to N 2N Try devide and conquer: P N (x) = p L (x) + x N /2 p’ H (x) p L (x) = a 0 + a 1 x +... a N/2 x N/2 p H (x) = a N/ a N/2 x N/2 P(x) Q(x) = p L (x) q L (x) + (p L (x) q H (x) + p H (x) q L (x)) x N/2 + p H (x) q H (x) x N T(N) = 4 T(N/2) + c 0 N  T(N) = O(N 2 ) Better: define (p L (x) + p H (x))(q L (x) + q H (x)) – p L (x) q L (x) – p H (x) p H (x) T(N) = 3 T(N/2) + c 0 N  T(N) = O(N  )

5 Large Integer Multiply: Z = X * Y Set: X & Y has at most N Digits:  X= 137 = 1* * Y= 025 = 0* * Steps: Single Digit Multipliers and Adders with carry. e.g. Standard method:  Complexity: T(N) = const * N 2  Is this best algorithm?  Is there a best upper bound A x B C

6 Beating O(N ) by “Divide & Conquer y Split each N digit integer into two N/2 integers:  X = XH * 10 N/2 + XL and Y = YH * 10 N/2 + YL  X*Y = XH*YH 10 N + (XH*YL + XL*YH) 10 N/2 + XL*YL  Number of Multiplies: 4 * (N/2) 2 = N 2 NO CHANGE ? BUT: XH*YL + XL*YH = (XH + XL)*(YH + YL) – XH*YH – XL*YL “Really 3 times half problems or 3 (N/2) 2 = 3N 2 /4 RECURSIVELY this gives T(N) = const N log(3)/log(2) = N 1.59… 2 y See Weiss Sec page 419

7 Large Integer Multiplication: T(N) = 3 T(N/2) + c N using: adding:

8 Integer Multiplication: T(N) = ? FunctionValueComplexity XL 6143Input O(N) XH8521Input O(N) YL9473Input O(N) YH6407Input O(N) D1 = XH + XL14664N adds D2 = YH + YL15880N adds XL*YL T(N/2) XH*YH T(N/2) D1* D T(N/2) D3 = D1*D2 - XH*YH - XL*YL N adds XH*YH + D3* XH*YH Add/Output O(N) Direct Method: T(N) = c1 N 2 + c2 N O(c1 N 2 + c2 N) = O(N 2 ) One Level: T(N) = 3 * (c1 (N/2) 2 + c2 N/2) O(0.75 c1 N 2 ) = O(N 2 ) Naive Recursion: T(N) = 4 T(N/2) + c N O(N 2 ) Smart Recursion: T(N) = 3 T(N/2) + c O( N l l og(3)/log(2) )

9 Strassen’s Algorithm O(N 2.81 ), p. 422 where: T(N) = 7 T(N/2) + c N 2 Naïve T(N) = c N ^3

10 Zeros of P N (x): Bisection vs Newton’s Methods P_N(x) has N complex roots. No closed form for roots for Quintic (N=5) & above Real roots by bisection: accuracy  = 1/N  O(log(N)) Newton’s Method: accuracy  = 1/N  O(log(N))

11 Multiplying Polynomials and FFTFFT Multiply P N/2 (x), Q N/2 (x) 1. Evaluate at 2N points (k=0,  N-1) O(N 2 ) 2. W(x k ) = Q(x k ) P(x k ) O(N) 3. Interpolate to find c k, n = 0,...,N-1 O(N 2 ) a i, b j c _k Q(x _k ) P(x _k ) W(x k ) = Q(x k ) P(x k ) O(N 2 ) O(N log(N)) O(N) O(N log(N)) FFT convolution multiply

12 FFT: x k =  k N = exp[i 2  k/N] spit polynomial into low/high pieces: even k odd k  One N = Two N/2 Fourier transforms

13 Thus T(N) = 2 T(N/2) + c o N: T(N) » N Log(N) Insert butterfly and discuss bit reversal

14 End Ari’s Class