Natural Logarithm of 2 Continued Fraction

Author

Eric W. Weisstein
August 21, 2013

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Constants/NaturalLogarithmof2ContinuedFraction.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/NaturalLogarithmof2ContinuedFraction.html.

©2013 Wolfram Research, Inc. except for portions noted otherwise

Initialization

<<Utilities`EISFormat`

Compute

{N[cons],Precision[cons]}

(10^9)

Length[cf=ContinuedFraction[cons]]//Timing

Max[cf]

DumpSave["/Developer/eww/ContinuedFractions/Log2_"<>ToString[Length[cf]]<>".mx",cf];

(10^10)

Length[cf=ContinuedFraction[cons]]//Timing

Max[cf]

{ByteCount[cf],MaxMemoryUsed[]}/10^9.GB

DumpSave["/Developer/eww/ContinuedFractions/Log2_"<>ToString[Length[cf]]<>".mx",cf];

Load

Length[Get["/Developer/eww/ContinuedFractions/Log2_970296842.mx"];cf]//AbsoluteTiming

HighWaterMarks

Length[cf]

(hwm=HighWaterMarks[cf]);//Timing

Length/@hwm

{hwm[[1]],hwm[[2]]-1}

First Occurrences

Length[cf]

fo=FirstOccurrences[cf];//Timing

p=Take[Position[fo,0],10]//Flatten

Take[fo,110]-1

BFile["~/a228269.txt",Take[fo,p[[1]]-1]-1]

ListPlot[Take[fo,p[[1]]-1]-1,AxesLabel->{Subscript[a,n],n},PlotRange->All]

n-Digit Terms

Length[cf]

digs=IntegerLength[cf];//Timing

(max=Max[digs])//Timing

positions=Table[Flatten[Position[digs,n,1,20]],{n,max}];//Timing

data=MapIndexed[{#2[[1]],{#,cf[[#]]}}&,positions]

Grid[{#[[1]],Column@#[[2]]}&/@data,Dividers->All,Alignment->Left]

Khinchin and Lévy Constant

KhinchinList[x_,n_:200]:=MapIndexed[#1^(1/#2[[1]])&,Rest@FoldList[Times,1,Rest[ContinuedFraction[Mod[x,1],n+1]]]]
KhinchinLevyList[x_,n_:200]:=MapIndexed[#1^(1/#2[[1]])&,Denominator/@FromContinuedFraction/@Reverse[NestList[Drop[#,-1]&,Rest[ContinuedFraction[Mod[x,1],n+1]],n]]]

<<Utilities`Typesetting`

With[{k=5000,c=Log[2]},
g1=ListPlot[KhinchinList[c,k],Joined->True,PlotStyle->Red,AxesLabel->{n,((Subscript[a, 1])(Subscript[⋯a, n]))^InlineFraction[1,n]},
PlotLabel->"Khinchin's constant",
Epilog->{Blue,Dashing[{.02}],Line[{{0,#},{k,#}}]&[2.685452001]}];
g2=ListPlot[KhinchinLevyList[c,k],Joined->True,PlotStyle->Red,AxesLabel->{n,(Subscript[q, n])^InlineFraction[1,n]},
PlotLabel->"Lévy constant",
Epilog->{Blue,Dashing[{.02}],Line[{{0,#},{k,#}}]&[Exp[Pi^2/12/Log[2]]]}
];
]//Timing

GraphicsRow[{g1,g2},Spacings->-30,ImageSize->400]