SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Multiplying Polynomials Fast

 Why do we need Complex
       Numbers?
The Problem


• (an xn + an-1 xn-1+…..+ a0 x0) * (bn xn + bn-1 xn-1+…..+ b0 x0)

• O(n^2) time
  – (Σi=0..k ai * bk-i) is coefficient of xk

• Can one do better?
Applications

• Where all does a pattern string P appear in a text string
  T?

   – P 0’s, 1’s and don’t cares.

   – T 0’s and 1’s


• Easy in O(|P|*|T|) time

   – Can one do better?
Conversion to Polynomial
                    Multiplication
•   Treat P and T as polynomials

     – T=0101       1 x0 + 0 x1 + 1 x2 + 0 x3
                                                                  tk-i       tk-2 tk-1 tk
     – P=01D1       0 x0 + 1 x1 + 0 x2 + 1 x3
                                                      1   0   1   0      1   1    0    0    1

•   Multiply Prev and T
                                                          1   0    0 0       1   0 0
                                                                  p-i            p-1 p-0
     – (Σi=0..k previ * tk-i) is coefficient of xk

     – (Σi=0..k p|P|-i * tk-i) is coefficient of xk


•   >=1 if and only if a 1 in P aligns with a 0 in T when P is placed with end at
    tk
     – 2 polynomial multiplications suffice to find all matches of P in T
Other Applications

• Image Processing                   At this
                                    location



      Slide this mask
        all over the
                                    Multiply each bit
         bigger one                  in the mask with
                                            the
                                    corresponding bit
                                       in the image,
                                       sum these up
Polynomial Multiplication
                     An Equivalent Form

• Evaluate each polynomial at 2n+1 distinct x’s

   – A(x) = (an xn + an-1 xn-1+…..+ a0 x0) -> A(v0)…..A(v2n)

   – B(x) = (bn xn + bn-1 xn-1+…..+ b0 x0) -> B(v0)…..B(v2n)


• A(x) * B(x)       ->   A(v0)*B(v0)………..A(v2n)*B(v2n)

   – Convolution in one domain=Simple multiplication in another

   – O(n) time!!!
Multi-Point Polynomial Evaluation

• Evaluate A(x) at v0 ……vn

  – O(n) time per vi using Horner’s rule




• Problems
  – O(n2) time

  – Large numbers with n log vi bits
Multi-Point Polynomial Evaluation
                Speed Up
• A(x) mod (x-v)

   – A(v)

   – O(n) time using high school polynomial division



• A’(x) = A(x) mod (x-v0) (x-v1)         [how fast?]
   – A’(x) mod (x-v0) = A(v0)   [O(1)]

   – A’(x) mod (x-v1) = A(v1)   [O(1)]

   – 2 expensive polynomial divisions could potentially be replaced by 1
Fast Multi-Point Polynomial Evaluation

                                          T0(x)=A(x) mod (x-v0) (x-v1).. (x-vn)

T1(x)=T0 (x) mod (x-v0)..(x-v(n+1)/2-1)        T2 (x)=T0 (x) mod (x-v(n+1)/2) (x-vn)




    • If T(x) mod (x-vi).. (x-vj) can be done in O(deg(T))
      time, then what is the total time taken?

         – O(n log n)!!
Computing T(x) mod (x-v1).. (x-vk)

•   High school algorithm

    – Time taken: O( deg(T) * k )

    – How do we make this faster?


• Stroke of genius
       • Can we choose vi’s so (x-v1).. (x-vk) = xk-v?

       • Then we get O(deg(T) ) time
Choosing vi’s
• When is (x-v1)(x-v2) = x2+v1v2 ?

   – v2+v1=0


• When is (x-a)(x+a)(x-b)(x+b) = x4+ a2b2?

   – b2-a2=0 => b2=-a2

      • => b= sqrt(-1) a

      • the 4 numbers are 1 –i -1 i

      • alternatively (–i)0 (–i)1 (–i)2 (–i)3
Choosing vi’s


• Choose vi to be roots of xn -1

   = Cos(2Πk/n) + i Sin(2Πk/n)
   = e i 2Πk/n

   – Powering just goes around the unit circle

      • Computing with log n bits suffices
Exercise


• Choose vi to be roots of xn -1

   = Cos(2Πk/n) + i Sin(2Πk/n)
   = e i 2Πk/n

   – Organize these roots so we get polynomials with
     just 2 terms in every node of the tree on slide 9
      • Assume n+1 is a power of 2
Conclusion


• Also called : Fast Fourier Transform

• Complex Numbers are interesting!

     • Reality can be explained elegantly only with
       complex numbers!!

Weitere ähnliche Inhalte

Was ist angesagt?

optimal control principle slided
optimal control principle slidedoptimal control principle slided
optimal control principle slidedKarthi Ramachandran
 
Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)
Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)
Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)STAIR Lab, Chiba Institute of Technology
 
Nodal Domain Theorem for the p-Laplacian on Graphs and the Related Multiway C...
Nodal Domain Theorem for the p-Laplacian on Graphs and the Related Multiway C...Nodal Domain Theorem for the p-Laplacian on Graphs and the Related Multiway C...
Nodal Domain Theorem for the p-Laplacian on Graphs and the Related Multiway C...Francesco Tudisco
 
Conditional neural processes
Conditional neural processesConditional neural processes
Conditional neural processesKazuki Fujikawa
 
Introduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchIntroduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchAhmed BESBES
 
A new Perron-Frobenius theorem for nonnegative tensors
A new Perron-Frobenius theorem for nonnegative tensorsA new Perron-Frobenius theorem for nonnegative tensors
A new Perron-Frobenius theorem for nonnegative tensorsFrancesco Tudisco
 
Estimating structured vector autoregressive models
Estimating structured vector autoregressive modelsEstimating structured vector autoregressive models
Estimating structured vector autoregressive modelsAkira Tanimoto
 
Small updates of matrix functions used for network centrality
Small updates of matrix functions used for network centralitySmall updates of matrix functions used for network centrality
Small updates of matrix functions used for network centralityFrancesco Tudisco
 
Computational Linguistics week 5
Computational Linguistics  week 5Computational Linguistics  week 5
Computational Linguistics week 5Mark Chang
 
NTHU AI Reading Group: Improved Training of Wasserstein GANs
NTHU AI Reading Group: Improved Training of Wasserstein GANsNTHU AI Reading Group: Improved Training of Wasserstein GANs
NTHU AI Reading Group: Improved Training of Wasserstein GANsMark Chang
 
Image Restoration 2 (Digital Image Processing)
Image Restoration 2 (Digital Image Processing)Image Restoration 2 (Digital Image Processing)
Image Restoration 2 (Digital Image Processing)VARUN KUMAR
 
Computational Linguistics week 10
 Computational Linguistics week 10 Computational Linguistics week 10
Computational Linguistics week 10Mark Chang
 
Murphy: Machine learning A probabilistic perspective: Ch.9
Murphy: Machine learning A probabilistic perspective: Ch.9Murphy: Machine learning A probabilistic perspective: Ch.9
Murphy: Machine learning A probabilistic perspective: Ch.9Daisuke Yoneoka
 
NTU ML TENSORFLOW
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOWMark Chang
 
Levitan Centenary Conference Talk, June 27 2014
Levitan Centenary Conference Talk, June 27 2014Levitan Centenary Conference Talk, June 27 2014
Levitan Centenary Conference Talk, June 27 2014Nikita V. Artamonov
 
Convex Optimization Modelling with CVXOPT
Convex Optimization Modelling with CVXOPTConvex Optimization Modelling with CVXOPT
Convex Optimization Modelling with CVXOPTandrewmart11
 

Was ist angesagt? (20)

optimal control principle slided
optimal control principle slidedoptimal control principle slided
optimal control principle slided
 
Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)
Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)
Higher-order Factorization Machines(第5回ステアラボ人工知能セミナー)
 
Nodal Domain Theorem for the p-Laplacian on Graphs and the Related Multiway C...
Nodal Domain Theorem for the p-Laplacian on Graphs and the Related Multiway C...Nodal Domain Theorem for the p-Laplacian on Graphs and the Related Multiway C...
Nodal Domain Theorem for the p-Laplacian on Graphs and the Related Multiway C...
 
Conditional neural processes
Conditional neural processesConditional neural processes
Conditional neural processes
 
Lec8
Lec8Lec8
Lec8
 
Introduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchIntroduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from Scratch
 
A new Perron-Frobenius theorem for nonnegative tensors
A new Perron-Frobenius theorem for nonnegative tensorsA new Perron-Frobenius theorem for nonnegative tensors
A new Perron-Frobenius theorem for nonnegative tensors
 
Lec16
Lec16Lec16
Lec16
 
Estimating structured vector autoregressive models
Estimating structured vector autoregressive modelsEstimating structured vector autoregressive models
Estimating structured vector autoregressive models
 
Small updates of matrix functions used for network centrality
Small updates of matrix functions used for network centralitySmall updates of matrix functions used for network centrality
Small updates of matrix functions used for network centrality
 
Gentle intro to SVM
Gentle intro to SVMGentle intro to SVM
Gentle intro to SVM
 
Computational Linguistics week 5
Computational Linguistics  week 5Computational Linguistics  week 5
Computational Linguistics week 5
 
NTHU AI Reading Group: Improved Training of Wasserstein GANs
NTHU AI Reading Group: Improved Training of Wasserstein GANsNTHU AI Reading Group: Improved Training of Wasserstein GANs
NTHU AI Reading Group: Improved Training of Wasserstein GANs
 
Image Restoration 2 (Digital Image Processing)
Image Restoration 2 (Digital Image Processing)Image Restoration 2 (Digital Image Processing)
Image Restoration 2 (Digital Image Processing)
 
Computational Linguistics week 10
 Computational Linguistics week 10 Computational Linguistics week 10
Computational Linguistics week 10
 
Murphy: Machine learning A probabilistic perspective: Ch.9
Murphy: Machine learning A probabilistic perspective: Ch.9Murphy: Machine learning A probabilistic perspective: Ch.9
Murphy: Machine learning A probabilistic perspective: Ch.9
 
NTU ML TENSORFLOW
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOW
 
Levitan Centenary Conference Talk, June 27 2014
Levitan Centenary Conference Talk, June 27 2014Levitan Centenary Conference Talk, June 27 2014
Levitan Centenary Conference Talk, June 27 2014
 
Convex Optimization Modelling with CVXOPT
Convex Optimization Modelling with CVXOPTConvex Optimization Modelling with CVXOPT
Convex Optimization Modelling with CVXOPT
 
2010 mainz
2010 mainz2010 mainz
2010 mainz
 

Andere mochten auch

Complex Numbers
Complex NumbersComplex Numbers
Complex Numbersswartzje
 
complex numbers
complex numberscomplex numbers
complex numbersvalour
 
Complex Numbers
Complex NumbersComplex Numbers
Complex Numbersitutor
 
Complex Number's Applications
Complex Number's ApplicationsComplex Number's Applications
Complex Number's ApplicationsNikhil Deswal
 
Complex numbers org.ppt
Complex numbers org.pptComplex numbers org.ppt
Complex numbers org.pptOsama Tahir
 
Complex Number I - Presentation
Complex Number I - PresentationComplex Number I - Presentation
Complex Number I - Presentationyhchung
 
Ch 7 Review March 18
Ch  7 Review March 18Ch  7 Review March 18
Ch 7 Review March 18RyanWatt
 
Complex Numbers And Appsfeb
Complex Numbers And AppsfebComplex Numbers And Appsfeb
Complex Numbers And Appsfebnitinpatelceng
 
Lattice Multiplication
Lattice MultiplicationLattice Multiplication
Lattice MultiplicationLilianPatrick
 
Applications of Definite Intergral
Applications of Definite IntergralApplications of Definite Intergral
Applications of Definite IntergralRAVI PRASAD K.J.
 
B.tech ii unit-3 material multiple integration
B.tech ii unit-3 material multiple integrationB.tech ii unit-3 material multiple integration
B.tech ii unit-3 material multiple integrationRai University
 
B.tech ii unit-2 material beta gamma function
B.tech ii unit-2 material beta gamma functionB.tech ii unit-2 material beta gamma function
B.tech ii unit-2 material beta gamma functionRai University
 
Complex number
Complex numberComplex number
Complex numberAnum Urooj
 

Andere mochten auch (19)

5.9 complex numbers
5.9 complex numbers5.9 complex numbers
5.9 complex numbers
 
Complex Numbers
Complex NumbersComplex Numbers
Complex Numbers
 
complex numbers
complex numberscomplex numbers
complex numbers
 
Complex number
Complex numberComplex number
Complex number
 
Complex Numbers
Complex NumbersComplex Numbers
Complex Numbers
 
Complex Number's Applications
Complex Number's ApplicationsComplex Number's Applications
Complex Number's Applications
 
Complex numbers org.ppt
Complex numbers org.pptComplex numbers org.ppt
Complex numbers org.ppt
 
Complex Number I - Presentation
Complex Number I - PresentationComplex Number I - Presentation
Complex Number I - Presentation
 
Ankit maths ppt
Ankit maths pptAnkit maths ppt
Ankit maths ppt
 
Ch 7 Review March 18
Ch  7 Review March 18Ch  7 Review March 18
Ch 7 Review March 18
 
Complex Numbers And Appsfeb
Complex Numbers And AppsfebComplex Numbers And Appsfeb
Complex Numbers And Appsfeb
 
Lattice multiplication
Lattice multiplicationLattice multiplication
Lattice multiplication
 
Lattice Multiplication
Lattice MultiplicationLattice Multiplication
Lattice Multiplication
 
Complex Numbers
Complex NumbersComplex Numbers
Complex Numbers
 
Ch 7 c volumes
Ch 7 c  volumesCh 7 c  volumes
Ch 7 c volumes
 
Applications of Definite Intergral
Applications of Definite IntergralApplications of Definite Intergral
Applications of Definite Intergral
 
B.tech ii unit-3 material multiple integration
B.tech ii unit-3 material multiple integrationB.tech ii unit-3 material multiple integration
B.tech ii unit-3 material multiple integration
 
B.tech ii unit-2 material beta gamma function
B.tech ii unit-2 material beta gamma functionB.tech ii unit-2 material beta gamma function
B.tech ii unit-2 material beta gamma function
 
Complex number
Complex numberComplex number
Complex number
 

Ähnlich wie Complex numbers polynomial multiplication

Gaussian Integration
Gaussian IntegrationGaussian Integration
Gaussian IntegrationReza Rahimi
 
An Algorithm to Find the Largest Circle inside a Polygon
An Algorithm to Find the Largest Circle inside a PolygonAn Algorithm to Find the Largest Circle inside a Polygon
An Algorithm to Find the Largest Circle inside a PolygonKasun Ranga Wijeweera
 
VHDL and Cordic Algorithim
VHDL and Cordic AlgorithimVHDL and Cordic Algorithim
VHDL and Cordic AlgorithimSubeer Rangra
 
Recurrent Problem in Discrete Mathmatics.pptx
Recurrent Problem in Discrete Mathmatics.pptxRecurrent Problem in Discrete Mathmatics.pptx
Recurrent Problem in Discrete Mathmatics.pptxgbikorno
 
Binomial theorem for any index
Binomial theorem for any indexBinomial theorem for any index
Binomial theorem for any indexindu psthakur
 
Unit 1 Operation on signals
Unit 1  Operation on signalsUnit 1  Operation on signals
Unit 1 Operation on signalsDr.SHANTHI K.G
 
05 history of cv a machine learning (theory) perspective on computer vision
05  history of cv a machine learning (theory) perspective on computer vision05  history of cv a machine learning (theory) perspective on computer vision
05 history of cv a machine learning (theory) perspective on computer visionzukun
 
An Algorithm to Find the Visible Region of a Polygon
An Algorithm to Find the Visible Region of a PolygonAn Algorithm to Find the Visible Region of a Polygon
An Algorithm to Find the Visible Region of a PolygonKasun Ranga Wijeweera
 
DIGITAL COMMUNICATION: ENCODING AND DECODING OF CYCLIC CODE
DIGITAL COMMUNICATION: ENCODING AND DECODING OF CYCLIC CODE DIGITAL COMMUNICATION: ENCODING AND DECODING OF CYCLIC CODE
DIGITAL COMMUNICATION: ENCODING AND DECODING OF CYCLIC CODE ShivangiSingh241
 
Interpolation techniques - Background and implementation
Interpolation techniques - Background and implementationInterpolation techniques - Background and implementation
Interpolation techniques - Background and implementationQuasar Chunawala
 
Copy of y16 02-2119divide-and-conquer
Copy of y16 02-2119divide-and-conquerCopy of y16 02-2119divide-and-conquer
Copy of y16 02-2119divide-and-conquerJoepang2015
 
Calculus Review for semester 1 at University
Calculus Review for semester 1 at UniversityCalculus Review for semester 1 at University
Calculus Review for semester 1 at Universitynetaf56543
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)ijceronline
 
Graphs of the Sine and Cosine Functions Lecture
Graphs of the Sine and Cosine Functions LectureGraphs of the Sine and Cosine Functions Lecture
Graphs of the Sine and Cosine Functions LectureFroyd Wess
 

Ähnlich wie Complex numbers polynomial multiplication (20)

Gaussian Integration
Gaussian IntegrationGaussian Integration
Gaussian Integration
 
An Algorithm to Find the Largest Circle inside a Polygon
An Algorithm to Find the Largest Circle inside a PolygonAn Algorithm to Find the Largest Circle inside a Polygon
An Algorithm to Find the Largest Circle inside a Polygon
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
VHDL and Cordic Algorithim
VHDL and Cordic AlgorithimVHDL and Cordic Algorithim
VHDL and Cordic Algorithim
 
Recurrent Problem in Discrete Mathmatics.pptx
Recurrent Problem in Discrete Mathmatics.pptxRecurrent Problem in Discrete Mathmatics.pptx
Recurrent Problem in Discrete Mathmatics.pptx
 
Time complexity
Time complexityTime complexity
Time complexity
 
Binomial theorem for any index
Binomial theorem for any indexBinomial theorem for any index
Binomial theorem for any index
 
Unit 1 Operation on signals
Unit 1  Operation on signalsUnit 1  Operation on signals
Unit 1 Operation on signals
 
05 history of cv a machine learning (theory) perspective on computer vision
05  history of cv a machine learning (theory) perspective on computer vision05  history of cv a machine learning (theory) perspective on computer vision
05 history of cv a machine learning (theory) perspective on computer vision
 
Taylor problem
Taylor problemTaylor problem
Taylor problem
 
An Algorithm to Find the Visible Region of a Polygon
An Algorithm to Find the Visible Region of a PolygonAn Algorithm to Find the Visible Region of a Polygon
An Algorithm to Find the Visible Region of a Polygon
 
DIGITAL COMMUNICATION: ENCODING AND DECODING OF CYCLIC CODE
DIGITAL COMMUNICATION: ENCODING AND DECODING OF CYCLIC CODE DIGITAL COMMUNICATION: ENCODING AND DECODING OF CYCLIC CODE
DIGITAL COMMUNICATION: ENCODING AND DECODING OF CYCLIC CODE
 
Interpolation techniques - Background and implementation
Interpolation techniques - Background and implementationInterpolation techniques - Background and implementation
Interpolation techniques - Background and implementation
 
Copy of y16 02-2119divide-and-conquer
Copy of y16 02-2119divide-and-conquerCopy of y16 02-2119divide-and-conquer
Copy of y16 02-2119divide-and-conquer
 
Calculus Review for semester 1 at University
Calculus Review for semester 1 at UniversityCalculus Review for semester 1 at University
Calculus Review for semester 1 at University
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
stoch41.pdf
stoch41.pdfstoch41.pdf
stoch41.pdf
 
Computer science-formulas
Computer science-formulasComputer science-formulas
Computer science-formulas
 
Graphs of the Sine and Cosine Functions Lecture
Graphs of the Sine and Cosine Functions LectureGraphs of the Sine and Cosine Functions Lecture
Graphs of the Sine and Cosine Functions Lecture
 

Mehr von Strand Life Sciences Pvt Ltd (12)

Strand genomics features in CIO review
Strand genomics features in CIO reviewStrand genomics features in CIO review
Strand genomics features in CIO review
 
Rules of a Quantum World
Rules of  a Quantum WorldRules of  a Quantum World
Rules of a Quantum World
 
Least common ancestors in constant time
Least common ancestors in constant timeLeast common ancestors in constant time
Least common ancestors in constant time
 
Introduction to statistics iii
Introduction to statistics iiiIntroduction to statistics iii
Introduction to statistics iii
 
Introduction to statistics ii
Introduction to statistics iiIntroduction to statistics ii
Introduction to statistics ii
 
Introduction to statistics
Introduction to statisticsIntroduction to statistics
Introduction to statistics
 
Dynamic programming for simd
Dynamic programming for simdDynamic programming for simd
Dynamic programming for simd
 
Converting High Dimensional Problems to Low Dimensional Ones
Converting High Dimensional Problems to Low Dimensional OnesConverting High Dimensional Problems to Low Dimensional Ones
Converting High Dimensional Problems to Low Dimensional Ones
 
Searching using Quantum Rules
Searching using Quantum RulesSearching using Quantum Rules
Searching using Quantum Rules
 
Randomized algorithms
Randomized algorithmsRandomized algorithms
Randomized algorithms
 
Suffix arrays
Suffix arraysSuffix arrays
Suffix arrays
 
Alignment of raw reads in Avadis NGS
Alignment of raw reads in Avadis NGSAlignment of raw reads in Avadis NGS
Alignment of raw reads in Avadis NGS
 

Kürzlich hochgeladen

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Complex numbers polynomial multiplication

  • 1. Multiplying Polynomials Fast Why do we need Complex Numbers?
  • 2. The Problem • (an xn + an-1 xn-1+…..+ a0 x0) * (bn xn + bn-1 xn-1+…..+ b0 x0) • O(n^2) time – (Σi=0..k ai * bk-i) is coefficient of xk • Can one do better?
  • 3. Applications • Where all does a pattern string P appear in a text string T? – P 0’s, 1’s and don’t cares. – T 0’s and 1’s • Easy in O(|P|*|T|) time – Can one do better?
  • 4. Conversion to Polynomial Multiplication • Treat P and T as polynomials – T=0101 1 x0 + 0 x1 + 1 x2 + 0 x3 tk-i tk-2 tk-1 tk – P=01D1 0 x0 + 1 x1 + 0 x2 + 1 x3 1 0 1 0 1 1 0 0 1 • Multiply Prev and T 1 0 0 0 1 0 0 p-i p-1 p-0 – (Σi=0..k previ * tk-i) is coefficient of xk – (Σi=0..k p|P|-i * tk-i) is coefficient of xk • >=1 if and only if a 1 in P aligns with a 0 in T when P is placed with end at tk – 2 polynomial multiplications suffice to find all matches of P in T
  • 5. Other Applications • Image Processing At this location Slide this mask all over the Multiply each bit bigger one in the mask with the corresponding bit in the image, sum these up
  • 6. Polynomial Multiplication An Equivalent Form • Evaluate each polynomial at 2n+1 distinct x’s – A(x) = (an xn + an-1 xn-1+…..+ a0 x0) -> A(v0)…..A(v2n) – B(x) = (bn xn + bn-1 xn-1+…..+ b0 x0) -> B(v0)…..B(v2n) • A(x) * B(x) -> A(v0)*B(v0)………..A(v2n)*B(v2n) – Convolution in one domain=Simple multiplication in another – O(n) time!!!
  • 7. Multi-Point Polynomial Evaluation • Evaluate A(x) at v0 ……vn – O(n) time per vi using Horner’s rule • Problems – O(n2) time – Large numbers with n log vi bits
  • 8. Multi-Point Polynomial Evaluation Speed Up • A(x) mod (x-v) – A(v) – O(n) time using high school polynomial division • A’(x) = A(x) mod (x-v0) (x-v1) [how fast?] – A’(x) mod (x-v0) = A(v0) [O(1)] – A’(x) mod (x-v1) = A(v1) [O(1)] – 2 expensive polynomial divisions could potentially be replaced by 1
  • 9. Fast Multi-Point Polynomial Evaluation T0(x)=A(x) mod (x-v0) (x-v1).. (x-vn) T1(x)=T0 (x) mod (x-v0)..(x-v(n+1)/2-1) T2 (x)=T0 (x) mod (x-v(n+1)/2) (x-vn) • If T(x) mod (x-vi).. (x-vj) can be done in O(deg(T)) time, then what is the total time taken? – O(n log n)!!
  • 10. Computing T(x) mod (x-v1).. (x-vk) • High school algorithm – Time taken: O( deg(T) * k ) – How do we make this faster? • Stroke of genius • Can we choose vi’s so (x-v1).. (x-vk) = xk-v? • Then we get O(deg(T) ) time
  • 11. Choosing vi’s • When is (x-v1)(x-v2) = x2+v1v2 ? – v2+v1=0 • When is (x-a)(x+a)(x-b)(x+b) = x4+ a2b2? – b2-a2=0 => b2=-a2 • => b= sqrt(-1) a • the 4 numbers are 1 –i -1 i • alternatively (–i)0 (–i)1 (–i)2 (–i)3
  • 12. Choosing vi’s • Choose vi to be roots of xn -1 = Cos(2Πk/n) + i Sin(2Πk/n) = e i 2Πk/n – Powering just goes around the unit circle • Computing with log n bits suffices
  • 13. Exercise • Choose vi to be roots of xn -1 = Cos(2Πk/n) + i Sin(2Πk/n) = e i 2Πk/n – Organize these roots so we get polynomials with just 2 terms in every node of the tree on slide 9 • Assume n+1 is a power of 2
  • 14. Conclusion • Also called : Fast Fourier Transform • Complex Numbers are interesting! • Reality can be explained elegantly only with complex numbers!!