CSE 548: Analysis of Algorithms. Lecture 4 ( Divide-and-Conquer Algorithms: Polynomial Multiplication )

Similar documents
CSE 613: Parallel Programming. Lectures ( Analyzing Divide-and-Conquer Algorithms )

CSE 613: Parallel Programming. Lecture 8 ( Analyzing Divide-and-Conquer Algorithms )

Chapter 1 Divide and Conquer Polynomial Multiplication Algorithm Theory WS 2015/16 Fabian Kuhn

FFT: Fast Polynomial Multiplications

Design and Analysis of Algorithms

CSE 421 Algorithms. T(n) = at(n/b) + n c. Closest Pair Problem. Divide and Conquer Algorithms. What you really need to know about recurrences

Chapter 1 Divide and Conquer Algorithm Theory WS 2016/17 Fabian Kuhn

Fast Convolution; Strassen s Method

Scientific Computing: An Introductory Survey

The Fast Fourier Transform. Andreas Klappenecker

Multiplying huge integers using Fourier transforms

Divide and Conquer algorithms

CSE 613: Parallel Programming. Lecture 9 ( Divide-and-Conquer: Partitioning for Selection and Sorting )

Lecture 20: Discrete Fourier Transform and FFT

Integer multiplication with generalized Fermat primes

Fall 2011, EE123 Digital Signal Processing

Divide and Conquer: Polynomial Multiplication Version of October 1 / 7, 24201

Algorithm Design and Analysis

Space- and Time-Efficient Polynomial Multiplication

Fast Fourier Transform

Divide and conquer. Philip II of Macedon

Frequency Domain Finite Field Arithmetic for Elliptic Curve Cryptography

CS S Lecture 5 January 29, 2019

CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: October 11. In-Class Midterm. ( 7:05 PM 8:20 PM : 75 Minutes )

Parallel Numerical Algorithms

Sequential Fast Fourier Transform (PSC ) Sequential FFT

CSE 421. Dynamic Programming Shortest Paths with Negative Weights Yin Tat Lee

CPSC 518 Introduction to Computer Algebra Asymptotically Fast Integer Multiplication

Integer Multiplication

The tangent FFT. D. J. Bernstein University of Illinois at Chicago

Fast Polynomial Multiplication

Interpolation on the unit circle

Divide and Conquer. Maximum/minimum. Median finding. CS125 Lecture 4 Fall 2016

5.6 Convolution and FFT

Introduction to Algorithms

Given a Polynomial of Degree Bound 8 Find 8 Distinct Points to Efficiently Evaluate it at. STRATEGY:Set for 04

Discrete Mathematics U. Waterloo ECE 103, Spring 2010 Ashwin Nayak May 17, 2010 Recursion

Implementation of the DKSS Algorithm for Multiplication of Large Numbers

DIVIDE AND CONQUER II

CPSC 518 Introduction to Computer Algebra Schönhage and Strassen s Algorithm for Integer Multiplication

Jim Lambers ENERGY 281 Spring Quarter Lecture 5 Notes

Elliptic Curves Spring 2013 Lecture #3 02/12/2013

EE123 Digital Signal Processing

Computational Methods CMSC/AMSC/MAPL 460

Fast reversion of formal power series

How to Multiply. 5.5 Integer Multiplication. Complex Multiplication. Integer Arithmetic. Complex multiplication. (a + bi) (c + di) = x + yi.

The Fast Fourier Transform: A Brief Overview. with Applications. Petros Kondylis. Petros Kondylis. December 4, 2014

Chapter 2 Algorithms for Periodic Functions

Fast and Small: Multiplying Polynomials without Extra Space

Faster integer multiplication using short lattice vectors

MARN 5898 Fourier Analysis.

E The Fast Fourier Transform

Chapter 5 Divide and Conquer

Algorithms and data structures

CS168: The Modern Algorithmic Toolbox Lecture #11: The Fourier Transform and Convolution

CSE548, AMS542: Analysis of Algorithms, Fall 2015 Date: October 12. In-Class Midterm. ( 1:05 PM 2:20 PM : 75 Minutes )

Algorithms and Data Structures

MA3232 Summary 5. d y1 dy1. MATLAB has a number of built-in functions for solving stiff systems of ODEs. There are ode15s, ode23s, ode23t, ode23tb.

Transforms and Orthogonal Bases

The Fast Fourier Transform

Speedy Maths. David McQuillan

Mid-term Exam Answers and Final Exam Study Guide CIS 675 Summer 2010

18.310A Final exam practice questions

Lecture4 INF-MAT : 5. Fast Direct Solution of Large Linear Systems

Divide and Conquer. CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30,

CS483 Design and Analysis of Algorithms

Even faster integer multiplication

CS 4424 Matrix multiplication

Introduction to Algorithms 6.046J/18.401J/SMA5503

RSA Implementation. Oregon State University

Fast algorithms for polynomials and matrices Part 2: polynomial multiplication

Integer multiplication and the truncated product problem

Tutorial 2 - Learning about the Discrete Fourier Transform

Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary

! Circular Convolution. " Linear convolution with circular convolution. ! Discrete Fourier Transform. " Linear convolution through circular

Asymptotic Analysis and Recurrences

Numerical Methods I: Interpolation (cont ed)

CSE 421 Algorithms: Divide and Conquer

Fourier transforms and convolution

Sequential Fast Fourier Transform

CSE548, AMS542: Analysis of Algorithms, Spring 2014 Date: May 12. Final In-Class Exam. ( 2:35 PM 3:50 PM : 75 Minutes )

CSE 548: Analysis of Algorithms. Lecture 8 ( Amortized Analysis )

Kartsuba s Algorithm and Linear Time Selection

Design and Analysis of Algorithms

23. The Finite Fourier Transform and the Fast Fourier Transform Algorithm

Data Structures and Algorithms CSE 465

Old and new algorithms for computing Bernoulli numbers

Digital Image Processing

CMPSCI611: Three Divide-and-Conquer Examples Lecture 2

Figure 1: Circuit for Simon s Algorithm. The above circuit corresponds to the following sequence of transformations.

Lecture 19 IIR Filters

The Fast Fourier Transform

CS711008Z Algorithm Design and Analysis

Homework 1 Solutions

A design paradigm. Divide and conquer: (When) does decomposing a problem into smaller parts help? 09/09/ EECS 3101

Class Note #14. In this class, we studied an algorithm for integer multiplication, which. 2 ) to θ(n

Fast reversion of power series

Parallel Recursion: Powerlists. Greg Plaxton Theory in Programming Practice, Fall 2005 Department of Computer Science University of Texas at Austin

Even faster integer multiplication

FOURIER SERIES, HAAR WAVELETS AND FAST FOURIER TRANSFORM

Transcription:

CSE 548: Analysis of Algorithms Lecture 4 ( Divide-and-Conquer Algorithms: Polynomial Multiplication ) Rezaul A. Chowdhury Department of Computer Science SUNY Stony Brook Spring 2015

Coefficient Representation of Polynomials is a polynomial of degree bound represented as a vector,,, of coefficients. The degreeof is provided it is the largest integer such that is nonzero. Clearly, 01. Evaluating at a given point: Takes Θ time using Horner s rule:

Coefficient Representation of Polynomials Adding Two Polynomials: Adding two polynomials of degree bound takes Θ time. Then, where, for 01. where, and.

Coefficient Representation of Polynomials Multiplying Two Polynomials: The product of two polynomials of degree bound is another polynomial of degree bound 21. where, and. Then, where, for 022. The coefficient vector,,,, denoted by, is also called the convolutionof vectors,,, and,,,. Clearly, straightforward evaluation of takes Θ time.

Convolution

Convolution

Convolution

Convolution

Convolution

Convolution

Convolution

Coefficient Representation of Polynomials Multiplying Two Polynomials: We can use Karatsuba salgorithm (assume to be a power of 2): Then But 3 recursive multiplications of polynomials of degree bound. Similar recurrence as in Karatsuba sinteger multiplication algorithm leading to a complexity of Ο Ο..

Point-Value Representation of Polynomials A point-value representation of a polynomial is a set of pointvalue pairs,,,,,, such that all are distinct and for 01. A polynomial has many point-value representations. Adding Two Polynomials: Suppose we have point-value representations of two polynomials of degree bound using the same set of points. If then :,,,,,, :,,,,,, :,,,,,, Thus polynomial addition takes Θ time.

Point-Value Representation of Polynomials Multiplying Two Polynomials: Suppose we have extended(why?) point-value representations of two polynomials of degree bound using the same set of 2points. If then :,,,,,, :,,,,,, :,,,,,, Thus polynomial multiplication also takes only Θ time! ( compare this with the Θ time needed in the coefficient form )

Faster Polynomial Multiplication? ( in Coefficient Form ) ordinary multiplication Time Θ evaluation Time? interpolation Time?,,, pointwise multiplication Time Θ

Faster Polynomial Multiplication? ( in Coefficient Form ) Coefficient Representation Point-Value Representation: We select any set of distinct points,,,, and evaluate for 01. Using Horner s rule this approach takes Θ time. Point-Value Representation Coefficient Representation: We can interpolate using Lagrange s formula: This again takes Θ time. In both cases we need to do much better!

Coefficient Form Point-Value Form A polynomial of degree bound : A set of distinct points:,,, Compute point-value form:,,,,,, Using matrix notation: 1 1 1 We want to choose the set of points in a way that simplifies the multiplication. In the rest of the lecture on this topic we will assume: is a power of 2.

Coefficient Form Point-Value Form Let s choose for 0 21. Then 1 1 1 1 1 1 Observe that for 0 21:,,,. Thus we have just split the original matrix into two almost similar matrices!

Coefficient Form Point-Value Form How and how much do we save? where, and., Observe that for 0 21: So in order to evaluate for all 01, we need: 2evaluations of and 2evaluations of multiplications 2additions and 2subtractions Thus we save about half the computation!

Coefficient Form Point-Value Form If we can recursively evaluate and using the same approach, we get the following recurrence relation for the running time of the algorithm: Θ 1, 1, 2 2 Θ,. Θ log Our trick was to evaluate at ( positive ) and ( negative ). But inputs to and are always of the form ( positive )! How can we apply the same trick?

Coefficient Form Point-Value Form Let us consider the evaluation of for 0 21: 1 1 1 In order to apply the same trick on we must set: for 0 4 1

Coefficient Form Point-Value Form In we set: for 0 41. Then 1 1 1 1 1 1 This means setting, where 1( imaginary )! This also allows us to apply the same trick on.

Coefficient Form Point-Value Form We can apply the trick once if we set: for 0 21 We can apply the trick ( recursively ) 2 times if we also set: for 0 2 1 We can apply the trick ( recursively ) 3 times if we also set: for 0 2 1 We can apply the trick ( recursively ) times if we also set: for 0 2 1

Coefficient Form Point-Value Form Consider the primitive root of unity: Then cos sin 1

Coefficient Form Point-Value Form If 2 we would like to apply the trick times recursively. What values should we choose for,,,? Example: For 2 we need to choose,,,. Choose: 1 3: 2: 1: 1 1 complex roots of unity

Coefficient Form Point-Value Form For a polynomial of degree bound 2, we need to apply the trick recursively at most logtimes. We choose 1 and set for 11. Then we compute the following product: 1 1 1 1 1 1 1 1 The vector,,, is called the discretefourier transform( DFT ) of,,,. This method of computing DFT is called the fast Fourier transform ( FFT ) method.

Coefficient Form Point-Value Form Rec-FFT ( ( a 0, a 1,, a n - 1 ) ) { n = 2 k for integer k 0 } 1. if n = 1 then 2. return ( a 0 ) 3. ω n e 2πi/n 4. ω 1 5. y even Rec-FFT ( ( a 0, a 2,, a n - 2 ) ) 6. y odd Rec-FFT ( ( a 1, a 3,, a n - 1 ) ) 7. for j 0 to n/2 1 do 8. y j y even j + ω y odd j 9. y n/2+j y even j ω y odd j 10. ω ω ω n 11. return y Running time: Θ 1, 1, 2 2 Θ,. Θ log

Faster Polynomial Multiplication? ( in Coefficient Form ) ordinary multiplication Time Θ forward FFT Time Θ log interpolation Time?,,, pointwise multiplication Time Θ Next Lecture will Cover Interpolation