Output-sensitive algorithms for sumset and sparse polynomial - - PowerPoint PPT Presentation

output sensitive algorithms for sumset and sparse
SMART_READER_LITE
LIVE PREVIEW

Output-sensitive algorithms for sumset and sparse polynomial - - PowerPoint PPT Presentation

Sparsity and Arithmetic Informative Example Consequences and Conclusions Output-sensitive algorithms for sumset and sparse polynomial multiplication Daniel S. Roche Andrew Arnold Cheriton School of Computer Science Computer Science


slide-1
SLIDE 1

Sparsity and Arithmetic Informative Example Consequences and Conclusions

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 Department United States Naval Academy Annapolis, Maryland, USA

ISSAC 2015 Bath, UK July 8, 2014

slide-2
SLIDE 2

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Our Result We can multiply any polynomial (sparse or dense) in linear time in the size of the input.*

*This statement is false.

slide-3
SLIDE 3

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Our Result We can multiply any polynomial (sparse or dense) in linear time in the sizes of the input and output.*

*This statement is false.

slide-4
SLIDE 4

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Our Result We can multiply any polynomial (sparse or dense) in softly-linear time in the sizes of the input and output.*

Note: O˜(φ) means O

  • φ logO(1) φ
  • .

*This statement is false.

slide-5
SLIDE 5

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Our Result We can multiply any polynomial (sparse or dense) in softly-linear time in the “structural” sizes of the input and output.

Note: O˜(φ) means O

  • φ logO(1) φ
  • .
slide-6
SLIDE 6

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Dense multiplication

How to multiply? 65x3 + 20x2 + 26x + 16 × 60x2 + 78x − 48

slide-7
SLIDE 7

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Dense multiplication

How to multiply? 65x3 + 20x2 + 26x + 16 60x2 + 78x − 48 =

3900x5+6270x4+2028x2−768

Direct “school” method. Quadratic complexity.

slide-8
SLIDE 8

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Dense multiplication

How to multiply? 65x3 + 20x2 + 26x + 16 60x2 + 78x − 48 =

3900x5+6270x4+2028x2−768

65002000260016 × 6000779952 =

390062700000202799999232

Direct “school” method. Quadratic complexity. Indirect method, using FFT. Softly-linear complexity.

slide-9
SLIDE 9

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Sparse Multiplication

How to multiply? 65x31y36 + 20x13y49 + 26x38y12 + 16x20y25 × 60x16y43 + 78x41y6 − 48x23y19

slide-10
SLIDE 10

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Sparse Multiplication

How to multiply? 65x31y36 + 20x13y49 + 26x38y12 + 16x20y25 60x16y43 + 78x41y6 − 48x23y19

Direct “school” method. Quadratic complexity

slide-11
SLIDE 11

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Sparse Multiplication

How to multiply? 65x31y36 + 20x13y49 + 26x38y12 + 16x20y25 60x16y43 + 78x41y6 − 48x23y19

Direct “school” method. Quadratic complexity Geobuckets (Yan ’98)

slide-12
SLIDE 12

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Sparse Multiplication

How to multiply? 65x31y36 + 20x13y49 + 26x38y12 + 16x20y25 60x16y43 + 78x41y6 − 48x23y19

Direct “school” method. Quadratic complexity Geobuckets (Yan ’98) Heaps (Johnson ’74, Monagan & Pearce ’07. . . )

slide-13
SLIDE 13

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Output-Sensitive Sparse Multiplication

Quadratic-time already defeated in many cases: Recursive dense Chunky, equal spaced (R. ’11) Blockwise dense (van der Hoeven & Lecerf ’12) Homogeneous dense (Gastineau & Laskar ’13) Support on a lattice (van der Hoeven, Lebreton, Schost ’13) Support is given (van der Hoeven & Lecerf ’13)

slide-14
SLIDE 14

Sparsity and Arithmetic Informative Example Consequences and Conclusions

What about sparse intepolation?

Idea: Evaluate at T ≫ #(fg) points, multiply, interpolate the product

slide-15
SLIDE 15

Sparsity and Arithmetic Informative Example Consequences and Conclusions

What about sparse intepolation?

Idea: Evaluate at T ≫ #(fg) points, multiply, interpolate the product

“Big prime” algorithms

Computation is performed modulo p, p ≫ deg(fg). But one evaluation needs O˜(T log deg(fg)) ops modulo p; hence at least O˜(T log2 deg(fg)) bit complexity

slide-16
SLIDE 16

Sparsity and Arithmetic Informative Example Consequences and Conclusions

What about sparse intepolation?

Idea: Evaluate at T ≫ #(fg) points, multiply, interpolate the product

“Big prime” algorithms

Computation is performed modulo p, p ≫ deg(fg). But one evaluation needs O˜(T log deg(fg)) ops modulo p; hence at least O˜(T log2 deg(fg)) bit complexity

“Small primes” algorithms

Computations performed modulo small primes p. But all algorithms still need O˜(T log2 deg(fg)) operations. Observe: The trouble is in the degree!

slide-17
SLIDE 17

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Two kinds of sparsity

Consider the following sparse addition problem:

+

slide-18
SLIDE 18

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Two kinds of sparsity

Consider the following sparse addition problem:

+ =

Structural sparsity is 7.

slide-19
SLIDE 19

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Two kinds of sparsity

Consider the following sparse addition problem:

−2 5 −5 −3 8 1 + 6 −5 −2 3 7 = 4 −5 −2 8 8

Structural sparsity is 7. Arithmetic sparsity is 5.

slide-20
SLIDE 20

Sparsity and Arithmetic Informative Example Consequences and Conclusions

What to notice

2 Building Blocks

Dense polynomial arithmetic Sparse polynomial interpolation

slide-21
SLIDE 21

Sparsity and Arithmetic Informative Example Consequences and Conclusions

What to notice

2 Building Blocks

Dense polynomial arithmetic Sparse polynomial interpolation

2 Techniques

Multiple reduction and relaxation Coefficient ratios without derivatives

slide-22
SLIDE 22

Sparsity and Arithmetic Informative Example Consequences and Conclusions

What to notice

2 Building Blocks

Dense polynomial arithmetic Sparse polynomial interpolation

2 Techniques

Multiple reduction and relaxation Coefficient ratios without derivatives

2 Useful Subroutines

Computing sumset Sparse interpolation with known support

slide-23
SLIDE 23

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Running Example

The Problem f = 65x31y36 + 20x13y49 + 26x38y12 + 16x20y25 g = 60x16y43 + 78x41y6 − 48x23y19

What is the product h = fg?

slide-24
SLIDE 24

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Running Example

The Problem f = 65x31y36 + 20x13y49 + 26x38y12 + 16x20y25 g = 60x16y43 + 78x41y6 − 48x23y19

What is the product h = fg?

Overview of approach

1 Estimate structural sparsity 2 Compute structural support 3 Compute arithmetic support (i.e., the actual exponents) 4 Compute the coefficients

slide-25
SLIDE 25

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 0: Substitutions

Given f = 65x31y36 + 20x13y49 + 26x38y12 + 16x20y25 g = 60x16y43 + 78x41y6 − 48x23y19 Kronecker Substitution fK = f(z, z100) = 20z4913 + 65z3631 + 16z2520 + 26z1238 gK = g(z, z100) = 60z4316 − 48z1923 + 78z641

Note: h completely determined from fKgK.

slide-26
SLIDE 26

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 0: Substitutions

Given f = 65x31y36 + 20x13y49 + 26x38y12 + 16x20y25 g = 60x16y43 + 78x41y6 − 48x23y19 Kronecker Substitution fK = f(z, z100) = 20z4913 + 65z3631 + 16z2520 + 26z1238 gK = g(z, z100) = 60z4316 − 48z1923 + 78z641

Note: h completely determined from fKgK.

Coefficient removal fS = z4913 + z3631 + z2520 + z1238 gS = z4316 + z1923 + z641

Note: structural support of h determined from fSgS.

slide-27
SLIDE 27

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 1: Estimate structural sparsity

Given fS = z4913 + z3631 + z2520 + z1238 gS = z4316 + z1923 + z641

How sparse is the product hS = fS · gS?

1 Choose primes

p = 211, p′ = 5

2 Compute

  • (fS · gS) mod p mod p′

= 2z4 + 3z3 + 3z2 + 2z + 2

3 Less than half-dense? No

slide-28
SLIDE 28

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 1: Estimate structural sparsity

Given fS = z4913 + z3631 + z2520 + z1238 gS = z4316 + z1923 + z641

How sparse is the product hS = fS · gS?

1 Choose primes

p = 211, p′ = 11

2 Compute

  • (fS · gS) mod p mod p′

= 3z9 + 2z8 + z7 + 2z4 + z3 + 3z2

3 Less than half-dense? No

slide-29
SLIDE 29

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 1: Estimate structural sparsity

Given fS = z4913 + z3631 + z2520 + z1238 gS = z4316 + z1923 + z641

How sparse is the product hS = fS · gS?

1 Choose primes

p = 211, p′ = 17

2 Compute

  • (fS · gS) mod p mod p′

= z16 + z7 + z6 + 2z4 + 3z3 + z2 + z + 2

3 Less than half-dense? Yes

Means structural sparsity is close to 8.

slide-30
SLIDE 30

Sparsity and Arithmetic Informative Example Consequences and Conclusions

First technique: Multiple Reduction and Relaxation

fS = z4913 + z3631 + z2520 + z1238 f mod 211

S

= z199 + z183 + z60 + z44

  • f mod 211

S

mod 17 = z13 + z12 + z10 + z9

What’s going on? First reduce exponents modulo p Now treat that as an ordinary polynomial Then reduce further! Each reduction introduces a factor-2 in the error estimation.

slide-31
SLIDE 31

Sparsity and Arithmetic Informative Example Consequences and Conclusions

First building block

How to compute

  • (fS · gS) mod p mod p′

? This polynomial never gets very sparse Its degree is linear in the actual structural sparsity

slide-32
SLIDE 32

Sparsity and Arithmetic Informative Example Consequences and Conclusions

First building block

How to compute

  • (fS · gS) mod p mod p′

? This polynomial never gets very sparse Its degree is linear in the actual structural sparsity So we can use dense polynomial arithmetic! Papers: (Karatsuba ’58), (Toom & Cook ’63), (Sch¨

  • nhage &

Strassen ’71), (Cantor & Kaltofen ’91), (F¨ urer ’07), (DKSS ’08), . . . Software: GMP , NTL, FLINT, Singular, Maple,. . .

slide-33
SLIDE 33

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 2: Compute structural support

Given fS = z4913 + z3631 + z2520 + z1238 gS = z4316 + z1923 + z641 #(fS · gS) ≈ 8

What are the exponents of hS = fS · gS? Use the same prime p = 211 as before. Compute h1 =

  • f mod p

S

· g mod p

S

mod p = 2z207 + z191 + z156 + z140 + 2z84 + 3z68 + z52 + z12

slide-34
SLIDE 34

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 2: Compute structural support

Given fS = z4913 + z3631 + z2520 + z1238 gS = z4316 + z1923 + z641 #(fS · gS) ≈ 8

What are the exponents of hS = fS · gS? Use the same prime p = 211 as before. Set ℓ ≫ deg(h) = 16000 Compute f2 = (eℓ + 1)ze mod p

= (4913·16000+1)z4913 mod 211+(3631·16000+1)z3631 mod 211+· · · = 40320001z199 + 19808001z183 + 78608001z60 + 58096001z44

Compute g2 similarly. Compute h2 = (f2 · g2) mod p mod ℓ2

= 101152002z207 + 30064001z191 + 147664001z156 + 127152001z140 + 218752002z84 + 266592003z68 + 68352001z52 + 71088001z12

slide-35
SLIDE 35

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 2: Compute structural support

Given fS = z4913 + z3631 + z2520 + z1238 gS = z4316 + z1923 + z641 #(fS · gS) ≈ 8

What are the exponents of hS = fS · gS?

p = 211,

, ℓ = 16000

h1 = 2z207 + z191 + z156 + z140 + 2z84 + 3z68 + z52 + z12 h2 = 101152002z207 + · · · + 68352001z52 + · · ·

Take coefficient ratios:

c2 c1 − 1

Structural support:

1879, 3161, 4272, 4443, 5554, 6836, 7947, 9229

slide-36
SLIDE 36

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Did you notice the first technique again?

slide-37
SLIDE 37

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Did you notice the first technique again?

(f2 · g2) mod p mod ℓ2

Multiple levels of reduction/relaxation here!

slide-38
SLIDE 38

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Second technique: Coefficient ratios

The polynomials f2, g2, h2 have their exponents encoded in the coefficients. The encoding is additive modulo ℓ2:

(aℓ + 1)(bℓ + 1) mod ℓ2 = (a + b)ℓ + 1

Allows recovering the actual exponents from the coefficients of the degree-reduced product.

slide-39
SLIDE 39

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Second building block

How to compute h2 = f2 · g2? This polynomial is kind of sparse. It has huge coefficients!

slide-40
SLIDE 40

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Second building block

How to compute h2 = f2 · g2? This polynomial is kind of sparse. It has huge coefficients! We can use sparse polynomial interpolation! Requirement: Linear-time in the sparsity bound, poly-logarithmic in the degree. Papers: (Prony ’95), (Blahut ’79), (Ben-Or & Tiwari ’88), (Kaltofen ’10), (Kaltofen & Lee ’03), (A., Giesbrecht, Roche ’14), . . . Software: Mathemagix, Maple (maybe), ???

slide-41
SLIDE 41

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 3: Trim down to the arithmetic support

Given fK = f(z, z100) = 20z4913 + 65z3631 + 16z2520 + 26z1238 gK = g(z, z100) = 60z4316 − 48z1923 + 78z641 supp(fK · gK) ⊆ S = {1879, 3161, 4272, 4443, 5554, 6836, 7947, 9229}

What are the actual exponents of fK · gK?

1 Choose

p = 23, q = 47

(note p|(q − 1))

2 Compute S mod p = {16, 10, 17, 4, 11, 5, 12, 6} 3 Compute hp,q = (fK · gK) mod p mod q

= 41z17 + 7z16 + 46z12 + 25z6 + 31z4

slide-42
SLIDE 42

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 3: Trim down to the arithmetic support

Given fK = f(z, z100) = 20z4913 + 65z3631 + 16z2520 + 26z1238 gK = g(z, z100) = 60z4316 − 48z1923 + 78z641 supp(fK · gK) ⊆ S = {1879, 3161, 4272, 4443, 5554, 6836, 7947, 9229}

What are the actual exponents of fK · gK?

1 Choose

p = 23, q = 47

(note p|(q − 1))

2 Compute S mod p = {16, 10, 17, 4, 11, 5, 12, 6} 3 Compute hp,q = (fK · gK) mod p mod q

= 41z17 + 7z16 + 46z12 + 25z6 + 31z4

4 Identify support from nonzero terms

slide-43
SLIDE 43

Sparsity and Arithmetic Informative Example Consequences and Conclusions

(Of course you saw the first technique again.)

(fK · gK) mod p mod q

slide-44
SLIDE 44

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Twist on second building block

How to compute (fK · gK) mod p mod q? This polynomial is kind of sparse. An advantage: this time we know the support!

slide-45
SLIDE 45

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Twist on second building block

How to compute (fK · gK) mod p mod q? This polynomial is kind of sparse. An advantage: this time we know the support! Use the coefficient-finding step of sparse interpolation! Because p|(q − 1), we can evaluate at pth roots of unity and solve a transposed Vandermonde system. Papers: (Kaltofen & Lakshman ’89), (van der Hoeven & Lecerf ’13)

slide-46
SLIDE 46

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 4: Compute the coefficients

Given fK = f(z, z100) = 20z4913 + 65z3631 + 16z2520 + 26z1238 gK = g(z, z100) = 60z4316 − 48z1923 + 78z641 supp(fK · gK) = S′ = {1879, 4272, 4443, 7947, 9229}

What are the coefficients of fK · gK?

1 Choose

p = 11, q = 23

(note p|(q − 1))

2 Compute S′ mod p = {9, 4, 10, 5, 0} 3 Compute hp,q = (fK · gK) mod p mod q

= 14z10 + 4z9 + 13z5 + 10z4 + 4

4 Group like terms for Chinese Remaindering

slide-47
SLIDE 47

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 4: Compute the coefficients

Given fK = f(z, z100) = 20z4913 + 65z3631 + 16z2520 + 26z1238 gK = g(z, z100) = 60z4316 − 48z1923 + 78z641 supp(fK · gK) = S′ = {1879, 4272, 4443, 7947, 9229}

What are the coefficients of fK · gK?

1 Choose

p = 11, q = 67

(note p|(q − 1))

2 Compute S′ mod p = {9, 4, 10, 5, 0} 3 Compute hp,q = (fK · gK) mod p mod q

= 36z10 + 18z9 + 14z5 + 45z4 + 61

4 Group like terms for Chinese Remaindering

slide-48
SLIDE 48

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 4: Compute the coefficients

Given fK = f(z, z100) = 20z4913 + 65z3631 + 16z2520 + 26z1238 gK = g(z, z100) = 60z4316 − 48z1923 + 78z641 supp(fK · gK) = S′ = {1879, 4272, 4443, 7947, 9229}

What are the coefficients of fK · gK?

1 Choose

p = 11, q = 89

(note p|(q − 1))

2 Compute S′ mod p = {9, 4, 10, 5, 0} 3 Compute hp,q = (fK · gK) mod p mod q

= 33z10 + 70z9 + 73z5 + 86z4 + 43

4 Group like terms for Chinese Remaindering

slide-49
SLIDE 49

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Step 4: Compute the coefficients

Given fK = f(z, z100) = 20z4913 + 65z3631 + 16z2520 + 26z1238 gK = g(z, z100) = 60z4316 − 48z1923 + 78z641 supp(fK · gK) = S′ = {1879, 4272, 4443, 7947, 9229}

What are the coefficients of fK · gK?

1 Choose

p = 11, q = 23, 67, 89

2 Compute S′ mod p = {9, 4, 10, 5, 0} 3 Compute hp,q = (fK · gK) mod p mod q 5 Apply CRT and undo the Kronecker map:

h = 3900x47y79+1200x29y92+5070x72y42+2028x79y18−768x43y44

slide-50
SLIDE 50

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Complexity Overview

Non-toy example

1000 terms, 8 variables, 64-bit coefficients , 32-bit exponents Structural sparsity 10000, arithmetic sparsity 1000

slide-51
SLIDE 51

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Complexity Overview

Non-toy example

1000 terms, 8 variables, 64-bit coefficients , 32-bit exponents Structural sparsity 10000, arithmetic sparsity 1000 Steps of the algorithm

1 Estimate structural sparsity

slide-52
SLIDE 52

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Complexity Overview

Non-toy example

1000 terms, 8 variables, 64-bit coefficients , 32-bit exponents Structural sparsity 10000, arithmetic sparsity 1000 Steps of the algorithm

1 Estimate structural sparsity 2 Compute structural support

slide-53
SLIDE 53

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Complexity Overview

Non-toy example

1000 terms, 8 variables, 64-bit coefficients , 32-bit exponents Structural sparsity 10000, arithmetic sparsity 1000 Steps of the algorithm

1 Estimate structural sparsity 2 Compute structural support 3 Trim to arithmetic support

slide-54
SLIDE 54

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Complexity Overview

Non-toy example

1000 terms, 8 variables, 64-bit coefficients , 32-bit exponents Structural sparsity 10000, arithmetic sparsity 1000 Steps of the algorithm

1 Estimate structural sparsity 2 Compute structural support 3 Trim to arithmetic support 4 Compute coefficients

slide-55
SLIDE 55

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Summary

C = |largest coefficient| D = max degree S = structural sparsity T = arithmetic sparsity

Theorem

Given f, g ∈ Z[x], our Monte Carlo algorithm computes h = fg with

O˜(S log C + T log D) bit complexity.

Extends to softly-linear time algorithms for Multivariate polynomials Laurent polynomials Modular rings, finite fields, exact rationals

slide-56
SLIDE 56

Sparsity and Arithmetic Informative Example Consequences and Conclusions

Two useful subroutines

Sumset

Given sets A, B ⊂ Z, compute

S = {a + b|a ∈ A, b ∈ B}. Sparse multiplication with known support

Given f, g ∈ Z[x] and the exponents of f · g, compute the coefficients of f · g. We provide softly linear-time solutions to both problems. (They correspond to steps 1-2 and steps 3-4, resp.)

slide-57
SLIDE 57

Sparsity and Arithmetic Informative Example Consequences and Conclusions

What’s left to do? (Lots!)

Make an efficient (parallel) implementation Decrease randomness (Las Vegas? Deterministic?) Make cost dependent on arithmetic sparsity Start worrying about the log factors Apply improvements to other problems (division, interpolation, . . . )