Algorithms 2005 Ramesh Hariharan. Polynomial Computation.

Slides:



Advertisements
Similar presentations
Fast Fourier Transform for speeding up the multiplication of polynomials an Algorithm Visualization Alexandru Cioaca.
Advertisements

-FFT Recap (or, what am I expected to know?) - Learning Finite State Environments Avrim Blum 11/25/03.
Bar Ilan University And Georgia Tech Artistic Consultant: Aviya Amir.
Fast Fourier Transform Lecture 6 Spoken Language Processing Prof. Andrew Rosenberg.
Polynomial and Rational
Infinite Horizon Problems
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)
CSE 421 Algorithms Richard Anderson Lecture 15 Fast Fourier Transform.
TECHNIQUES OF INTEGRATION
FFT1 The Fast Fourier Transform by Jorge M. Trabal.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Fast Fourier Transform Jean Baptiste Joseph Fourier ( ) These lecture.
CSE 421 Algorithms Richard Anderson Lecture 13 Divide and Conquer.
ON MULTIVARIATE POLYNOMIAL INTERPOLATION
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.
LIAL HORNSBY SCHNEIDER
Fast Fourier Transform Irina Bobkova. Overview I. Polynomials II. The DFT and FFT III. Efficient implementations IV. Some problems.
1 Linear Recurrence Relations Part I Jorge Cobb The University of Texas at Dallas.
Polynomial Division: Dividing one polynomial by another polynomial to find the zeros of the polynomial. Ex 1: Find the zeros of Solution:1 st way: At.
Efficiant polynomial interpolation algorithms
Using Adaptive Methods for Updating/Downdating PageRank Gene H. Golub Stanford University SCCM Joint Work With Sep Kamvar, Taher Haveliwala.
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Great Theoretical Ideas in Computer Science.
Quantum Computing MAS 725 Hartmut Klauck NTU TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A.
FFT1 The Fast Fourier Transform. FFT2 Outline and Reading Polynomial Multiplication Problem Primitive Roots of Unity (§10.4.1) The Discrete Fourier Transform.
The Fast Fourier Transform
PRIMES is in P Manindra Agrawal NUS Singapore / IIT Kanpur.
Advanced Algebraic Algorithms on Integers and Polynomials Prepared by John Reif, Ph.D. Analysis of Algorithms.
Length Reduction in Binary Transforms Oren Kapah Ely Porat Amir Rothschild Amihood Amir Bar Ilan University and Johns Hopkins University.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Chapter 8 With Question/Answer Animations. Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence.
Complexity 20-1 Complexity Andrei Bulatov Parallel Arithmetic.
Great Theoretical Ideas in Computer Science.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
The Fast Fourier Transform and Applications to Multiplication
1 Markov Decision Processes Infinite Horizon Problems Alan Fern * * Based in part on slides by Craig Boutilier and Daniel Weld.
06/12/2015Applied Algorithmics - week41 Non-periodicity and witnesses  Periodicity - continued If string w=w[0..n-1] has periodicity p if w[i]=w[i+p],
Section 5.5 The Real Zeros of a Polynomial Function.
1 Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
Zero of Polynomial Functions Factor Theorem Rational Zeros Theorem Number of Zeros Conjugate Zeros Theorem Finding Zeros of a Polynomial Function.
15.082J & 6.855J & ESD.78J September 30, 2010 The Label Correcting Algorithm.
Applied Symbolic Computation1 Applied Symbolic Computation (CS 567) The Fast Fourier Transform (FFT) and Convolution Jeremy R. Johnson TexPoint fonts used.
STROUD Worked examples and exercises are in the text PROGRAMME F3 EXPRESSIONS and EQUATIONS.
May 9, 2001Applied Symbolic Computation1 Applied Symbolic Computation (CS 680/480) Lecture 6: Multiplication, Interpolation, and the Chinese Remainder.
Real Zeros of Polynomial Functions
RS – Reed Solomon Error correcting code. Error-correcting codes are clever ways of representing data so that one can recover the original information.
Fuw-Yi Yang1 Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann Chap 1 Integers Department of Computer Science and Information Engineering,
MA2213 Lecture 12 REVIEW. 1.1 on page Compute Compute quadratic Taylor polynomials for 12. Compute where g is the function in problems 11 and 12.
Chapter 11 Polynomial Functions
More on Problem Solving
Great Theoretical Ideas in Computer Science
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Catie Baker Spring 2015.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Polynomial + Fast Fourier Transform
Algorithms with numbers (1) CISC4080, Computer Algorithms
September 4, 1997 Applied Symbolic Computation (CS 300) Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
Polynomials and the FFT(UNIT-3)
Applied Symbolic Computation
RS – Reed Solomon List Decoding.
September 4, 1997 Applied Symbolic Computation (CS 300) Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
The Fast Fourier Transform
Advanced Algorithms Analysis and Design
September 4, 1997 Applied Symbolic Computation (CS 567) Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
Applied Symbolic Computation
CSE 373: Data Structures & Algorithms
The Fast Fourier Transform
Fast Polynomial and Integer Multiplication
Presentation transcript:

Algorithms 2005 Ramesh Hariharan

Polynomial Computation

Multiplying Univariate Polynomials Of degrees n and m gives a new polynomial of degree n+m Time taken is O(nxm) Can one do better?

Multiplying 2 Polynomials Consider n=m first Evaluate each polynomial at 2n+1 distinct values Compute products of 2n+1 evaluations Interpolate between the resulting 2n+1 values to obtain the product polynomial (prove that it is possible to uniquely recover the polynomial from its evaluations at 2n+1 distinct values)

Multi-location Polynomial Evaluation Consider evaluating a polynomial of degree n at k=2n+1 distinct locations Each evaluation takes O(n); Total O(n^2); Can one do better? Also. an evaluation could produce a huge number, how do we handle these numbers?

Multi-location Polynomial Evaluation Consider evaluating a polynomial P(x) of degree 2n+1 at distinct locations a_1..a_k, k=2n+1 Same as computing P(x) mod (x-a_1), …, P(x) mod (x-a_k) Show this.

Multi-location Polynomial Evaluation Computing P(x) mod (x-a_1) and P(x) mod (x-a_2) involves 2 mod computations on a high degree polynomial. Can this be reduced to one high degree mod computation (and possibly several low degree mod computations if required? Compute Q(x)=P(x) mod (x-a_1)(x-a_2) Compute Q(x) mod (x-a_1) and Q(x) mod (x-a_2)

Multi-location Polynomial Evaluation Q(x)=P(x) mod (x-a_1)..(x-a_k) R(x)=Q(x) mod (x-a_1)..(x-a_k/2)H(x)=Q(x) mod (x-a_k/2+1)..(x-a_k) F(x)=R(x) mod (x-a_1)..(x-a_k/4) D(x)=H(x) mod (x-a_3k/4+1)..(x-a_k) L(x)=R(x) mod (x-a_k/4+1)..(x-a_k/2) E(x)=H(x) mod (x-a_k/2+1)..(x-a_3k/4)

Multi-location Polynomial Evaluation Time taken At each node at level i, find the remainder of a degree k/2^(i-1) with respect to a polynomial of degree k/2^(i) Time is O(k^2/2^2(i-1)) at each level i node. There are 2^i nodes at level i. Total time taken is still quadratic. What happens if we could do each level i node in time O(k/2^(i-1)) ? Total time then is O(n log n). Can this be achieved if the remaindering polynomials has only a constant number of terms each?

Multi-location Polynomial Evaluation How do we ensure that the remaindering polynomials have few terms (x-a_1)(x-a_2)=x^2–(a_1+a_2)x+a_1a_2 If a_1+a_2=0 then the result has only 2 terms

Multi-location Polynomial Evaluation How do we ensure that the remaindering polynomials have few terms Iterating this principle up the tree gives the following constraints a_1a_2+a_3a_4=0 a_5a_6+a_7a_8=0 a_1a_2a_3a_4+a_5a_6a_7a_8=0 a_1+a_2=0 a_3+a_4=0 a_5+a_6=0 a_7+a_8=0

Multi-location Polynomial Evaluation Solving the above constraints gives a –a b –b c –c d –d e -e f –f g –g h –h a –a ia –ia c –c ic –ic e –e ie –ie g –g ig –ig a –a ia –ia ja –ja ija –ija e –e ie –ie je –je ije –ije a –a ia –ia ja –ja ija –ija ha –ha iha –iha jha –jha ijha –ijha i^2=-1 j^4=-1 h^8=-1 a is unconstrained, so setting a=1 gives 1 –1 i –i j –j ij –ij h –h ih –ih jha –jh ijh –ijh

Multi-location Polynomial Evaluation Sequence for general k=2^* S(k)=S(k/2). Primitive-kth-root-of-unity*S(k/2) S(1)=1 We need the kth, k/2th, k/4th.. roots of unity A primitive kth root of unity x satisfies x^k=1 but x^{k/2}!=1

Multi-location Polynomial Evaluation rth root of unity is Cos(2π/r) + i Sin(2π/r) This is irrational, so we can only do approximate computation To what precision should we compute? How do these approximations add up?

Multi-location Polynomial Evaluation Precision Questions To get a certain accuracy at the output, what input precision must we start with? How much does each operation amplify the error?

Multi-location Polynomial Evaluation A Careful Look at Operations Each remaindering polynomial is of the form x^i-a^2; it is obtained by multiplying (x^{i/2}-a)(x^{i/2}+a) What is the error in computing a^2? If the error in a is \eps, then the error is a^2 is |a^2 – (a+\eps)^2|= \eps|2a+\eps| < 3\eps assuming |a|<=1 and \eps<=1 (which will be true, why?) The total error in constant term of the remaindering polynomial this trebles at each level reaching a max of 3^{log k}\eps = k^{O(1)}\eps at the top, where \eps is the starting error at the bottom. By choosing the starting error at the bottom to be 1/poly(k), we can keep the error at the top 1/poly(k) as well.

Multi-location Polynomial Evaluation A Careful Look at Operations It remains to consider to the mod operations Q(x) mod x^i –a Note Q(x) has degree less than 2i (this is important) Each step in the mod computation performs c – b a, where c and b are coefficients of Q(x) (to show this for b, we need that deg(Q(x))<2i) Assume b=O(poly(k)) (justify this assumption and show that it holds for intermediate polynomials Q(x) provided it holds for the original polynomial)

Multi-location Polynomial Evaluation A Careful Look at Operations If the coefficients of Q(x) have error \del and a has error \gam then what is the error in the result. |c+\del – (b+\del)(a+\gam) – (c-ab)|<=\del+a\del+b\gam+\del\gam <=3\del + b\gam since |a|<=1 and \del<1 and \gam<=1 (which will be true, why?) We can choose \eps on the previous slide so that \gam is a small enough inverse polynomial so b\gam<\del, in which case the error goes from \del to 4\del in one mod operation. This translates to a 4^{log k}\del error at the bottom; choosing \del to be at least b\gam which is 1/poly(k) we can bound this error to 1/poly(k) as well.

Multi-location Polynomial Evaluation Completing Precision Details How do we compute Cos(2π/r) and Sin(2π/r) to 1/poly(k) precision? How much time does this take? Exercise. How many bits does it take? O(log k) bits; so arithmetic operations on these bits can be performed in O(1) time.

Multi-location Polynomial Evaluation Total Time Taken O(k log k), assuming O(1) time for arithmetic operations on O(log k) bit words; also assuming roots of unity can be computed to the desired accuracy; also assuming the original coefficients are sub poly(k). Output accuracy is 1/poly(k)

Multi-location Polynomial Evaluation Interpolating to Recover the Product An almost identical procedure Find 2 polynomials A(x) and B(x) recursively which interpolate on a_1..a_k/2 and a_k/2+1..a_k respectively Obtain the full polynomial by computing (x-a_1).. (x-a_k/2) B(x) + (x-a_k/2+1).. (x-a_k) A(x)

String Matching with WildCards How can Polynomial Multiplication be used? Given a text with 0s and 1s and a pattern with 0s,1s,*, find all occurrences of the pattern in the text. The pattern matches at a location if all 0s in the pattern are aligned to 0s, all 1s are aligned to 1s and *’s could be aligned to 0s or 1s. For text length n and pattern length m, time taken is O(nlog m)