Champernowne Constant Digits

Author

Eric W. Weisstein
September 14, 2013

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

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

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

Digit Computation

N[ChampernowneNumber[],20]

Compute

(10^9)

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

Precision[cons = N[ChampernowneNumber[], 1*^9+10]]// Timing

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

StringLength[string=StringTake[ToString[cons],{3,-3}]]//Timing

StringTake[string,10]

StringTake[string,-40]

DumpSave["/Developer/eww/DigitStrings/Champernowne_10_9.mx",string];

5×(10^10)

{DateString[],$TopDirectory,$MachineName}

ByteCount[c = N[ChampernowneNumber[], 5*^10]]/10^9. // Timing

MaxMemoryUsed[]/10^9. GB

mem=Take[#,700]&/@(ToExpression@Transpose[Take[#,{4,6}]&/@(StringSplit/@Select[Import["~/memory5.10.10.log","Lines"],StringMatchQ[#," "~~DigitCharacter~~__]&])])

{
ListPlot[mem[[1]]/10^6.,PlotLabel->"free"],
ListPlot[mem[[2]]/10^6.,PlotLabel->"inact"],
ListPlot[mem[[3]]/10^6.,PlotLabel->"active"]
}

6×(10^10)

{DateString[],$TopDirectory,$MachineName}

ByteCount[c = N[ChampernowneNumber[], 6*^10]]/10^9. // Timing

MaxMemoryUsed[]/10^9. GB

mem=Take[#,All]&/@(ToExpression@Transpose[Take[#,{4,6}]&/@(StringSplit/@Select[Import["~/memory6.10.10.log","Lines"],StringMatchQ[#," "~~DigitCharacter~~__]&])])

{
ListPlot[mem[[1]]/10^6.,PlotLabel->"free"],
ListPlot[mem[[2]]/10^6.,PlotLabel->"inact"],
ListPlot[mem[[3]]/10^6.,PlotLabel->"active"]
}

DumpSave["Developer/eww/Constants/Champernowne_6_10_10.mx",c];

Get["/Developer/eww/Constants/ChampernowneConstant-6_10_10.mx"];//Timing

{ByteCount[c],Precision[c]}

StringLength[string=StringTake[ToString[cons],{3,-3}]]//Timing

StringTake[string,10]

DumpSave["/Developer/eww/DigitStrings/Champernowne_6_10_10.mx",string];

Read from file

Get["/Developer/eww/Constants/Champernowne_6_10_10.mx"];//Timing//AbsoluteTiming

{Precision[cons=c],ByteCount[cons]/10^9. GB}

Read String from file

Get["/Developer/eww/DigitStrings/Champernowne_6_10_6.mx"];//Timing//AbsoluteTiming

Digit Distribution

StringPartition[s_String,chunksize_]:=Module[{len=StringLength[s],k},If[chunksize>len,{s},StringTake[s,#]&/@Table[{1+(k-1) chunksize,Min[len,k chunksize]},{k,Ceiling[len/chunksize]}]]]

BigStringCount[s_,c_,chunksize_:((2^31)-1)]:=Total[StringCount[#,c]&/@StringPartition[s,chunksize]]

(10^9)

(digits=Table[{n,BigStringCount[StringTake[string,10^n],#,(2^31)-1]&/@CharacterRange["0","9"]},{n,9}])//Timing

Grid[digits,Dividers->All,Alignment->Left]

A224615 to A224818

MapIndexed[{#2[[1]]-1,#}&,Transpose[digits[[All,2]]]]

Digit Runs

k n’s

(10^9)

StringLength[string]

(data=Flatten[Table[{d,n,If[#=={},0,First[#]]&/@StringPosition[string,StringJoin@@Table[ToString[d],{n}],10]},{d,0,9},{n,12}],1])//Timing

Grid[DeleteCases[data,{_,_,{}}],Dividers->All,Alignment->Left]

n n’s (Earls Sequence)

A224819

(10^9)

StringLength[string]

earls=Cases[DeleteCases[data,{_,_,{}}],{x_,x_,s_}:>{x,s[[1]]}]

earls[[All,2]]

Length[earls]

Scan until all n-digits strings have been found

N[ChampernowneNumber[],11]

?ScanDigitStrings

Length[realdigits=RealDigits[ChampernowneNumber[],10,10^7][[1]]]//Timing

Length[realdigits=RealDigits[N[ChampernowneNumber[],10^7],10][[1]]]//Timing

Length[realdigits=RealDigits[ChampernowneNumber[],10,10^8][[1]]]//Timing

Do[Print[{n,ScanDigitStrings[realdigits,n]//Timing}],{n,9}]

RSolve[{a[n+1]==a[n]+1+9 (10^n) (1+n),a[0]==1},a[n],n]//FullSimplify

Table[(10/9)-((10^n)/9)+n+(10^n) n,{n,0,10}]

Table[(10/9)-((10^(1+n))/9)+n+(10^n) (1+n),{n,0,10}]

a[n_]:=(10/9)-((10^n)/9)+n+(10^n) n

IntegerLength[a[1000]]

<<Utilities`EISFormat`

BFile["~/b072290.txt",Table[a[n],{n,0,1000}],0]

First digit string occurrences

A229186

Length[f=FirstDigitOccurrences[realdigits,6]]//Timing

Take[f,100]

Take[Position[f,0],All]//Flatten

<<Utilities`EISFormat`

BFile["~/a229186.txt",Take[f,1000],0]

Specific Digits Runs

StringLength[string]

0123456789

StringPosition[string,"0123456789"]//Timing

9876543210

StringPosition[string,"9876543210"]//Timing