algebraic algorithms

21
Algebraic Algorithms

Upload: terri

Post on 23-Feb-2016

51 views

Category:

Documents


0 download

DESCRIPTION

Algebraic Algorithms. Definition. Combinatorial methods : Tries to construct the object explicitly piece-by-piece . Algebraic methods : Implicitly sieves for the object by evaluating a sum . The 4cycle Detection Problem. 4cycle detection. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Algebraic Algorithms

Algebraic Algorithms

Page 2: Algebraic Algorithms

Definition

Combinatorial methods: Tries to construct the object explicitly piece-by-piece.

Algebraic methods: Implicitly sieves for the object by evaluating a sum.

Page 3: Algebraic Algorithms

The 4cycle Detection Problem

Page 4: Algebraic Algorithms

4cycle detection

1. Init a boolean nxn table T(:,:)=false.2. For each vertex v3. For each pair of neighbors u,w of v4. If T(u,w) then return true and

stop5. T(u,w)=true6. End7. End8. Return false

Page 5: Algebraic Algorithms

The Triangle Detection Problem

Page 6: Algebraic Algorithms

Square Matrix MultiplicationWhat is the computational

complexity in terms of number of scalar operations (*,+) of computing the product of two nxn-matrices A and B?

From definition Cij=Sk AikBkj we get O(n3) time.

There is a (highly theoretical) O(n2.373) time algorithm!

Page 7: Algebraic Algorithms

Strassen’s algorithm

A1,1 A1,2

A2,1 A2,2

⎡ ⎣ ⎢

⎤ ⎦ ⎥B1,1 B1,2

B2,1 B2,2

⎡ ⎣ ⎢

⎤ ⎦ ⎥=C1,1 = A1,1B1,1 + A1,2B2,1 C1,2 = A1,1B1,2 + A1,2B2,2

C2,1 = A2,1B1,1 + A2,2B2,1 C2,2 = A2,1B1,2 + A2,2B2,2

⎡ ⎣ ⎢

⎤ ⎦ ⎥

M1 = (A1,1 + A2,2)(B1,1 + B2,2)

M2 = (A2,1 + A2,2)B1,1

M3 = A1,1(B1,2 − B2,2)

M4 = A2,2(B2,1 − B1,1)

M5 = (A1,1 + A1,2)B2,2

M6 = (A2,1 − A1,1)(B1,1 + B1,2)

M7 = (A1,2 − A2,2)(B2,1 + B2,2)

C1,1 = M1 +M4 −M5 +M7

C1,2 = M3 +M5

C2,1 = M2 +M4

C2,2 = M1 −M2 +M3 +M6

Page 8: Algebraic Algorithms

Strassen’s algorithm

T(n)=cn2+7T(n/2)=cn2+7c(n/2)2+72T(n/4)=

cn2+7c(n/2)2+72c(n/4)2+73T(n/8)=…=

cn2(1+7/4+(7/4)2+…+(7/4)log2(n))+7log2(n)=

O(nlog2(7))=O(n2.81).

Page 9: Algebraic Algorithms

Verifying Matrix ProductsGiven three nxn matrices A,B, and C

you want to verify that AB=C.Can you do this faster than

recomputing the matrix product?

Page 10: Algebraic Algorithms

Verifying Matrix Products Idea: Project the difference matrix on

a randomly chosen 0/1-vector r. If (AB-C)r=A(Br)-Cr=0, we conclude

that AB=C, otherwise we deem them different.

No false negatives.False positives with probability

<=1/2.

Note that this is an O(n2) time algorithm!

Page 11: Algebraic Algorithms

Verifying Matrix Products

(AB-C)= r=

e1e2 e3 e4r1r2

r3

r4

Pr( eiri = 0) ≤12i=1

4

Page 12: Algebraic Algorithms

Polynomial Identity TestingGiven ”black box” multivariate

polynomial P, is P identically zero or not?

Think of polynomial P as given by arithmetic circuit:

x

+

x xx

+ + + + + +

x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14

+ +

Page 13: Algebraic Algorithms

The Schwartz Zippel LemmaSchwartz-Zippel Lemma: Let P(x1,x2,

…,xn) be a multivariate non-zero polynomial of total degree d over a finite field F. For uniformly and independently sampled values r1,r2,…,rn in F:

Pr[P(r1,r2,...,rn ) = 0] ≤dF

Page 14: Algebraic Algorithms

Bipartite Matching

Pick as many end-point disjoint edges as possible.

Page 15: Algebraic Algorithms

Bipartite Matching: Augmentation paths

Classic matching algorithm:Use dfs to find augmentation paths.

Page 16: Algebraic Algorithms

Bipartite Matching: Biadjacency matrix

1 0 1 0 00 1 1 0 01 0 0 0 10 1 0 1 00 0 0 1 1

⎢ ⎢ ⎢ ⎢ ⎢ ⎢

⎥ ⎥ ⎥ ⎥ ⎥ ⎥

1

2

3

4

5

A

B

C

D

E

1

2

3

4

5

A B C D E

Page 17: Algebraic Algorithms

Determinants

1 0 1 0 00 1 1 0 01 0 0 0 10 1 0 1 00 0 0 1 1

⎢ ⎢ ⎢ ⎢ ⎢ ⎢

⎥ ⎥ ⎥ ⎥ ⎥ ⎥

1

2

3

4

5

A B C D E

det(A) = sgn(σ ) Ai,σ (i)i=1

n

∏σ :[n ]→[n ]one−to−one

In fields of characteristic two:

det(A) = Ai,σ ( i)i=1

n

∏σ :[n ]→[n ]one−to−one

Page 18: Algebraic Algorithms

Fields of characteristic two

+ 0 1 A B0 0 1 A B1 1 0 B AA A B 0 1B B A 1 0

* 0 1 A B0 0 0 0 01 0 1 A BA 0 A B 1B 0 B 1 A

F4

Page 19: Algebraic Algorithms

Determinants with indeterminates

x1A 0 x1C 0 00 x2B x2C 0 0x3A 0 0 0 x3E

0 x4B 0 x4D 00 0 0 x5D x5E

⎢ ⎢ ⎢ ⎢ ⎢ ⎢

⎥ ⎥ ⎥ ⎥ ⎥ ⎥

1

2

3

4

5

A B C D E

det(A) = Ai,σ ( i)i=1

n

∏σ :[n ]→[n ]one−to−one

det(A) = x i,σ (i)i=1

n

∏Matchingsσ :[1..5]→[A ..E ]

Page 20: Algebraic Algorithms

Algorithm

r1A 0 r1C 0 00 r2B r2C 0 0r3A 0 0 0 r3E0 r4B 0 r4D 00 0 0 r5D r5E

⎢ ⎢ ⎢ ⎢ ⎢ ⎢

⎥ ⎥ ⎥ ⎥ ⎥ ⎥

1

2

3

4

5

A B C D E1. Replace indeterminates by random values xij=rij.2. Compute the determinant.3. If it is non-zero return Yes otherwise No.

Page 21: Algebraic Algorithms

General Matchings

0 x12 0 0 x15 0x12 0 x23 x24 0 x26

0 x23 0 x34 x35 x36

0 x24 x34 0 0 x46

x15 0 x35 0 0 00 x26 x36 x46 0 0

⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢

⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥

1

2

3

4

5

1 2 3 4 5 6

6

12

3 4

5 6