Continued Logarithm Algorithm. A probabilistic study

76
Continued Logarithm Algorithm. A probabilistic study Pablo Rotondo IRIF, Paris 7 Diderot, Universidad de la Rep´ ublica, Uruguay GREYC, associate Work with Brigitte Vall´ ee and Alfredo Viola 13 31 = 2 -1 1+ 2 -2 1+ 2 -1 1+ 2 0 1+ 2 -1 1 eminaire ALGO, Caen, 20 Februrary, 2018.

Transcript of Continued Logarithm Algorithm. A probabilistic study

Page 1: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm Algorithm.A probabilistic study

Pablo RotondoIRIF, Paris 7 Diderot,

Universidad de la Republica, Uruguay

GREYC, associate

Work with

Brigitte Vallee and Alfredo Viola

1331 =

2−1

1 +2−2

1 +2−1

1 +20

1 +2−1

1

Seminaire ALGO, Caen, 20 Februrary, 2018.

Page 2: Continued Logarithm Algorithm. A probabilistic study

Table of Contents

Introduction

The CL Dynamical system

Extended system and results

Conclusions and extensions

Page 3: Continued Logarithm Algorithm. A probabilistic study

The origins

In Hakmem Gosper writes

“There is a mutation of continued fractions, which I call continuedlogarithms, which have several advantages over regular continuedfractions, especially for computational hardware.

(. . .) The primary advantage is the conveniently small information parcel.

(. . .) the continued logarithm of Avogadro’s number begins with itsbinary order of magnitude, and only then begins the descriptionequivalent to the leading digits – a sort of recursive version of scientificnotation.”

The continued logarithm algorithm computes the odd gcd and

I involves quotients that are powers of 2.

I seems simple and efficient.

I let us see an example!

Page 4: Continued Logarithm Algorithm. A probabilistic study

The origins

In Hakmem Gosper writes

“There is a mutation of continued fractions, which I call continuedlogarithms, which have several advantages over regular continuedfractions, especially for computational hardware.

(. . .) The primary advantage is the conveniently small information parcel.

(. . .) the continued logarithm of Avogadro’s number begins with itsbinary order of magnitude, and only then begins the descriptionequivalent to the leading digits – a sort of recursive version of scientificnotation.”

The continued logarithm algorithm computes the odd gcd and

I involves quotients that are powers of 2.

I seems simple and efficient.

I let us see an example!

Page 5: Continued Logarithm Algorithm. A probabilistic study

The origins

In Hakmem Gosper writes

“There is a mutation of continued fractions, which I call continuedlogarithms, which have several advantages over regular continuedfractions, especially for computational hardware.

(. . .) The primary advantage is the conveniently small information parcel.

(. . .) the continued logarithm of Avogadro’s number begins with itsbinary order of magnitude, and only then begins the descriptionequivalent to the leading digits – a sort of recursive version of scientificnotation.”

The continued logarithm algorithm computes the odd gcd and

I involves quotients that are powers of 2.

I seems simple and efficient.

I let us see an example!

Page 6: Continued Logarithm Algorithm. A probabilistic study

The origins

In Hakmem Gosper writes

“There is a mutation of continued fractions, which I call continuedlogarithms, which have several advantages over regular continuedfractions, especially for computational hardware.

(. . .) The primary advantage is the conveniently small information parcel.

(. . .) the continued logarithm of Avogadro’s number begins with itsbinary order of magnitude, and only then begins the descriptionequivalent to the leading digits – a sort of recursive version of scientificnotation.”

The continued logarithm algorithm computes the odd gcd and

I involves quotients that are powers of 2.

I seems simple and efficient.

I let us see an example!

Page 7: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm Algorithm?

A binary “division”:q = 2ap+ r ,

how to choose a = a(p, q)? ⇒ greedily!

Example. Let us find gcd(31, 13). Whiteboard!

a q p 2ap r

1 31 13 26 52 26 5 20 61 20 6 12 80 12 8 8 41 8 4 8 0

Remarks.

I Powers of two pop up everywhere!

I We ended up with (8, 0), what is the gcd? ⇒ odd gcd = 1.

Page 8: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm Algorithm?

A binary “division”:q = 2ap+ r ,

how to choose a = a(p, q)?

⇒ greedily!

Example. Let us find gcd(31, 13). Whiteboard!

a q p 2ap r

1 31 13 26 52 26 5 20 61 20 6 12 80 12 8 8 41 8 4 8 0

Remarks.

I Powers of two pop up everywhere!

I We ended up with (8, 0), what is the gcd? ⇒ odd gcd = 1.

Page 9: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm Algorithm?

A binary “division”:q = 2ap+ r ,

how to choose a = a(p, q)? ⇒ greedily!

Example. Let us find gcd(31, 13). Whiteboard!

a q p 2ap r

1 31 13 26 52 26 5 20 61 20 6 12 80 12 8 8 41 8 4 8 0

Remarks.

I Powers of two pop up everywhere!

I We ended up with (8, 0), what is the gcd? ⇒ odd gcd = 1.

Page 10: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm Algorithm?

A binary “division”:q = 2ap+ r ,

how to choose a = a(p, q)? ⇒ greedily!

Example. Let us find gcd(31, 13).

Whiteboard!

a q p 2ap r

1 31 13 26 52 26 5 20 61 20 6 12 80 12 8 8 41 8 4 8 0

Remarks.

I Powers of two pop up everywhere!

I We ended up with (8, 0), what is the gcd? ⇒ odd gcd = 1.

Page 11: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm Algorithm?

A binary “division”:q = 2ap+ r ,

how to choose a = a(p, q)? ⇒ greedily!

Example. Let us find gcd(31, 13). Whiteboard!

a q p 2ap r

1 31 13 26 52 26 5 20 61 20 6 12 80 12 8 8 41 8 4 8 0

Remarks.

I Powers of two pop up everywhere!

I We ended up with (8, 0), what is the gcd? ⇒ odd gcd = 1.

Page 12: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm Algorithm?

A binary “division”:q = 2ap+ r ,

how to choose a = a(p, q)? ⇒ greedily!

Example. Let us find gcd(31, 13). Whiteboard!

a q p 2ap r

1 31 13 26 52 26 5 20 61 20 6 12 80 12 8 8 41 8 4 8 0

Remarks.

I Powers of two pop up everywhere!

I We ended up with (8, 0), what is the gcd? ⇒ odd gcd = 1.

Page 13: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm Algorithm?

A binary “division”:q = 2ap+ r ,

how to choose a = a(p, q)? ⇒ greedily!

Example. Let us find gcd(31, 13). Whiteboard!

a q p 2ap r

1 31 13 26 52 26 5 20 61 20 6 12 80 12 8 8 41 8 4 8 0

Remarks.

I Powers of two pop up everywhere!

I We ended up with (8, 0), what is the gcd? ⇒ odd gcd = 1.

Page 14: Continued Logarithm Algorithm. A probabilistic study

Worst-case studied by Shallit (2016): consider (1, 2n − 1).

Response. We have at most O(log q) steps, like Euclid.No apparent gains in length ⇒ maybe on average?

Shallit then proposed the average case as an open problem.We considered his question...

the problem turned out to be interesting.

We provide an answer to his question,

Average number of steps K and shifts S satisfy

EN [K] ∼ k logN , EN [S] ∼ log 3−log 22 log 2−log 3 EN [K]

for an explicit constant k.= 1.49283 . . . given by

k =2

H, H = 1

log(4/3)

(π2

6 + 2Li2(−1/2)− (log 2) log 27log 16

)=⇒ proof turns out to be a bit unexpected.

Page 15: Continued Logarithm Algorithm. A probabilistic study

Worst-case studied by Shallit (2016): consider (1, 2n − 1).

Response. We have at most O(log q) steps, like Euclid.

No apparent gains in length ⇒ maybe on average?

Shallit then proposed the average case as an open problem.We considered his question...

the problem turned out to be interesting.

We provide an answer to his question,

Average number of steps K and shifts S satisfy

EN [K] ∼ k logN , EN [S] ∼ log 3−log 22 log 2−log 3 EN [K]

for an explicit constant k.= 1.49283 . . . given by

k =2

H, H = 1

log(4/3)

(π2

6 + 2Li2(−1/2)− (log 2) log 27log 16

)=⇒ proof turns out to be a bit unexpected.

Page 16: Continued Logarithm Algorithm. A probabilistic study

Worst-case studied by Shallit (2016): consider (1, 2n − 1).

Response. We have at most O(log q) steps, like Euclid.No apparent gains in length

⇒ maybe on average?

Shallit then proposed the average case as an open problem.We considered his question...

the problem turned out to be interesting.

We provide an answer to his question,

Average number of steps K and shifts S satisfy

EN [K] ∼ k logN , EN [S] ∼ log 3−log 22 log 2−log 3 EN [K]

for an explicit constant k.= 1.49283 . . . given by

k =2

H, H = 1

log(4/3)

(π2

6 + 2Li2(−1/2)− (log 2) log 27log 16

)=⇒ proof turns out to be a bit unexpected.

Page 17: Continued Logarithm Algorithm. A probabilistic study

Worst-case studied by Shallit (2016): consider (1, 2n − 1).

Response. We have at most O(log q) steps, like Euclid.No apparent gains in length ⇒ maybe on average?

Shallit then proposed the average case as an open problem.We considered his question...

the problem turned out to be interesting.

We provide an answer to his question,

Average number of steps K and shifts S satisfy

EN [K] ∼ k logN , EN [S] ∼ log 3−log 22 log 2−log 3 EN [K]

for an explicit constant k.= 1.49283 . . . given by

k =2

H, H = 1

log(4/3)

(π2

6 + 2Li2(−1/2)− (log 2) log 27log 16

)=⇒ proof turns out to be a bit unexpected.

Page 18: Continued Logarithm Algorithm. A probabilistic study

Worst-case studied by Shallit (2016): consider (1, 2n − 1).

Response. We have at most O(log q) steps, like Euclid.No apparent gains in length ⇒ maybe on average?

Shallit then proposed the average case as an open problem.We considered his question...

the problem turned out to be interesting.

We provide an answer to his question,

Average number of steps K and shifts S satisfy

EN [K] ∼ k logN , EN [S] ∼ log 3−log 22 log 2−log 3 EN [K]

for an explicit constant k.= 1.49283 . . . given by

k =2

H, H = 1

log(4/3)

(π2

6 + 2Li2(−1/2)− (log 2) log 27log 16

)=⇒ proof turns out to be a bit unexpected.

Page 19: Continued Logarithm Algorithm. A probabilistic study

Worst-case studied by Shallit (2016): consider (1, 2n − 1).

Response. We have at most O(log q) steps, like Euclid.No apparent gains in length ⇒ maybe on average?

Shallit then proposed the average case as an open problem.We considered his question...

the problem turned out to be interesting.

We provide an answer to his question,

Average number of steps K and shifts S satisfy

EN [K] ∼ k logN , EN [S] ∼ log 3−log 22 log 2−log 3 EN [K]

for an explicit constant k.= 1.49283 . . . given by

k =2

H, H = 1

log(4/3)

(π2

6 + 2Li2(−1/2)− (log 2) log 27log 16

)

=⇒ proof turns out to be a bit unexpected.

Page 20: Continued Logarithm Algorithm. A probabilistic study

Worst-case studied by Shallit (2016): consider (1, 2n − 1).

Response. We have at most O(log q) steps, like Euclid.No apparent gains in length ⇒ maybe on average?

Shallit then proposed the average case as an open problem.We considered his question...

the problem turned out to be interesting.

We provide an answer to his question,

Average number of steps K and shifts S satisfy

EN [K] ∼ k logN , EN [S] ∼ log 3−log 22 log 2−log 3 EN [K]

for an explicit constant k.= 1.49283 . . . given by

k =2

H, H = 1

log(4/3)

(π2

6 + 2Li2(−1/2)− (log 2) log 27log 16

)=⇒ proof turns out to be a bit unexpected.

Page 21: Continued Logarithm Algorithm. A probabilistic study

Procedure summarized in

(p, q) 7→ (p′, q′) = (q − 2ap, 2ap) ,

where a is chosen greedily.

Note.

I The map p/q 7→ p′/q′ can be extended to I = (0, 1)

T : I → I , T (x) =2−a

x− 1 ,

where a is chosen greedily! a = blog2(1/x)c.I Algorithm gives rise to a continued fraction

p

q=

2−a

1 + p′

q′

.

Page 22: Continued Logarithm Algorithm. A probabilistic study

Procedure summarized in

(p, q) 7→ (p′, q′) = (q − 2ap, 2ap) ,

where a is chosen greedily.

Note.

I The map p/q 7→ p′/q′ can be extended to I = (0, 1)

T : I → I , T (x) =2−a

x− 1 ,

where a is chosen greedily!

a = blog2(1/x)c.I Algorithm gives rise to a continued fraction

p

q=

2−a

1 + p′

q′

.

Page 23: Continued Logarithm Algorithm. A probabilistic study

Procedure summarized in

(p, q) 7→ (p′, q′) = (q − 2ap, 2ap) ,

where a is chosen greedily.

Note.

I The map p/q 7→ p′/q′ can be extended to I = (0, 1)

T : I → I , T (x) =2−a

x− 1 ,

where a is chosen greedily! a = blog2(1/x)c.I Algorithm gives rise to a continued fraction

p

q=

2−a

1 + p′

q′

.

Page 24: Continued Logarithm Algorithm. A probabilistic study

Procedure summarized in

(p, q) 7→ (p′, q′) = (q − 2ap, 2ap) ,

where a is chosen greedily.

Note.

I The map p/q 7→ p′/q′ can be extended to I = (0, 1)

T : I → I , T (x) =2−a

x− 1 ,

where a is chosen greedily! a = blog2(1/x)c.I Algorithm gives rise to a continued fraction

p

q=

2−a

1 + p′

q′

.

Page 25: Continued Logarithm Algorithm. A probabilistic study

Dynamical system (I, T )

1x

1

T(x)

The map T : I → I

Branches

For x ∈ Ia := [2−a−1, 2−a]

x 7→ T (x) :=2−a

x− 1 .

where a(x) := blog2(1/x)c .

Inverse branches

ha(x) :=2−a

1 + x, H := ha : a ∈ N ,

and at depth k

Hk := ha1 · · · hak : a1, . . . , ak ∈ N .

Page 26: Continued Logarithm Algorithm. A probabilistic study

Density transformerQuestion: If g ∈ C0(I) were the density of x =⇒ density of T (x)?

1x

1

T(x)

|dh0(y)||dh1(y)||dh2(y)||dh3(y)|

dy

Answer: The density is

H[g](x) =∑h∈H

∣∣h′(x)∣∣ g (h(x))=

1

(1 + x)2

∑a≥0

2−a g

(2−a

1 + x

).

In general T k(x) has density

Hk[g](x) =∑h∈Hk

∣∣h′(x)∣∣ g (h(x)) .=⇒ Transfer operator Hs extends H, introducing a variable s

Hs[g](x) =∑h∈H

∣∣h′(x)∣∣s g (h(x)) .

Page 27: Continued Logarithm Algorithm. A probabilistic study

Density transformerQuestion: If g ∈ C0(I) were the density of x =⇒ density of T (x)?

1x

1

T(x)

|dh0(y)||dh1(y)||dh2(y)||dh3(y)|

dy

Answer: The density is

H[g](x) =∑h∈H

∣∣h′(x)∣∣ g (h(x))=

1

(1 + x)2

∑a≥0

2−a g

(2−a

1 + x

).

In general T k(x) has density

Hk[g](x) =∑h∈Hk

∣∣h′(x)∣∣ g (h(x)) .=⇒ Transfer operator Hs extends H, introducing a variable s

Hs[g](x) =∑h∈H

∣∣h′(x)∣∣s g (h(x)) .

Page 28: Continued Logarithm Algorithm. A probabilistic study

Density transformerQuestion: If g ∈ C0(I) were the density of x =⇒ density of T (x)?

1x

1

T(x)

|dh0(y)||dh1(y)||dh2(y)||dh3(y)|

dy

Answer: The density is

H[g](x) =∑h∈H

∣∣h′(x)∣∣ g (h(x))=

1

(1 + x)2

∑a≥0

2−a g

(2−a

1 + x

).

In general T k(x) has density

Hk[g](x) =∑h∈Hk

∣∣h′(x)∣∣ g (h(x)) .

=⇒ Transfer operator Hs extends H, introducing a variable s

Hs[g](x) =∑h∈H

∣∣h′(x)∣∣s g (h(x)) .

Page 29: Continued Logarithm Algorithm. A probabilistic study

Density transformerQuestion: If g ∈ C0(I) were the density of x =⇒ density of T (x)?

1x

1

T(x)

|dh0(y)||dh1(y)||dh2(y)||dh3(y)|

dy

Answer: The density is

H[g](x) =∑h∈H

∣∣h′(x)∣∣ g (h(x))=

1

(1 + x)2

∑a≥0

2−a g

(2−a

1 + x

).

In general T k(x) has density

Hk[g](x) =∑h∈Hk

∣∣h′(x)∣∣ g (h(x)) .=⇒ Transfer operator Hs extends H, introducing a variable s

Hs[g](x) =∑h∈H

∣∣h′(x)∣∣s g (h(x)) .

Page 30: Continued Logarithm Algorithm. A probabilistic study

Great!=⇒ Apply dynamical analysis?

Principles of dynamical analysis:

In our case: Transfer operator does not give enough information!=⇒ Lack information to retrieve the denominator! ⇒ why?

Page 31: Continued Logarithm Algorithm. A probabilistic study

Great!=⇒ Apply dynamical analysis?

Principles of dynamical analysis:

In our case: Transfer operator does not give enough information!=⇒ Lack information to retrieve the denominator! ⇒ why?

Page 32: Continued Logarithm Algorithm. A probabilistic study

Great!=⇒ Apply dynamical analysis?

Principles of dynamical analysis:

In our case: Transfer operator does not give enough information!

=⇒ Lack information to retrieve the denominator! ⇒ why?

Page 33: Continued Logarithm Algorithm. A probabilistic study

Great!=⇒ Apply dynamical analysis?

Principles of dynamical analysis:

In our case: Transfer operator does not give enough information!=⇒ Lack information to retrieve the denominator!

⇒ why?

Page 34: Continued Logarithm Algorithm. A probabilistic study

Great!=⇒ Apply dynamical analysis?

Principles of dynamical analysis:

In our case: Transfer operator does not give enough information!=⇒ Lack information to retrieve the denominator! ⇒ why?

Page 35: Continued Logarithm Algorithm. A probabilistic study

But our algorithm was “simple”, right?Back to the example (13, 31)

a q p 2ap r gcd(p, q)

1 31 13 26 5 12 26 5 20 6 11 20 6 12 8 20 12 8 8 4 41 8 4 8 0 4

Remarks.

I Seemingly helpful large exponents a slow down the algorithm!

I Growing gcd(p, q) prevents inverse branchesfrom distinguishing original denominator q.

I Conjecture: For long developments, gcd(p, q) is a power oftwo with exponent

∼ #steps/2 .

=⇒ Essential to keep track of this “dyadic behaviour”.

Page 36: Continued Logarithm Algorithm. A probabilistic study

But our algorithm was “simple”, right?Back to the example (13, 31)

a q p 2ap r gcd(p, q)

1 31 13 26 5 12 26 5 20 6 11 20 6 12 8 20 12 8 8 4 41 8 4 8 0 4

Remarks.

I Seemingly helpful large exponents a slow down the algorithm!

I Growing gcd(p, q) prevents inverse branchesfrom distinguishing original denominator q.

I Conjecture: For long developments, gcd(p, q) is a power oftwo with exponent

∼ #steps/2 .

=⇒ Essential to keep track of this “dyadic behaviour”.

Page 37: Continued Logarithm Algorithm. A probabilistic study

But our algorithm was “simple”, right?Back to the example (13, 31)

a q p 2ap r gcd(p, q)

1 31 13 26 5 12 26 5 20 6 11 20 6 12 8 20 12 8 8 4 41 8 4 8 0 4

Remarks.

I Seemingly helpful large exponents a slow down the algorithm!

I Growing gcd(p, q) prevents inverse branchesfrom distinguishing original denominator q.

I Conjecture: For long developments, gcd(p, q) is a power oftwo with exponent

∼ #steps/2 .

=⇒ Essential to keep track of this “dyadic behaviour”.

Page 38: Continued Logarithm Algorithm. A probabilistic study

But our algorithm was “simple”, right?Back to the example (13, 31)

a q p 2ap r gcd(p, q)

1 31 13 26 5 12 26 5 20 6 11 20 6 12 8 20 12 8 8 4 41 8 4 8 0 4

Remarks.

I Seemingly helpful large exponents a slow down the algorithm!

I Growing gcd(p, q) prevents inverse branchesfrom distinguishing original denominator q.

I Conjecture: For long developments, gcd(p, q) is a power oftwo with exponent

∼ #steps/2 .

=⇒ Essential to keep track of this “dyadic behaviour”.

Page 39: Continued Logarithm Algorithm. A probabilistic study

Recording the dyadic behaviour

Dyadic behaviour is related to divisibility

=⇒ ... but we employ analysis!

Response: Dyadic numbers Q2 !

Dyadic topology = Divisibility by 2 constraints ,

using the dyadic norm | · |2.

I Incorporate Q2 into the Transfer Operator?

I Careful! Add dyadic component y to “real” dynamical system!

I Variations in y add powers of two to Transfer operator⇒ yet the real component that “leads”.

Idea works!

Page 40: Continued Logarithm Algorithm. A probabilistic study

Recording the dyadic behaviour

Dyadic behaviour is related to divisibility=⇒ ... but we employ analysis!

Response: Dyadic numbers Q2 !

Dyadic topology = Divisibility by 2 constraints ,

using the dyadic norm | · |2.

I Incorporate Q2 into the Transfer Operator?

I Careful! Add dyadic component y to “real” dynamical system!

I Variations in y add powers of two to Transfer operator⇒ yet the real component that “leads”.

Idea works!

Page 41: Continued Logarithm Algorithm. A probabilistic study

Recording the dyadic behaviour

Dyadic behaviour is related to divisibility=⇒ ... but we employ analysis!

Response: Dyadic numbers Q2 !

Dyadic topology = Divisibility by 2 constraints ,

using the dyadic norm | · |2.

I Incorporate Q2 into the Transfer Operator?

I Careful! Add dyadic component y to “real” dynamical system!

I Variations in y add powers of two to Transfer operator⇒ yet the real component that “leads”.

Idea works!

Page 42: Continued Logarithm Algorithm. A probabilistic study

Recording the dyadic behaviour

Dyadic behaviour is related to divisibility=⇒ ... but we employ analysis!

Response: Dyadic numbers Q2 !

Dyadic topology = Divisibility by 2 constraints ,

using the dyadic norm | · |2.

I Incorporate Q2 into the Transfer Operator?

I Careful! Add dyadic component y to “real” dynamical system!

I Variations in y add powers of two to Transfer operator⇒ yet the real component that “leads”.

Idea works!

Page 43: Continued Logarithm Algorithm. A probabilistic study

Recording the dyadic behaviour

Dyadic behaviour is related to divisibility=⇒ ... but we employ analysis!

Response: Dyadic numbers Q2 !

Dyadic topology = Divisibility by 2 constraints ,

using the dyadic norm | · |2.

I Incorporate Q2 into the Transfer Operator?

I Careful! Add dyadic component y to “real” dynamical system!

I Variations in y add powers of two to Transfer operator⇒ yet the real component that “leads”.

Idea works!

Page 44: Continued Logarithm Algorithm. A probabilistic study

Recording the dyadic behaviour

Dyadic behaviour is related to divisibility=⇒ ... but we employ analysis!

Response: Dyadic numbers Q2 !

Dyadic topology = Divisibility by 2 constraints ,

using the dyadic norm | · |2.

I Incorporate Q2 into the Transfer Operator?

I Careful! Add dyadic component y to “real” dynamical system!

I Variations in y add powers of two to Transfer operator

⇒ yet the real component that “leads”.

Idea works!

Page 45: Continued Logarithm Algorithm. A probabilistic study

Recording the dyadic behaviour

Dyadic behaviour is related to divisibility=⇒ ... but we employ analysis!

Response: Dyadic numbers Q2 !

Dyadic topology = Divisibility by 2 constraints ,

using the dyadic norm | · |2.

I Incorporate Q2 into the Transfer Operator?

I Careful! Add dyadic component y to “real” dynamical system!

I Variations in y add powers of two to Transfer operator⇒ yet the real component that “leads”.

Idea works!

Page 46: Continued Logarithm Algorithm. A probabilistic study

Average behaviour of the CL algorithmInput model:

Ω := (p, q) : 0 < p < q, gcd(p, q) = 1 , ΩN := Ω ∩ [N ]× [N ] ,

take uniform probability on ΩN

⇒ expected value EN .

Result.

The mean value of steps EN [K] and shifts EN [S] performedduring the execution of the CL algorithm are Θ(logN).

We have explicit constants

EN [K] ∼ 2

HlogN , EN [S] ∼

log 3− log 2

2 log 2− log 3EN [K] ,

here H is known as the entropy of the system,

H = 1log(4/3)

(π2

6 + 2Li2(−1

2

)− (log 2) log 27log 16

),

numerically H.= 1.33973 . . .

Page 47: Continued Logarithm Algorithm. A probabilistic study

Average behaviour of the CL algorithmInput model:

Ω := (p, q) : 0 < p < q, gcd(p, q) = 1 , ΩN := Ω ∩ [N ]× [N ] ,

take uniform probability on ΩN ⇒ expected value EN .

Result.

The mean value of steps EN [K] and shifts EN [S] performedduring the execution of the CL algorithm are Θ(logN).

We have explicit constants

EN [K] ∼ 2

HlogN , EN [S] ∼

log 3− log 2

2 log 2− log 3EN [K] ,

here H is known as the entropy of the system,

H = 1log(4/3)

(π2

6 + 2Li2(−1

2

)− (log 2) log 27log 16

),

numerically H.= 1.33973 . . .

Page 48: Continued Logarithm Algorithm. A probabilistic study

Average behaviour of the CL algorithmInput model:

Ω := (p, q) : 0 < p < q, gcd(p, q) = 1 , ΩN := Ω ∩ [N ]× [N ] ,

take uniform probability on ΩN ⇒ expected value EN .

Result.

The mean value of steps EN [K] and shifts EN [S] performedduring the execution of the CL algorithm are Θ(logN).

We have explicit constants

EN [K] ∼ 2

HlogN , EN [S] ∼

log 3− log 2

2 log 2− log 3EN [K] ,

here H is known as the entropy of the system,

H = 1log(4/3)

(π2

6 + 2Li2(−1

2

)− (log 2) log 27log 16

),

numerically H.= 1.33973 . . .

Page 49: Continued Logarithm Algorithm. A probabilistic study

Average behaviour of the CL algorithmInput model:

Ω := (p, q) : 0 < p < q, gcd(p, q) = 1 , ΩN := Ω ∩ [N ]× [N ] ,

take uniform probability on ΩN ⇒ expected value EN .

Result.

The mean value of steps EN [K] and shifts EN [S] performedduring the execution of the CL algorithm are Θ(logN).

We have explicit constants

EN [K] ∼ 2

HlogN , EN [S] ∼

log 3− log 2

2 log 2− log 3EN [K] ,

here H is known as the entropy of the system,

H = 1log(4/3)

(π2

6 + 2Li2(−1

2

)− (log 2) log 27log 16

),

numerically H.= 1.33973 . . .

Page 50: Continued Logarithm Algorithm. A probabilistic study

The extended dynamical system

~ Introduce I := I ×Q2 and T : I → I as follows

T (x, y) = (Ta(x), Ta(y)) ,

for x ∈ Ia = [2−a−1, 2−a]. This gives inverse branches

ha(x, y) = (ha(x), ha(y)) , (x, y) ∈ I .

Evolution is lead by the real component, which determines a.

~ For Transfer operator ⇒ need change of variables formula!

Haar (translation invariant) measure ν on Q2 does satisfy∫Q2

F (y)dν(y) =

∫Q2

F (h(y))|h′(y)|2dν(y) .

=⇒ Consider related measure ν on Q2 !⇒ extended transfer operator Hs.

Page 51: Continued Logarithm Algorithm. A probabilistic study

The extended dynamical system

~ Introduce I := I ×Q2 and T : I → I as follows

T (x, y) = (Ta(x), Ta(y)) ,

for x ∈ Ia = [2−a−1, 2−a]. This gives inverse branches

ha(x, y) = (ha(x), ha(y)) , (x, y) ∈ I .

Evolution is lead by the real component, which determines a.

~ For Transfer operator ⇒ need change of variables formula!

Haar (translation invariant) measure ν on Q2 does satisfy∫Q2

F (y)dν(y) =

∫Q2

F (h(y))|h′(y)|2dν(y) .

=⇒ Consider related measure ν on Q2 !⇒ extended transfer operator Hs.

Page 52: Continued Logarithm Algorithm. A probabilistic study

The extended dynamical system

~ Introduce I := I ×Q2 and T : I → I as follows

T (x, y) = (Ta(x), Ta(y)) ,

for x ∈ Ia = [2−a−1, 2−a]. This gives inverse branches

ha(x, y) = (ha(x), ha(y)) , (x, y) ∈ I .

Evolution is lead by the real component, which determines a.

~ For Transfer operator ⇒ need change of variables formula!

Haar (translation invariant) measure ν on Q2 does satisfy∫Q2

F (y)dν(y) =

∫Q2

F (h(y))|h′(y)|2dν(y) .

=⇒ Consider related measure ν on Q2 !⇒ extended transfer operator Hs.

Page 53: Continued Logarithm Algorithm. A probabilistic study

The extended dynamical system

~ Introduce I := I ×Q2 and T : I → I as follows

T (x, y) = (Ta(x), Ta(y)) ,

for x ∈ Ia = [2−a−1, 2−a]. This gives inverse branches

ha(x, y) = (ha(x), ha(y)) , (x, y) ∈ I .

Evolution is lead by the real component, which determines a.

~ For Transfer operator ⇒ need change of variables formula!

Haar (translation invariant) measure ν on Q2 does satisfy∫Q2

F (y)dν(y) =

∫Q2

F (h(y))|h′(y)|2dν(y) .

=⇒ Consider related measure ν on Q2 !⇒ extended transfer operator Hs.

Page 54: Continued Logarithm Algorithm. A probabilistic study

The extended dynamical system

~ Introduce I := I ×Q2 and T : I → I as follows

T (x, y) = (Ta(x), Ta(y)) ,

for x ∈ Ia = [2−a−1, 2−a]. This gives inverse branches

ha(x, y) = (ha(x), ha(y)) , (x, y) ∈ I .

Evolution is lead by the real component, which determines a.

~ For Transfer operator ⇒ need change of variables formula!

Haar (translation invariant) measure ν on Q2 does satisfy∫Q2

F (y)dν(y) =

∫Q2

F (h(y))|h′(y)|2dν(y) .

=⇒ Consider related measure ν on Q2 !⇒ extended transfer operator Hs.

Page 55: Continued Logarithm Algorithm. A probabilistic study

Regarding the extended dynamical system

Several remarks

I Real component behaves extremely well...... yet the dyadic one does not.

I This fact complicates the Functional AnalysisI ... choice of functional space F .I ... scope at which Hs will act nicely on F .

I Real component so “nice” that we still succeed!

Real dynamical system studied by Chan (2005), Borwein at al. (2016)

I Ergodic.

I Invariant density ψ(x) = 1log(4/3)

1(x+1)(x+2) .

I Geometrical properties that make it act nicely on C1(I)=⇒ Dominant eigenvalue and spectral gap!

Page 56: Continued Logarithm Algorithm. A probabilistic study

Regarding the extended dynamical system

Several remarks

I Real component behaves extremely well...... yet the dyadic one does not.

I This fact complicates the Functional AnalysisI ... choice of functional space F .I ... scope at which Hs will act nicely on F .

I Real component so “nice” that we still succeed!

Real dynamical system studied by Chan (2005), Borwein at al. (2016)

I Ergodic.

I Invariant density ψ(x) = 1log(4/3)

1(x+1)(x+2) .

I Geometrical properties that make it act nicely on C1(I)=⇒ Dominant eigenvalue and spectral gap!

Page 57: Continued Logarithm Algorithm. A probabilistic study

Regarding the extended dynamical system

Several remarks

I Real component behaves extremely well...... yet the dyadic one does not.

I This fact complicates the Functional AnalysisI ... choice of functional space F .I ... scope at which Hs will act nicely on F .

I Real component so “nice” that we still succeed!

Real dynamical system studied by Chan (2005), Borwein at al. (2016)

I Ergodic.

I Invariant density ψ(x) = 1log(4/3)

1(x+1)(x+2) .

I Geometrical properties that make it act nicely on C1(I)=⇒ Dominant eigenvalue and spectral gap!

Page 58: Continued Logarithm Algorithm. A probabilistic study

Regarding the extended dynamical system

Several remarks

I Real component behaves extremely well...... yet the dyadic one does not.

I This fact complicates the Functional AnalysisI ... choice of functional space F .I ... scope at which Hs will act nicely on F .

I Real component so “nice” that we still succeed!

Real dynamical system studied by Chan (2005), Borwein at al. (2016)

I Ergodic.

I Invariant density ψ(x) = 1log(4/3)

1(x+1)(x+2) .

I Geometrical properties that make it act nicely on C1(I)=⇒ Dominant eigenvalue and spectral gap!

Page 59: Continued Logarithm Algorithm. A probabilistic study

Regarding the extended dynamical system

Several remarks

I Real component behaves extremely well...... yet the dyadic one does not.

I This fact complicates the Functional AnalysisI ... choice of functional space F .I ... scope at which Hs will act nicely on F .

I Real component so “nice” that we still succeed!

Real dynamical system studied by Chan (2005), Borwein at al. (2016)

I Ergodic.

I Invariant density ψ(x) = 1log(4/3)

1(x+1)(x+2) .

I Geometrical properties that make it act nicely on C1(I)=⇒ Dominant eigenvalue and spectral gap!

Page 60: Continued Logarithm Algorithm. A probabilistic study

Functional space F for the extended operator Hs

Real component directs the dynamical system:

I sections Fy fixing y ∈ Q2 asked to be C1(I).I the dyadic component follows, demanding only integrability of

y 7→ supxFy , and y 7→ sup

x∂xFy .

Ensuing space F makes Hs

I act on F for <s > 1/2 ⇒ big enough set of s.

I have a dominant eigenvalue and spectral gaprelying strongly on the real component.

We can finish the dynamical analysis!

Page 61: Continued Logarithm Algorithm. A probabilistic study

Functional space F for the extended operator Hs

Real component directs the dynamical system:

I sections Fy fixing y ∈ Q2 asked to be C1(I).I the dyadic component follows, demanding only integrability of

y 7→ supxFy , and y 7→ sup

x∂xFy .

Ensuing space F makes Hs

I act on F for <s > 1/2 ⇒ big enough set of s.

I have a dominant eigenvalue and spectral gaprelying strongly on the real component.

We can finish the dynamical analysis!

Page 62: Continued Logarithm Algorithm. A probabilistic study

Functional space F for the extended operator Hs

Real component directs the dynamical system:

I sections Fy fixing y ∈ Q2 asked to be C1(I).I the dyadic component follows, demanding only integrability of

y 7→ supxFy , and y 7→ sup

x∂xFy .

Ensuing space F makes Hs

I act on F for <s > 1/2 ⇒ big enough set of s.

I have a dominant eigenvalue and spectral gaprelying strongly on the real component.

We can finish the dynamical analysis!

Page 63: Continued Logarithm Algorithm. A probabilistic study

Conclusion and further questions

We have analysed

1. the number of steps

2. the number of binary shifts

performed by the Continued Logarithm Algorithm.

We would like to consider... the bit complexity.

In particular when dividing (p, q) 7→ (p/2, q/2) as soon as possible!⇒ may have competitive bit complexity.

Page 64: Continued Logarithm Algorithm. A probabilistic study

Conclusion and further questions

We have analysed

1. the number of steps

2. the number of binary shifts

performed by the Continued Logarithm Algorithm.

We would like to consider... the bit complexity.

In particular when dividing (p, q) 7→ (p/2, q/2) as soon as possible!⇒ may have competitive bit complexity.

Page 65: Continued Logarithm Algorithm. A probabilistic study

Conclusion and further questions

We have analysed

1. the number of steps

2. the number of binary shifts

performed by the Continued Logarithm Algorithm.

We would like to consider... the bit complexity.

In particular when dividing (p, q) 7→ (p/2, q/2) as soon as possible!⇒ may have competitive bit complexity.

Page 66: Continued Logarithm Algorithm. A probabilistic study

The Continued Logarithm vs. other binary algorithms

Other well-known binary algorithms include

I The binary GCD

I The LSB (least significant bits) algorithm– Informally “the Tortoise and the Hare”.

The dyadics play different roles in the dynamical analysis

I For the binary GCD: they do not intervene.

I For the LSB: they play the main role!

Unify the analysis to better understand the role of the dyadics?

Page 67: Continued Logarithm Algorithm. A probabilistic study

The Continued Logarithm vs. other binary algorithms

Other well-known binary algorithms include

I The binary GCD

I The LSB (least significant bits) algorithm– Informally “the Tortoise and the Hare”.

The dyadics play different roles in the dynamical analysis

I For the binary GCD: they do not intervene.

I For the LSB: they play the main role!

Unify the analysis to better understand the role of the dyadics?

Page 68: Continued Logarithm Algorithm. A probabilistic study

The Continued Logarithm vs. other binary algorithms

Other well-known binary algorithms include

I The binary GCD

I The LSB (least significant bits) algorithm– Informally “the Tortoise and the Hare”.

The dyadics play different roles in the dynamical analysis

I For the binary GCD: they do not intervene.

I For the LSB: they play the main role!

Unify the analysis to better understand the role of the dyadics?

Page 69: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm expansion over the reals

Chan studied from an Ergodic perspective

I the averages of the exponents (a1(x) + . . .+ aM (x))/M .

I the exponential growth of the “natural continuants” Qk(x).

Results concerning almost every x ∈ I=⇒ truncate the expansion a1(x), a2(x), . . . at depth k.

Adapting our methods to this context is work in progress:

I behaviour of continuants Qk differs from rational case.

I we conjecture − 1kE[log2 |Qk|2] ∼ 1/2

→ we have proved the limit exists... explicit invariant density Ψ(x, y) ?

→ related to growth of gcd(p, q) in the algorithm!

Page 70: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm expansion over the reals

Chan studied from an Ergodic perspective

I the averages of the exponents (a1(x) + . . .+ aM (x))/M .

I the exponential growth of the “natural continuants” Qk(x).

Results concerning almost every x ∈ I=⇒ truncate the expansion a1(x), a2(x), . . . at depth k.

Adapting our methods to this context is work in progress:

I behaviour of continuants Qk differs from rational case.

I we conjecture − 1kE[log2 |Qk|2] ∼ 1/2

→ we have proved the limit exists... explicit invariant density Ψ(x, y) ?

→ related to growth of gcd(p, q) in the algorithm!

Page 71: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm expansion over the reals

Chan studied from an Ergodic perspective

I the averages of the exponents (a1(x) + . . .+ aM (x))/M .

I the exponential growth of the “natural continuants” Qk(x).

Results concerning almost every x ∈ I=⇒ truncate the expansion a1(x), a2(x), . . . at depth k.

Adapting our methods to this context is work in progress:

I behaviour of continuants Qk differs from rational case.

I we conjecture − 1kE[log2 |Qk|2] ∼ 1/2

→ we have proved the limit exists... explicit invariant density Ψ(x, y) ?

→ related to growth of gcd(p, q) in the algorithm!

Page 72: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm expansion over the reals

Chan studied from an Ergodic perspective

I the averages of the exponents (a1(x) + . . .+ aM (x))/M .

I the exponential growth of the “natural continuants” Qk(x).

Results concerning almost every x ∈ I=⇒ truncate the expansion a1(x), a2(x), . . . at depth k.

Adapting our methods to this context is work in progress:

I behaviour of continuants Qk differs from rational case.

I we conjecture − 1kE[log2 |Qk|2] ∼ 1/2

→ we have proved the limit exists... explicit invariant density Ψ(x, y) ?

→ related to growth of gcd(p, q) in the algorithm!

Page 73: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm expansion over the reals

Chan studied from an Ergodic perspective

I the averages of the exponents (a1(x) + . . .+ aM (x))/M .

I the exponential growth of the “natural continuants” Qk(x).

Results concerning almost every x ∈ I=⇒ truncate the expansion a1(x), a2(x), . . . at depth k.

Adapting our methods to this context is work in progress:

I behaviour of continuants Qk differs from rational case.

I we conjecture − 1kE[log2 |Qk|2] ∼ 1/2

→ we have proved the limit exists

... explicit invariant density Ψ(x, y) ?→ related to growth of gcd(p, q) in the algorithm!

Page 74: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm expansion over the reals

Chan studied from an Ergodic perspective

I the averages of the exponents (a1(x) + . . .+ aM (x))/M .

I the exponential growth of the “natural continuants” Qk(x).

Results concerning almost every x ∈ I=⇒ truncate the expansion a1(x), a2(x), . . . at depth k.

Adapting our methods to this context is work in progress:

I behaviour of continuants Qk differs from rational case.

I we conjecture − 1kE[log2 |Qk|2] ∼ 1/2

→ we have proved the limit exists... explicit invariant density Ψ(x, y) ?

→ related to growth of gcd(p, q) in the algorithm!

Page 75: Continued Logarithm Algorithm. A probabilistic study

Continued Logarithm expansion over the reals

Chan studied from an Ergodic perspective

I the averages of the exponents (a1(x) + . . .+ aM (x))/M .

I the exponential growth of the “natural continuants” Qk(x).

Results concerning almost every x ∈ I=⇒ truncate the expansion a1(x), a2(x), . . . at depth k.

Adapting our methods to this context is work in progress:

I behaviour of continuants Qk differs from rational case.

I we conjecture − 1kE[log2 |Qk|2] ∼ 1/2

→ we have proved the limit exists... explicit invariant density Ψ(x, y) ?

→ related to growth of gcd(p, q) in the algorithm!

Page 76: Continued Logarithm Algorithm. A probabilistic study

References I

H.C. Chan.The Asymptotic Growth Rate of Random Fibonacci TypeSequences.Fibonacci Quarterly, vol. 43, no. 3, pp. 243–255, 2005.

Bill Gosper.Continued fraction arithmetic.Unpublished manuscript, c. 1978. Available athttp://perl.plover.com/classes/cftalk/INFO/gosper.txt.

P. Rotondo, B. Vallee, and A. Viola.Analysis of the Continued Logarithm Algorithm.Accepted in LATIN 2018. Prepub: arXiv:1801.10139

J. Shallit.Length of the continued logarithm algorithm on rationalinputs.Prepublication submitted to arXiv: arXiv:1606.03881v2, 2016.