feb abhi shelat FFT,Median
|
|
- Martha Sullivan
- 5 years ago
- Views:
Transcription
1 L8 feb abhi shelat FFT,Median
2 merge-sort (A, p, r) if p<r q (p + r)/2 merge-sort (A, p, q) merge-sort (A, q +1,r) merge(a, p, q, r) MERGE(A[1.. n],m): i 1; j m +1 for k 1 to n if j>n B[k] A[i]; i i +1 else if i>m B[k] A[j]; j j +1 else if A[i] <A[j] B[k] A[i]; i i +1 else B[k] A[j]; j j +1 for k 1 to n A[k] B[k] jeff erickson
3 Karatsuba(ab, cd) Base case: return b*d if inputs are 1-digit ac = Karatsuba(a,c) bd = Karatsuba(b,d) 3T (n/2) + 2n t = Karatsuba((a+b),(c+d)) mid = t - ac - bd RETURN ac* mid*100 + bd 4n 3n
4 Closest(P,SX,SY) Let q be the middle-element of SX Divide P into Left, Right according to q delta,r,j = MIN(Closest(Left, LX, LY) Closest(Right, RX, RY) ) Mohawk = { Scan SY, add pts that are delta from q.x } For each point x in Mohawk (in order): Compute distance to its next 15 neighbors Update delta,r,j if any pair (x,y) is < delta Return (delta,r,j) Can be reduced to 7!
5 second attempt arbit+(a[1...n]) base case if A <=2, (lg,minl,maxl) = arbit(left(a)) (rg,minr,maxr) = arbit(right(a)) return max{maxr-minl,lg,rg}, min{minl, minr}, max{maxl, maxr}
6 [strassen]
7 FFT(f=a[1,...,n]) Base case if n<=2 E[...] <- FFT(Ae) O[...] <- FFT(Ao) // eval Ae on n/2 roots of unity // eval Ao on n/2 roots of unity combine results using equation: Return n resulting values.
8 Fast Fourier Transform 2
9 FFT input: a 0,a 1,a 2,...,a n 1 output: evaluate polynomial A at (any) n different points. n points on a curve
10 Brute force method to evaluate A at n points:
11
12 FFT(f=a[1,...,n]) Evaluates degree n poly on the n th roots of unity
13 Last remaining issue: Which points to use? Roots of unity should have n solutions what are they?
14 the n solutions are: n1,e 2 i/n,e 2 i2/n,e 2 i3/n,...,e 2 i(n 1)/no because e 2 i =1
15 the n solutions are: consider for j=0,1,2,3,...,n-1 = is an n th root of unity
16 What is this number? = is an n th root of unity
17 Taylor series expansion of a function f around point a f (y) = f (a)+ f 0 (a) (y a)+ f 00 (a) 1! 2! (y a) 2 + f 000 (a) 3! (y a) 2 + e x = around 0
18 What is this number? = is an n th root of unity e 2pij/n = cos(2pj/n)+i sin(2pj/n)
19 = is an n th root of unity Lets compute! 1,8
20 Compute all 8 roots of unity Then graph them
21 roots of unity should have n solutions e 2pij/n = cos(2pj/n)+i sin(2pj/n)
22 squaring the n th roots of unity
23 Thm: Squaring an n th root produces an n/2 th root. 1! 1,8 = p2 + p i example: 2! 2 1,8 = 1 p2 + p i 2 = 2 1 p p2 i p 2 + i p 2 2 =1/2+i 1/2 = i
24 squaring the n th roots of unity
25 Thm: Squaring an n th root produces an n/2 th root. n1,e 2 i(1/n),e 2 i(2/n),e 2 i(3/n),...,e 2 i(n/2)/n,e 2 i(n/2+1)/n 2 i(n,...,e 1)/no
26 Thm: Squaring an n th root produces an n/2 th root. n1,e 2 i(1/n),e 2 i(2/n),e 2 i(3/n),...,e 2 i(n/2)/n,e 2 i(n/2+1)/n 2 i(n,...,e 1)/no 1 e 2 i(1/(n/2)) e 2 i(2/(n/2)) e 2 i(3/(n/2)) 1 e 2 i((n/2)+1/(n/2)) = e 2 i(1+1/(n/2)) =1 e 2 i(1/(n/2))
27 If n=16
28 evaluate at a root of unity A(! i,n )=A e (! 2 i,n)+! i,n A o (! 2 i,n) n th root of unity n/2 th root of unity n/2 th root of unity
29 FFT(f=a[1,...,n]) Evaluates degree n poly on the n th roots of unity
30 FFT(f=a[1,...,n]) Base case if n<=2 E[...] <- FFT(Ae) O[...] <- FFT(Ao) // eval Ae on n/2 roots of unity // eval Ao on n/2 roots of unity combine results using equation: Return n resulting values.
31
32 a3 a2 a1 a0 b3 b2 b1 b0 a3b0 a2b0 a1b0 a0b0 a3b1 a2b1 a1b1 a0b1 a3b2 a2b2 a1b2 a0b2 a3b3 a2b3 a1b3 a0b3
33 A(x) =a 3 x 3 + a 2 x 2 + a 1 x + a 0 B(x) =b 3 x 3 + b 2 x 2 + b 1 x + b 0 C(x) = a 3 b 3 x 6 + (a 3 b 2 + a 2 b 3 )x 5 + (a 3 b 1 + a 2 b 2 + a 1 b 3 )x 4 + (a 3 b 0 + a 2 b 1 + a 1 b 2 + a 0 b 3 )x 3 + (a 2 b 0 + a 1 b 1 + a 0 b 2 )x 2 + (a 1 b 0 + a 0 b 1 )x+ a 0 b 0
34 y=2x+1 y=x+1
35 y=2x+1 y=x+1
36 a3 a2 a1 a0 b3 b2 b1 b0 A(x) =a 0 + a 1 x + a 2 x 2 + a 3 x 3 +0x 4 +0x 5 +0x 6 +0x 7 B(x) =b 0 + b 1 x + b 2 x 2 + b 3 x 3 +0x 4 +0x 5 +0x 6 +0x 7
37 a3 a2 a1 a0 b3 b2 b1 b0 A(x) =a 0 + a 1 x + a 2 x 2 + a 3 x 3 +0x 4 +0x 5 +0x 6 +0x 7 B(x) =b 0 + b 1 x + b 2 x 2 + b 3 x 3 +0x 4 +0x 5 +0x 6 +0x 7 A(! 0 ) A(! 1 ) A(! 2 ) A(! 7 )...
38 a3 a2 a1 a0 b3 b2 b1 b0 A(x) =a 0 + a 1 x + a 2 x 2 + a 3 x 3 +0x 4 +0x 5 +0x 6 +0x 7 B(x) =b 0 + b 1 x + b 2 x 2 + b 3 x 3 +0x 4 +0x 5 +0x 6 +0x 7 A(! 0 ) A(! 1 ) A(! 2 ) A(! 7 )... B(! 0 ) B(! 1 ) B(! 2 )... B(! 7 ) FFT FFT
39 a3 a2 a1 a0 b3 b2 b1 b0 A(x) =a 0 + a 1 x + a 2 x 2 + a 3 x 3 +0x 4 +0x 5 +0x 6 +0x 7 B(x) =b 0 + b 1 x + b 2 x 2 + b 3 x 3 +0x 4 +0x 5 +0x 6 +0x 7 A(! 0 ) A(! 1 ) A(! 2 ) A(! 7 )... B(! 0 ) B(! 1 ) B(! 2 )... B(! 7 ) FFT FFT C(! 0 ) C(! 1 ) C(! 2 )... C(! 7 )
40 a3 a2 a1 a0 b3 b2 b1 b0 A(x) =a 0 + a 1 x + a 2 x 2 + a 3 x 3 +0x 4 +0x 5 +0x 6 +0x 7 B(x) =b 0 + b 1 x + b 2 x 2 + b 3 x 3 +0x 4 +0x 5 +0x 6 +0x 7 A(! 0 ) A(! 1 ) A(! 2 ) A(! 7 )... B(! 0 ) B(! 1 ) B(! 2 )... B(! 7 ) FFT FFT C(! 0 ) C(! 1 ) C(! 2 )... C(! 7 ) C(x) =c 0 + c 1 x + c 2 x 2 + c 7 x 7 IFFT
41 application to mult karatsuba a b c d
42 application to mult karatsuba a b c d
43 Multiplying n-bit numbers Schönhage Strassen 71 Fürer 07 O(n log n log log n) O(n log(n)2 log (n) )
44 AGMP-BASEDIMPLEMENTATIONOFSCHÖNHAGE-STRASSEN S LARGE INTEGER MULTIPLICATION ALGORITHM PIERRICK GAUDRY, ALEXANDER KRUPPA, AND PAUL ZIMMERMANN Abstract. Schönhage-Strassen s algorithm is one of the best known algorithms for multiplying large integers. Implementing it efficiently is of utmost importance, since many other algorithms rely on it as a subroutine. We present here an improved implementation, based on the one distributed within the GMP library. The following ideas and techniques were used or tried: faster arithmetic modulo 2 n +1, improved cache locality, Mersenne transforms, Chinese Remainder Reconstruction, the 2trick,Harley sandgranlund stricks, improved tuning. We also discuss some ideas we plan to try in the future. Introduction Since Schönhage and Strassen have shown in 1971 how to multiply two N-bit integers in O(N log N log log N) time[21],severalauthorsshowedhowtoreduceotheroperations inverse, division, square root, gcd, base conversion, elementary functions to multiplication, possibly with log N multiplicative factors [5, 8, 17, 18, 20, 23]. It has now become common practice to express complexities in terms of the cost M(N) to multiply two N-bit numbers, and many researchers tried hard to get the best possible constants in front of M(N) forthe above-mentioned operations (see for example [6, 16]). Strangely, much less effort was made for decreasing the implicit constant in M(N) itself, although any gain on that constant will give a similar gain on all multiplication-based operations. Some authors reported on implementations of large integer arithmetic for specific hardware or as part of a number-theoretic project [2, 10]. In this article we concentrate on the question of an optimized implementation of Schönhage-Strassen s algorithm on a classical workstation.
45 Applications of FFT
46 Applications of FFT
47
48 String matching with * ACAAGATGCCATTGTCCCCCGGCCTCCTGCTGCTGCTGCTCTCCGGGGCCACGGCCACCGCTGCCCTGCC CCTGGAGGGTGGCCCCACCGGCCGAGACAGCGAGCATATGCAGGAAGCGGCAGGAATAAGGAAAAGCAGC CTCCTGACTTTCCTCGCTTGGTGGTTTGAGTGGACCTCCCAGGCCAGTGCCGGGCCCCTCATAGGAGAGG AAGCTCGGGAGGTGGCCAGGCGGCAGGAAGGCGCACCCCCCCAGCAATCCGCGCGCCGGGACAGAATGCC CTGCAGGAACTTCTTCTGGAAGACCTTCTCCTCCTGCAAATAAAACCTCACCCATGAATGCTCACGCAAG TTTAATTACAGACCTGAA Looking for all occurrences of GGC*GAG*C*GC where I don't care what the * symbol is.
49 Median
50 problem: given a list of n elements, find the element of rank n/2. (half are larger, half are smaller)
51 problem: given a list of n elements, find the element of rank n/2. (half are larger, half are smaller) can generalize to i first solution: sort and pluck.
52 problem: given a list of n elements, find the element of rank i. key insight: we do not have to fully sort. semi sort can suffice.
53 pick first element partition list about this one see where we stand
54 review: how to partition a list
55 review: how to partition a list GOAL: start with THIS LIST and END with THAT LIST less than greater than
56 review: how to partition a list
57 review: how to partition a list
58 review: how to partition a list
59 review: how to partition a list
60 review: how to partition a list
61 review: how to partition a list partitioning a list about an element takes linear time.
62 select
63 select handle base case. partition list about first element if pivot p is position i, return pivot else if pivot p is in position > i select else select
64 Assume our partition always select splits list into two eql parts handle base case. partition list about first element if pivot is position i, return pivot else if pivot is in position > i select else select
65 Assume our partition always select splits list into two eql parts handle base case. partition list about first element if pivot is position i, return pivot else if pivot is in position > i select else select
66 problem: what if we always pick bad partitions?
67 problem: what if we always pick bad partitions?
68 problem: what if we always pick bad partitions?
69 problem: what if we always pick bad partitions?
70 select handle base case. partition list about first element if pivot is position i, return pivot else if pivot is in position > i select else select
71 select handle base case. partition list about first element if pivot is position i, return pivot else if pivot is in position > i select else select T (n) =T (n 1) + O(n) (n 2 )
72 Needed: a good partition element partition
73 Needed: a good partition element partition produce an element where 30% smaller, 30% larger
74 solution: bootstrap image: gucci image: mark nason image: d&g
75 partition
76 partition
77 partition
78 partition median of each group form a smaller list select use the median of this smaller list as the partition element
79 partition
80 partition divide list into groups of 5 elements find median of each small list gather all medians call select(...) on this sublist to find median return the result
81 partition divide list into groups of 5 elements find median of each small list gather all medians call select(...) on this sublist to find median return the result
82 a nice property of our partition
83 a nice property of our partition
84 a nice property of our partition
85 SWITCH TO A BIGGER EXAMPLE
86 a nice property of our partition < < < < < < < < < < <
87 a nice property of our partition < < < < < < < < < < < this implies there are at most numbers larger than /smaller
88 a nice property of our partition
89
90 select
91 select handle base case for small list else pivot = FindPartitionValue(A,n) partition list about pivot if pivot is position i, return pivot else if pivot is in position > i select else select
92
93 FindPartition divide list into groups of 5 elements find median of each small list gather all medians call select(...) on this sublist to find median return the result
94 select handle base case for small list else pivot = FindPartitionValue(A,n) partition list about pivot if pivot is position i, return pivot else if pivot is in position > i select else select
95 select handle base case for small list else pivot = FindPartitionValue(A,n) partition list about pivot if pivot is position i, return pivot else if pivot is in position > i select else select
96
97
98 Stairs(n) if n<=1 return 1 return Stairs(n-1) + Stairs(n-2)
99 Stairs(n) if n<=1 return 1 ret Stairs(n-1) + Stairs(n-2) Stairs(5) Stairs(4) Stairs(3) Stairs(3) Stairs(2) Stairs(2) Stairs(1) Stairs(2) Stairs(1) Stairs(1) Stairs(0) Stairs(1) Stairs(0)
100 initialize memory M Stairs(n) if n<=1 then return 1 if n is in M, return M[n] answer = Stairs(i-1)+ Stairs(i-2) M[n] = answer return answer
101 Stairs(n) if n<=1 then return 1 if n is in M, return M[n] answer = Stairs(i-1)+ Stairs(i-2) M[n] = answer return answer Stairs(5)
102 Stairs(n) stair[0]=1 stair[1]=1 for i=2 to n stair[i] = stair[i-1]+stair[i-2] return stair[i]
103 initialize memory M Stairs(n)
104 Stairs(n) if n<=1 then return 1 if n is in M, return M[n] answer = Stairs(i-1)+ Stairs(i-2) M[n] = answer return answer Stairs(5)
105 Stairs(n) stair[0]=1 stair[1]=1 for i=2 to n stair[i] = stair[i-1]+stair[i-2] return stair[i]
106 Dynamic Programming
107 two big ideas
108 two big ideas recursive structure memoizing
109 wood cutting
110
111 Spot price for lumber
112 Spot price for lumber
113 Log cutter dilemna input to the problem: n, (p 1,...,p n ) goal:
114 Observation
115 Solution equation
116 Approach 0... i
117 BestLogs( n, (p 1,...,p n ) ) if n<=0 return 0
118 BestLogs( n, (p 1,...,p n ) ) if n<=0 return 0 for i=1 to n Best[i] = max k=1...i {p k +Best[i k]}
119 The actual cuts?
120 BestLogs( n, (p 1,...,p n ) ) if n<=0 return 0 for i=1 to n Best[i] = max k=1...i {p k +Best[i k]}
shelat 16f-4800 sep Matrix Mult, Median, FFT
L5 shelat 16f-4800 sep 23 2016 Matrix Mult, Median, FFT merge-sort (A, p, r) if p
More informationfeb abhi shelat Matrix, FFT
L7 feb 11 2016 abhi shelat Matrix, FFT userid: = Using the standard method, how many multiplications does it take to multiply two NxN matrices? cos( /4) = cos( /2) = sin( /4) = sin( /2) = Mergesort Karatsuba
More informationshelat divide&conquer closest points matrixmult median
L6feb 9 2016 shelat 4102 divide&conquer closest points matrixmult median 7.5 7.8 9.5 3.7 26.1 closest pair of points simple brute force approach takes 14 1 2 7 8 9 4 13 3 10 11 5 12 6 solve the large problem
More informationDivide and conquer. Philip II of Macedon
Divide and conquer Philip II of Macedon Divide and conquer 1) Divide your problem into subproblems 2) Solve the subproblems recursively, that is, run the same algorithm on the subproblems (when the subproblems
More informationKartsuba s Algorithm and Linear Time Selection
CS 374: Algorithms & Models of Computation, Fall 2015 Kartsuba s Algorithm and Linear Time Selection Lecture 09 September 22, 2015 Chandra & Manoj (UIUC) CS374 1 Fall 2015 1 / 32 Part I Fast Multiplication
More informationDivide and Conquer. Maximum/minimum. Median finding. CS125 Lecture 4 Fall 2016
CS125 Lecture 4 Fall 2016 Divide and Conquer We have seen one general paradigm for finding algorithms: the greedy approach. We now consider another general paradigm, known as divide and conquer. We have
More information1 Divide and Conquer (September 3)
The control of a large force is the same principle as the control of a few men: it is merely a question of dividing up their numbers. Sun Zi, The Art of War (c. 400 C.E.), translated by Lionel Giles (1910)
More informationCPSC 518 Introduction to Computer Algebra Schönhage and Strassen s Algorithm for Integer Multiplication
CPSC 518 Introduction to Computer Algebra Schönhage and Strassen s Algorithm for Integer Multiplication March, 2006 1 Introduction We have now seen that the Fast Fourier Transform can be applied to perform
More informationCSE 421 Algorithms. T(n) = at(n/b) + n c. Closest Pair Problem. Divide and Conquer Algorithms. What you really need to know about recurrences
CSE 421 Algorithms Richard Anderson Lecture 13 Divide and Conquer What you really need to know about recurrences Work per level changes geometrically with the level Geometrically increasing (x > 1) The
More informationFrequency Domain Finite Field Arithmetic for Elliptic Curve Cryptography
Frequency Domain Finite Field Arithmetic for Elliptic Curve Cryptography Selçuk Baktır, Berk Sunar {selcuk,sunar}@wpi.edu Department of Electrical & Computer Engineering Worcester Polytechnic Institute
More informationImplementation of the DKSS Algorithm for Multiplication of Large Numbers
Implementation of the DKSS Algorithm for Multiplication of Large Numbers Christoph Lüders Universität Bonn The International Symposium on Symbolic and Algebraic Computation, July 6 9, 2015, Bath, United
More informationSpeedy Maths. David McQuillan
Speedy Maths David McQuillan Basic Arithmetic What one needs to be able to do Addition and Subtraction Multiplication and Division Comparison For a number of order 2 n n ~ 100 is general multi precision
More informationCPSC 518 Introduction to Computer Algebra Asymptotically Fast Integer Multiplication
CPSC 518 Introduction to Computer Algebra Asymptotically Fast Integer Multiplication 1 Introduction We have now seen that the Fast Fourier Transform can be applied to perform polynomial multiplication
More informationHow to Multiply. 5.5 Integer Multiplication. Complex Multiplication. Integer Arithmetic. Complex multiplication. (a + bi) (c + di) = x + yi.
How to ultiply Slides by Kevin Wayne. Copyright 5 Pearson-Addison Wesley. All rights reserved. integers, matrices, and polynomials Complex ultiplication Complex multiplication. a + bi) c + di) = x + yi.
More informationParallel Integer Polynomial Multiplication Changbo Chen, Svyatoslav Parallel Integer Covanov, Polynomial FarnamMultiplication
Parallel Integer Polynomial Multiplication Parallel Integer Polynomial Multiplication Changbo Chen 1 Svyatoslav Covanov 2,3 Farnam Mansouri 2 Marc Moreno Maza 2 Ning Xie 2 Yuzhen Xie 2 1 Chinese Academy
More informationInteger Multiplication
Integer Multiplication in almost linear time Martin Fürer CSE 588 Department of Computer Science and Engineering Pennsylvania State University 1/24/08 Karatsuba algebraic Split each of the two factors
More informationCSE 421 Algorithms: Divide and Conquer
CSE 42 Algorithms: Divide and Conquer Larry Ruzzo Thanks to Richard Anderson, Paul Beame, Kevin Wayne for some slides Outline: General Idea algorithm design paradigms: divide and conquer Review of Merge
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 14 Divide and Conquer Fast Fourier Transform Sofya Raskhodnikova 10/7/2016 S. Raskhodnikova; based on slides by K. Wayne. 5.6 Convolution and FFT Fast Fourier Transform:
More informationA design paradigm. Divide and conquer: (When) does decomposing a problem into smaller parts help? 09/09/ EECS 3101
A design paradigm Divide and conquer: (When) does decomposing a problem into smaller parts help? 09/09/17 112 Multiplying complex numbers (from Jeff Edmonds slides) INPUT: Two pairs of integers, (a,b),
More informationClass Note #14. In this class, we studied an algorithm for integer multiplication, which. 2 ) to θ(n
Class Note #14 Date: 03/01/2006 [Overall Information] In this class, we studied an algorithm for integer multiplication, which improved the running time from θ(n 2 ) to θ(n 1.59 ). We then used some of
More informationPolynomials. In many problems, it is useful to write polynomials as products. For example, when solving equations: Example:
Polynomials Monomials: 10, 5x, 3x 2, x 3, 4x 2 y 6, or 5xyz 2. A monomial is a product of quantities some of which are unknown. Polynomials: 10 + 5x 3x 2 + x 3, or 4x 2 y 6 + 5xyz 2. A polynomial is a
More informationThe divide-and-conquer strategy solves a problem by: Chapter 2. Divide-and-conquer algorithms. Multiplication
The divide-and-conquer strategy solves a problem by: Chapter 2 Divide-and-conquer algorithms 1 Breaking it into subproblems that are themselves smaller instances of the same type of problem 2 Recursively
More informationIntroduction to Algorithms
Lecture 1 Introduction to Algorithms 1.1 Overview The purpose of this lecture is to give a brief overview of the topic of Algorithms and the kind of thinking it involves: why we focus on the subjects that
More informationDivide and Conquer algorithms
Divide and Conquer algorithms Another general method for constructing algorithms is given by the Divide and Conquer strategy. We assume that we have a problem with input that can be split into parts in
More informationDivide and Conquer: Polynomial Multiplication Version of October 1 / 7, 24201
Divide and Conquer: Polynomial Multiplication Version of October 7, 2014 Divide and Conquer: Polynomial Multiplication Version of October 1 / 7, 24201 Outline Outline: Introduction The polynomial multiplication
More informationInteger multiplication with generalized Fermat primes
Integer multiplication with generalized Fermat primes CARAMEL Team, LORIA, University of Lorraine Supervised by: Emmanuel Thomé and Jérémie Detrey Journées nationales du Calcul Formel 2015 (Cluny) November
More informationFast Polynomial Multiplication
Fast Polynomial Multiplication Marc Moreno Maza CS 9652, October 4, 2017 Plan Primitive roots of unity The discrete Fourier transform Convolution of polynomials The fast Fourier transform Fast convolution
More informationThree Ways to Test Irreducibility
Three Ways to Test Irreducibility Richard P. Brent Australian National University joint work with Paul Zimmermann INRIA, Nancy France 12 Feb 2009 Outline Polynomials over finite fields Irreducibility criteria
More informationDivide and Conquer. CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30,
Divide and Conquer CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Merging sorted lists: WHAT Given two sorted lists a 1 a 2 a 3 a k b 1 b 2 b 3 b
More informationComputer Algebra: General Principles
Computer Algebra: General Principles For article on related subject see SYMBOL MANIPULATION. Computer algebra is a branch of scientific computation. There are several characteristic features that distinguish
More informationInteger multiplication and the truncated product problem
Integer multiplication and the truncated product problem David Harvey Arithmetic Geometry, Number Theory, and Computation MIT, August 2018 University of New South Wales Political update from Australia
More informationThe divide-and-conquer strategy solves a problem by: 1. Breaking it into subproblems that are themselves smaller instances of the same type of problem
Chapter 2. Divide-and-conquer algorithms The divide-and-conquer strategy solves a problem by: 1. Breaking it into subproblems that are themselves smaller instances of the same type of problem. 2. Recursively
More informationAlgorithms (II) Yu Yu. Shanghai Jiaotong University
Algorithms (II) Yu Yu Shanghai Jiaotong University Chapter 1. Algorithms with Numbers Two seemingly similar problems Factoring: Given a number N, express it as a product of its prime factors. Primality:
More informationShort Division of Long Integers. (joint work with David Harvey)
Short Division of Long Integers (joint work with David Harvey) Paul Zimmermann October 6, 2011 The problem to be solved Divide efficiently a p-bit floating-point number by another p-bit f-p number in the
More informationReductions, Recursion and Divide and Conquer
Chapter 5 Reductions, Recursion and Divide and Conquer CS 473: Fundamental Algorithms, Fall 2011 September 13, 2011 5.1 Reductions and Recursion 5.1.0.1 Reduction Reducing problem A to problem B: (A) Algorithm
More informationRSA Implementation. Oregon State University
RSA Implementation Çetin Kaya Koç Oregon State University 1 Contents: Exponentiation heuristics Multiplication algorithms Computation of GCD and Inverse Chinese remainder algorithm Primality testing 2
More informationPUTNAM PROBLEMS SEQUENCES, SERIES AND RECURRENCES. Notes
PUTNAM PROBLEMS SEQUENCES, SERIES AND RECURRENCES Notes. x n+ = ax n has the general solution x n = x a n. 2. x n+ = x n + b has the general solution x n = x + (n )b. 3. x n+ = ax n + b (with a ) can be
More informationAlgorithms, Design and Analysis. Order of growth. Table 2.1. Big-oh. Asymptotic growth rate. Types of formulas for basic operation count
Types of formulas for basic operation count Exact formula e.g., C(n) = n(n-1)/2 Algorithms, Design and Analysis Big-Oh analysis, Brute Force, Divide and conquer intro Formula indicating order of growth
More informationCS483 Design and Analysis of Algorithms
CS483 Design and Analysis of Algorithms Lecture 6-8 Divide and Conquer Algorithms Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments
More informationGreat Theoretical Ideas in Computer Science
15-251 Great Theoretical Ideas in Computer Science Polynomials, Lagrange, and Error-correction Lecture 23 (November 10, 2009) P(X) = X 3 X 2 + + X 1 + Definition: Recall: Fields A field F is a set together
More informationFaster integer multiplication using short lattice vectors
Faster integer multiplication using short lattice vectors David Harvey and Joris van der Hoeven ANTS XIII, University of Wisconsin, Madison, July 2018 University of New South Wales / CNRS, École Polytechnique
More informationThree Ways to Test Irreducibility
Outline Three Ways to Test Irreducibility Richard P. Brent Australian National University joint work with Paul Zimmermann INRIA, Nancy France 8 Dec 2008 Polynomials over finite fields Irreducibility criteria
More informationDivide and Conquer. Arash Rafiey. 27 October, 2016
27 October, 2016 Divide the problem into a number of subproblems Divide the problem into a number of subproblems Conquer the subproblems by solving them recursively or if they are small, there must be
More informationChapter 4 Finite Fields
Chapter 4 Finite Fields Introduction will now introduce finite fields of increasing importance in cryptography AES, Elliptic Curve, IDEA, Public Key concern operations on numbers what constitutes a number
More informationSolutions to 2015 Entrance Examination for BSc Programmes at CMI. Part A Solutions
Solutions to 2015 Entrance Examination for BSc Programmes at CMI Part A Solutions 1. Ten people sitting around a circular table decide to donate some money for charity. You are told that the amount donated
More informationGreat Theoretical Ideas in Computer Science
15-251 Great Theoretical Ideas in Computer Science Randomness and Computation Lecture 18 (October 25, 2007) Checking Our Work Suppose we want to check p(x) q(x) = r(x), where p, q and r are three polynomials.
More informationIntroduction to Algorithms 6.046J/18.401J/SMA5503
Introduction to Algorithms 6.046J/8.40J/SMA5503 Lecture 3 Prof. Piotr Indyk The divide-and-conquer design paradigm. Divide the problem (instance) into subproblems. 2. Conquer the subproblems by solving
More informationMAT 243 Test 2 SOLUTIONS, FORM A
MAT Test SOLUTIONS, FORM A 1. [10 points] Give a recursive definition for the set of all ordered pairs of integers (x, y) such that x < y. Solution: Let S be the set described above. Note that if (x, y)
More informationAnalysis of Algorithms CMPSC 565
Analysis of Algorithms CMPSC 565 LECTURES 38-39 Randomized Algorithms II Quickselect Quicksort Running time Adam Smith L1.1 Types of randomized analysis Average-case analysis : Assume data is distributed
More informationPUTTING FÜRER ALGORITHM INTO PRACTICE WITH THE BPAS LIBRARY. (Thesis format: Monograph) Linxiao Wang. Graduate Program in Computer Science
PUTTING FÜRER ALGORITHM INTO PRACTICE WITH THE BPAS LIBRARY. (Thesis format: Monograph) by Linxiao Wang Graduate Program in Computer Science A thesis submitted in partial fulfillment of the requirements
More informationSolutions to Exercises, Section 2.4
Instructor s Solutions Manual, Section 2.4 Exercise 1 Solutions to Exercises, Section 2.4 Suppose p(x) = x 2 + 5x + 2, q(x) = 2x 3 3x + 1, s(x) = 4x 3 2. In Exercises 1 18, write the indicated expression
More informationCSCI Honor seminar in algorithms Homework 2 Solution
CSCI 493.55 Honor seminar in algorithms Homework 2 Solution Saad Mneimneh Visiting Professor Hunter College of CUNY Problem 1: Rabin-Karp string matching Consider a binary string s of length n and another
More informationSection September 6, If n = 3, 4, 5,..., the polynomial is called a cubic, quartic, quintic, etc.
Section 2.1-2.2 September 6, 2017 1 Polynomials Definition. A polynomial is an expression of the form a n x n + a n 1 x n 1 + + a 1 x + a 0 where each a 0, a 1,, a n are real numbers, a n 0, and n is a
More informationBasic elements of number theory
Cryptography Basic elements of number theory Marius Zimand 1 Divisibility, prime numbers By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a
More informationx 9 or x > 10 Name: Class: Date: 1 How many natural numbers are between 1.5 and 4.5 on the number line?
1 How many natural numbers are between 1.5 and 4.5 on the number line? 2 How many composite numbers are between 7 and 13 on the number line? 3 How many prime numbers are between 7 and 20 on the number
More informationLucas Lehmer primality test - Wikipedia, the free encyclopedia
Lucas Lehmer primality test From Wikipedia, the free encyclopedia In mathematics, the Lucas Lehmer test (LLT) is a primality test for Mersenne numbers. The test was originally developed by Edouard Lucas
More informationBasic elements of number theory
Cryptography Basic elements of number theory Marius Zimand By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a k for some integer k. Notation
More informationPUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include
PUTNAM TRAINING POLYNOMIALS (Last updated: December 11, 2017) Remark. This is a list of exercises on polynomials. Miguel A. Lerma Exercises 1. Find a polynomial with integral coefficients whose zeros include
More informationCopyright 2000, Kevin Wayne 1
Algorithm runtime analysis and computational tractability Time Complexity of an Algorithm How do we measure the complexity (time, space requirements) of an algorithm. 1 microsecond? Units of time As soon
More informationChapter 5 Divide and Conquer
CMPT 705: Design and Analysis of Algorithms Spring 008 Chapter 5 Divide and Conquer Lecturer: Binay Bhattacharya Scribe: Chris Nell 5.1 Introduction Given a problem P with input size n, P (n), we define
More informationOfficial Solutions 2014 Sun Life Financial CMO Qualifying Rêpechage 1
Official s 2014 Sun Life Financial CMO Qualifying Rêpechage 1 1. Let f : Z Z + be a function, and define h : Z Z Z + by h(x, y) = gcd(f(x), f(y)). If h(x, y) is a two-variable polynomial in x and y, prove
More informationInput Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary
Complexity Analysis Complexity Theory Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary Output TRUE or FALSE Time and Space
More informationContinuing discussion of CRC s, especially looking at two-bit errors
Continuing discussion of CRC s, especially looking at two-bit errors The definition of primitive binary polynomials Brute force checking for primitivity A theorem giving a better test for primitivity Fast
More informationA field F is a set of numbers that includes the two numbers 0 and 1 and satisfies the properties:
Byte multiplication 1 Field arithmetic A field F is a set of numbers that includes the two numbers 0 and 1 and satisfies the properties: F is an abelian group under addition, meaning - F is closed under
More informationChapter. Algebra techniques. Syllabus Content A Basic Mathematics 10% Basic algebraic techniques and the solution of equations.
Chapter 2 Algebra techniques Syllabus Content A Basic Mathematics 10% Basic algebraic techniques and the solution of equations. Page 1 2.1 What is algebra? In order to extend the usefulness of mathematical
More informationOutput-sensitive algorithms for sumset and sparse polynomial multiplication
Output-sensitive algorithms for sumset and sparse polynomial multiplication Andrew Arnold Cheriton School of Computer Science University of Waterloo Waterloo, Ontario, Canada Daniel S. Roche Computer Science
More informationFast Convolution; Strassen s Method
Fast Convolution; Strassen s Method 1 Fast Convolution reduction to subquadratic time polynomial evaluation at complex roots of unity interpolation via evaluation at complex roots of unity 2 The Master
More informationBetween Sparse and Dense Arithmetic
Between Sparse and Dense Arithmetic Daniel S. Roche Computer Science Department United States Naval Academy NARC Seminar November 28, 2012 The Problem People want to compute with really big numbers and
More informationAlgorithms and Data Structures
Charles A. Wuethrich Bauhaus-University Weimar - CogVis/MMC June 1, 2017 1/44 Space reduction mechanisms Range searching Elementary Algorithms (2D) Raster Methods Shell sort Divide and conquer Quicksort
More informationTenth Bit Bank Mathematics Real Numbers
Tenth Bit Bank Mathematics Real Numbers 1. The rational number among the following is... i) 4.28 ii) 4.282828... iii) 4.288888... A) i) & ii) B) ii) & iii) C) i) & iii) D) All the above 2. A rational number
More information3 The fundamentals: Algorithms, the integers, and matrices
3 The fundamentals: Algorithms, the integers, and matrices 3.4 The integers and division This section introduces the basics of number theory number theory is the part of mathematics involving integers
More information3x + 1 (mod 5) x + 2 (mod 5)
Today. Secret Sharing. Polynomials Polynomials. Secret Sharing. Share secret among n people. Secrecy: Any k 1 knows nothing. Roubustness: Any k knows secret. Efficient: minimize storage. A polynomial P(x)
More informationFinal Review Accelerated Advanced Algebra
Name: ate: 1. What are the factors of z + z 2 + 25z + 25? 5. Factor completely: (7x + 2) 2 6 (z + 1)(z + 5)(z 5) (z 1)(z + 5i) 2 (49x + 1)(x 8) (7x 4)(7x + 8) (7x + 4)(7x 8) (7x + 4)(x 9) (z 1)(z + 5i)(z
More informationExact Arithmetic on a Computer
Exact Arithmetic on a Computer Symbolic Computation and Computer Algebra William J. Turner Department of Mathematics & Computer Science Wabash College Crawfordsville, IN 47933 Tuesday 21 September 2010
More informationCMPT 307 : Divide-and-Conqer (Study Guide) Should be read in conjunction with the text June 2, 2015
CMPT 307 : Divide-and-Conqer (Study Guide) Should be read in conjunction with the text June 2, 2015 1 Introduction The divide-and-conquer strategy is a general paradigm for algorithm design. This strategy
More informationImplementation of the DKSS Algorithm for Multiplication of Large Numbers
Implementation of the DKSS Algorithm for Multiplication of Large Numbers Christoph Lüders Universität Bonn Institut für Informatik Bonn, Germany chris@cfos.de ABSTRACT The Schönhage-Strassen algorithm
More informationDesign and Analysis of Algorithms
CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 4: Divide and Conquer (I) Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ Divide and Conquer ( DQ ) First paradigm or framework DQ(S)
More informationRemainders. We learned how to multiply and divide in elementary
Remainders We learned how to multiply and divide in elementary school. As adults we perform division mostly by pressing the key on a calculator. This key supplies the quotient. In numerical analysis and
More informationax b mod m. has a solution if and only if d b. In this case, there is one solution, call it x 0, to the equation and there are d solutions x m d
10. Linear congruences In general we are going to be interested in the problem of solving polynomial equations modulo an integer m. Following Gauss, we can work in the ring Z m and find all solutions to
More informationCopyright 2000, Kevin Wayne 1
Divide-and-Conquer Chapter 5 Divide and Conquer Divide-and-conquer. Break up problem into several parts. Solve each part recursively. Combine solutions to sub-problems into overall solution. Most common
More information7.3 Singular points and the method of Frobenius
284 CHAPTER 7. POWER SERIES METHODS 7.3 Singular points and the method of Frobenius Note: or.5 lectures, 8.4 and 8.5 in [EP], 5.4 5.7 in [BD] While behaviour of ODEs at singular points is more complicated,
More informationcompare to comparison and pointer based sorting, binary trees
Admin Hashing Dictionaries Model Operations. makeset, insert, delete, find keys are integers in M = {1,..., m} (so assume machine word size, or unit time, is log m) can store in array of size M using power:
More information6.S897 Algebra and Computation February 27, Lecture 6
6.S897 Algebra and Computation February 7, 01 Lecture 6 Lecturer: Madhu Sudan Scribe: Mohmammad Bavarian 1 Overview Last lecture we saw how to use FFT to multiply f, g R[x] in nearly linear time. We also
More informationPermutations and Polynomials Sarah Kitchen February 7, 2006
Permutations and Polynomials Sarah Kitchen February 7, 2006 Suppose you are given the equations x + y + z = a and 1 x + 1 y + 1 z = 1 a, and are asked to prove that one of x,y, and z is equal to a. We
More informationCopyright 2000, Kevin Wayne 1
//8 Fast Integer Division Too (!) Schönhage Strassen algorithm CS 8: Algorithm Design and Analysis Integer division. Given two n-bit (or less) integers s and t, compute quotient q = s / t and remainder
More informationAlgebra. Mathematics Help Sheet. The University of Sydney Business School
Algebra Mathematics Help Sheet The University of Sydney Business School Introduction Terminology and Definitions Integer Constant Variable Co-efficient A whole number, as opposed to a fraction or a decimal,
More informationTropical Polynomials
1 Tropical Arithmetic Tropical Polynomials Los Angeles Math Circle, May 15, 2016 Bryant Mathews, Azusa Pacific University In tropical arithmetic, we define new addition and multiplication operations on
More informationCSE 421. Dynamic Programming Shortest Paths with Negative Weights Yin Tat Lee
CSE 421 Dynamic Programming Shortest Paths with Negative Weights Yin Tat Lee 1 Shortest Paths with Neg Edge Weights Given a weighted directed graph G = V, E and a source vertex s, where the weight of edge
More informationSMT BASICS WS 2017/2018 ( ) LOGIC SATISFIABILITY MODULO THEORIES. Institute for Formal Models and Verification Johannes Kepler Universität Linz
LOGIC SATISFIABILITY MODULO THEORIES SMT BASICS WS 2017/2018 (342.208) Armin Biere Martina Seidl biere@jku.at martina.seidl@jku.at Institute for Formal Models and Verification Johannes Kepler Universität
More informationCS 580: Algorithm Design and Analysis
CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 208 Announcement: Homework 3 due February 5 th at :59PM Final Exam (Tentative): Thursday, May 3 @ 8AM (PHYS 203) Recap: Divide
More informationDIVIDE AND CONQUER II
DIVIDE AND CONQUER II master theorem integer multiplication matrix multiplication convolution and FFT Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos
More informationMath Lecture 18 Notes
Math 1010 - Lecture 18 Notes Dylan Zwick Fall 2009 In our last lecture we talked about how we can add, subtract, and multiply polynomials, and we figured out that, basically, if you can add, subtract,
More informationAlgorithms. Shanks square forms algorithm Williams p+1 Quadratic Sieve Dixon s Random Squares Algorithm
Alex Sundling Algorithms Shanks square forms algorithm Williams p+1 Quadratic Sieve Dixon s Random Squares Algorithm Shanks Square Forms Created by Daniel Shanks as an improvement on Fermat s factorization
More informationSchönhage-Strassen Algorithm with MapReduce for Multiplying Terabit Integers (April 29, 2011)
Schönhage-Strassen Algorithm with MapReduce for Multiplying Terabit Integers (April 29, 2011) Tsz-Wo Sze Yahoo! Cloud Platform 701 First Avenue Sunnyvale, CA 94089, USA tsz@yahoo-inc.com ABSTRACT We present
More informationCS 310 Advanced Data Structures and Algorithms
CS 310 Advanced Data Structures and Algorithms Runtime Analysis May 31, 2017 Tong Wang UMass Boston CS 310 May 31, 2017 1 / 37 Topics Weiss chapter 5 What is algorithm analysis Big O, big, big notations
More informationarxiv: v1 [cs.na] 8 Feb 2016
Toom-Coo Multiplication: Some Theoretical and Practical Aspects arxiv:1602.02740v1 [cs.na] 8 Feb 2016 M.J. Kronenburg Abstract Toom-Coo multiprecision multiplication is a well-nown multiprecision multiplication
More informationCS/COE 1501 cs.pitt.edu/~bill/1501/ Integer Multiplication
CS/COE 1501 cs.pitt.edu/~bill/1501/ Integer Multiplication Integer multiplication Say we have 5 baskets with 8 apples in each How do we determine how many apples we have? Count them all? That would take
More informationFast reversion of power series
Fast reversion of power series Fredrik Johansson November 2011 Overview Fast power series arithmetic Fast composition and reversion (Brent and Kung, 1978) A new algorithm for reversion Implementation results
More information1: Please compute the Jacobi symbol ( 99
SCORE/xx: Math 470 Communications Cryptography NAME: PRACTICE FINAL Please show your work write only in pen. Notes are forbidden. Calculators, all other electronic devices, are forbidden. Brains are encouraged,
More informationChapter 1 Divide and Conquer Algorithm Theory WS 2016/17 Fabian Kuhn
Chapter 1 Divide and Conquer Algorithm Theory WS 2016/17 Fabian Kuhn Formulation of the D&C principle Divide-and-conquer method for solving a problem instance of size n: 1. Divide n c: Solve the problem
More information