Euler-Mascheroni Constant Continued Fraction

Author

Eric W. Weisstein
July 22, 2013

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Constants/Euler-MascheroniConstantContinuedFraction.nb.

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

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

Initialization

<<Utilities`EISFormat`

Convergents

With[{n=30},FromContinuedFraction/@Reverse[NestList[Most,ContinuedFraction[EulerGamma,n],n-1]]]

Compute

ContinuedFraction[EulerGamma,30]

V5.1

ContinuedFraction[EulerGamma,8 10^6]//Timing

V8

$Version

Length[ContinuedFraction[EulerGamma,10^6]]//Timing

Length[ContinuedFraction[EulerGamma,10^7]]//Timing

Length[ContinuedFraction[EulerGamma,2*^7]]//Timing

Length[ContinuedFraction[EulerGamma,5*^7]]//Timing

Length[ContinuedFraction[EulerGamma,1*^8]]//Timing

Length[c=ContinuedFraction[EulerGamma,1*^8]]//Timing

https://bugs.wolfram.com/show?number=56712

Length[c=ContinuedFraction[EulerGamma,11*^7]]//Timing

Length[c=ContinuedFraction[EulerGamma,12*^7]]//Timing

Length[c=ContinuedFraction[EulerGamma,15*^7]]//Timing

$Version

Length[c=ContinuedFraction[EulerGamma,12*^7]]//Timing

V8.1

$Version

(10^7)

Length[cf=ContinuedFraction[N[EulerGamma,10^7]]]//Timing

2 × (10^8)

Length[cf=ContinuedFraction[N[EulerGamma,2*^8]]]//Timing

(10^6)

$Version

{Date[],Length[cf=ContinuedFraction[N[EulerGamma,1*^6]]]//Timing,MaxMemoryUsed[]/10.^9GB,ByteCount[cf]/10^9.GB}

(10^7)

$Version

{Date[],Length[cf=ContinuedFraction[N[EulerGamma,1*^7]]]//Timing,MaxMemoryUsed[]/10.^9GB,ByteCount[cf]/10^9.GB}

(10^8)

$Version

{Date[],Length[cf=ContinuedFraction[N[EulerGamma,1*^8]]]//Timing,MaxMemoryUsed[]/10.^9GB,ByteCount[cf]/10^9.GB}

(10^9)

{$MachineName,$TopDirectory,DateString[],$Version}//Column

DateString[]

Precision[gamma]

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

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

DumpSave["/Developer/eww/ContinuedFractions/EulerGamma_970258158.mx",cf];

5×(10^9)

{$MachineName,$TopDirectory,DateString[],$Version}//Column

Precision[cons]

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

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

DumpSave["/Developer/eww/ContinuedFractions/EulerGamma_4851382841.mx",cf];

Read

Get["/Developer/eww/ContinuedFractions/EulerGamma_4851382841.mx"];//Timing//AbsoluteTiming

Length[cf]

High-Water marks

Terms: A033091
Positions: A033092

(10^7)

HighWaterMarks[cf]

2×(10^8)

HighWaterMarks[cf]

(10^9)

HighWaterMarks[cf]

5×(10^9)

Length[cf]

(hwm=HighWaterMarks[cf,Method->"LowMemory"])//Timing

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

First Occurrences

A033149

(10^9)

Length[fo=FirstOccurrences[cf]]//Timing

Flatten[Position[first,0,1,20]]

Take[first,1000]

5×(10^9)

Length[cf]

Loop

fo=FirstOccurrences[cf];//Timing

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

Take[fo,110]-1

Take[cf,10]

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

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

Clear[fo]

n-Digit Terms

(10^9)

Length[cf]

digs=IntegerLength[cf];//Timing

Max[digs]//Timing

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

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

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

5×(10^9)

Length[cf]

digs=IntegerLength[cf];//Timing

Max[digs]//Timing

positions=Table[Flatten[Position[digs,n,1,20]],{n,11}];//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]]]]
LevyList[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=EulerGamma},
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[LevyList[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->-100,ImageSize->400]