Landau-Ramanujan Constant

Author

Eric W. Weisstein
November 9, 2009

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Constants/Landau-RamanujanConstant.nb.

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

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

Enumeration

twosquares[n_]:=Module[{i,j},Rest[Select[Union[Flatten[Table[(i^2)+(j^2),{i,0,n},{j,i,n}]]],#<=(n^2)&]]]

twosquares[7]

Plot

data=MapIndexed[{#,N[((Sqrt[Log[#]])/(#))]First[#2]}&,twosquares[1000]];//Timing

Through[{Last,Length}[data]]

MakeBoxes[ylabel,TraditionalForm]:=RowBox[{FractionBox[SqrtBox[RowBox[{"ln","x"}]],"x"]," ",RowBox[{"S","(","x",")"}]}]

With[{k=0.76422365358922066},
ListPlot[Last/@Partition[data,10],
Joined->True,PlotStyle->Red,
Epilog->{Blue,Style[Text["K",{1.01*^6,.77}],FontSlant->Italic],Line[{{0,k},{10^6,k}}]},
AxesLabel->{x,ylabel},
PlotRange->{.75,.9},
AxesOrigin->{0,.75}]
]

Powers of 10

Method 1

Very inefficient

twosquares[5]

(powers=Flatten[Table[Position[twosquares[1000],_?(#≥10^n&),{1},1],{n,0,6}]])//Timing

(powers=Flatten[Table[Position[twosquares[2000],_?(#≥10^n&),{1},1],{n,0,8}]])//Timing

(powers=Flatten[Table[Position[twosquares[10^4],_?(#≥10^n&),{1},1],{n,0,10}]])//Timing

Method 2 (Fast-ish)

(10^5)

Table[Total[Unitize[SquaresR[2,Range[(10^n)]]]],{n,5}]//Timing

(10^6)

Table[Total[Unitize[SquaresR[2,Range[(10^n)]]]],{n,6}]//Timing

MaxMemoryUsed[]/10^6.

(10^7)

(l=Table[Total[Unitize[SquaresR[2,Range[(10^n)]]]],{n,7}])//Timing

MaxMemoryUsed[]/10^9.

(l=Table[Total[Unitize[SquaresR[2,Range[(10^n)]]]],{n,7}])//Timing

(10^8)

(l=Table[Total[Unitize[SquaresR[2,Range[(10^n)]]]],{n,8}])//Timing

Method 3

Less efficient due to compilation?

With[{nmax=5},
1+Accumulate[Total/@Table[Unitize[SquaresR[2,Range[(10^nmax)]]][[1+(10^(n-1));;(10^n)]],{n,nmax}]]
]//Timing

Method 4

Table[Length[Position[Table[FindInstance[x^2+y^2==n,{x,y},Integers,1],{n,10^p}],Except[{}],1,Heads->False]],{p,4}]//Timing

Method 5

Table[Length[Position[Table[PowersRepresentations[n,2,2],{n,10^p}],Except[{}],1,Heads->False]],{p,4}]//Timing

Method 6 (Fast and Low-Memory)

For n > 1,  SquaresR[2, n] has a solution iff n is not divisible by a prime power (p^m) with Mod[p, 4] == 3 and m odd.

SetAttributes[UnitizeSquaresR, Listable]
UnitizeSquaresR[0] = 0;
UnitizeSquaresR[1] = 1;
UnitizeSquaresR[n_] := If[MemberQ[FactorInteger[n], {p_ /; Mod[p, 4] == 3, _?OddQ}], 0, 1]

(10^5)

Timing[Table[Total[UnitizeSquaresR[Range[10^n]]], {n, 5}]]

MaxMemoryUsed[]/10^6.

(10^6)

Timing[Table[Total[UnitizeSquaresR[Range[10^n]]], {n, 6}]]

MaxMemoryUsed[]/10^6.

(10^7)

Timing[Table[Total[UnitizeSquaresR[Range[10^n]]], {n, 7}]]

MaxMemoryUsed[]/10^6.

(10^8)

Timing[Table[Total[UnitizeSquaresR[Range[10^n]]], {n, 8}]]

MaxMemoryUsed[]/10^9.

s=0;
(Monitor[Do[s+=UnitizeSquaresR[n],{n,nmax=10^8}],{n,n/nmax 100. "%",s}];s)//Timing

(10^9)

s=0;
(Monitor[Do[s+=UnitizeSquaresR[n],{n,nmax=10^9}],{n,n/nmax 100. "%",s}];s)//Timing

(10^10)

s=0;
(Monitor[For[n=1,n≤(nmax=10^10),n++,s+=UnitizeSquaresR[n]],{n,n/nmax 100. "%",s}];s)//Timing

790658/86400. Days

Table

l={7,43,330,2749,24028,216341,1985459,18457847,173229058,1637624156};

Grid[MapIndexed[{x=#2[[1]],#1,N[((Sqrt[x Log[10]])/(10^x))#1,10]}&,l],Alignment->Decimal,Dividers->All]

Prime Products

(Times@@N[((1-1/#^2)^(-1/2)&/@Select[Prime[Range[#]],Mod[#,4]==3&]),20]/Sqrt[2]//Timing)&/@{10^4,5 10^4}

(Times@@N[((1-1/#^2)^(1/2)&/@Select[Prime[Range[#]],Mod[#,4]==1&]),20]Pi/4//Timing)&/@{10^4,5 10^4}

Rapidly Converging Series

(((∏_(k=1)^(⌈((ln(((ln(10) n)/(ln(3)))))/(ln(2)))⌉))((((((4^(2^k)) (1-(2^(-(2^k)))) ζ((2^k)))/(ζ((2^k),(1/4))-ζ((2^k),(3/4))))))^(2^(-k-1))))/(Sqrt[2]))

Victor's Form

V6

Function[n,Ceiling[Log[2,n Log[3,10]]]]/@{100}

With[{K=⌈Log[2,n Log[3,10]]⌉},(1/(Sqrt[2]))(∏_(k=1)^K)((((((1-(2^(-(2^k)))) (4^(2^k)) Zeta[(2^k)])/(Zeta[(2^k),(1/4)]-Zeta[(2^k),(3/4)]))))^(2^(-k-1)))]

LandauRamanujan[100]//Timing

LandauRamanujan[500]//Timing

LandauRamanujan[1000]//Timing

V7

TimeConstrained[With[{K=⌈Log[2,n Log[3,10]]⌉},(1/(Sqrt[2]))(∏_(k=1)^K)((((((1-(2^(-(2^k)))) (4^(2^k)) Zeta[(2^k)])/(Zeta[(2^k),(1/4)]-Zeta[(2^k),(3/4)]))))^(2^(-k-1)))],60]//Timing

(∏_n^∞)((((((1-(1/(2^(2^n)))) ζ((2^n)))/(β((2^n))))))^(1/(2^(n+1))))

Equivalent Form

DirichletBeta[x_]:=(4^(-x)) (Zeta[x,(1/4)]-Zeta[x,(3/4)])

Plot[((((1-(1/(2^(2^n))))((Zeta[(2^n)])/(DirichletBeta[(2^n)]))))^(1/((2^n)+1))),{n,1,10},PlotStyle->Red]

V6

Product[((((1-(1/(2^(2^n))))((Zeta[(2^n)])/(DirichletBeta[(2^n)]))))^(1/((2^(n+1))))),{n,∞}]/Sqrt[2]

V7

Product[((((1-(1/(2^(2^n))))((Zeta[(2^n)])/(DirichletBeta[(2^n)]))))^(1/((2^(n+1))))),{n,∞}]/Sqrt[2]//Timing

NProduct

NProduct[((((1-(1/(2^(2^n))))((Zeta[(2^n)])/(DirichletBeta[(2^n)]))))^(1/(2^(n+1)))),{n,∞},WorkingPrecision->50]/Sqrt[2]

NProduct[((((1-(1/(2^(2^n))))((Zeta[(2^n)])/(DirichletBeta[(2^n)]))))^(1/(2^(n+1)))),{n,∞},WorkingPrecision->50,VerifyConvergence->False]/Sqrt[2]

NProduct[((((1-(1/(2^(2^n))))((Zeta[(2^n)])/(DirichletBeta[(2^n)]))))^(1/(2^(n+1)))),{n,∞},WorkingPrecision->50,VerifyConvergence->False,Method->Integrate]/Sqrt[2]

NProduct[((((1-(1/(2^(2^n))))((Zeta[(2^n)])/(DirichletBeta[(2^n)]))))^(1/(2^(n+1)))),{n,∞},WorkingPrecision->50,VerifyConvergence->False,Method->NIntegrate]/Sqrt[2]

NProduct[((((1-(1/(2^(2^n))))((Zeta[(2^n)])/(DirichletBeta[(2^n)]))))^(1/(2^(n+1)))),{n,∞},WorkingPrecision->50,VerifyConvergence->False,Method->SequenceLimit]/Sqrt[2]

NProduct[((((1-(1/(2^(2^n))))((Zeta[(2^n)])/(DirichletBeta[(2^n)]))))^(1/(2^(n+1)))),{n,∞},WorkingPrecision->50,VerifyConvergence->False,Method->Fit]/Sqrt[2]

k=NProduct[((((1-(1/(2^(2^n))))((Zeta[(2^n)])/(DirichletBeta[(2^n)]))))^(1/(2^(n+1)))),{n,20},WorkingPrecision->100]/Sqrt[2]

term[n_?NumberQ]:=(Print[n];((((((4^(2^n)) (1-(2^(-(2^n)))) Zeta[(2^n)])/(Zeta[(2^n),(1/4)]-Zeta[(2^n),(3/4)]))))^(2^(-1-n))))

NProduct[term[n],{n,∞},WorkingPrecision->50]/Sqrt[2]

term/@N[{46662,93308},50]

Divide@@(term/@N[{46662,93308},50])

NProduct[term[n],{n,∞},WorkingPrecision->50,VerifyConvergence->False,Method->Fit]/Sqrt[2]

term[30]

term[n]

FullSimplify[((((((4^(2^n)) (1-(2^(-(2^n)))) Zeta[(2^n)])/(Zeta[(2^n),(1/4)]-Zeta[(2^n),(3/4)]))))^(2^(-1-n)))]

4^(2^30)

term[n_]:=((((((4^(2^n)) (1-(2^(-(2^n)))) Zeta[(2^n)])/(Zeta[(2^n),(1/4)]-Zeta[(2^n),(3/4)]))))^(2^(-1-n)))

Limit[FullSimplify[term[n]/term[n-1]],n->∞]

By Hand

N[Times@@Table[((((1-(1/(2^(2^n))))((Zeta[(2^n)])/(DirichletBeta[(2^n)]))))^(1/(2^(n+1)))),{n,#}]/Sqrt[2],100]&/@{10,11}

Gosper

This doesn't seem quite right

Ψ[m_]:=((m PolyGamma[m-1,1/4])/((π^m)((2^m)-1)(4^(m-1))Abs@BernoulliB[m]))

FullSimplify[FunctionExpand[Table[Ψ[2^m],{m,0,3}]]]

NΨ[n_]:=Module[{m=N[n,50]},((m PolyGamma[m-1,1/4])/((π^m)((2^m)-1)(4^(m-1))BernoulliB[n]))]

((((1/(NΨ[2]-1))))^(2^(1/2)))Product[((((1/(-NΨ[(2^k)]-1))))^(1/(2^(k+1)))),{k,2,4}]/2

Table[((((1/(-NΨ[(2^k)]-1))))^(1/(2^(k+1)))),{k,2,5}]

Second Constant

(1/2) (1-ln(((π exp(ℽ))/(((Γ((1/4)))^2)/(Sqrt[2 π])))))-(1/4) (((∏_n^∞)If[(Subscript[p, n]) mod 4==3,(1/(1-(1/(Subscript[p, n]^(2 s))))),1])[0])'

V6

(L=((Gamma[1/4]^2)/(2Sqrt[2Pi])))//N

N[1/2(1-Log[(Pi/(2L))Exp[EulerGamma]])-1/4D[Log[Times@@(1/(1-#^(-2s))&/@Select[Prime[Range[1000]],Mod[#,4]==3&])],s]/.s->1,20]//Timing

N[1/2(1-Log[(Pi/(2L))Exp[EulerGamma]])-1/4D[Log[Times@@(1/(1-#^(-2s))&/@Select[Prime[Range[10000]],Mod[#,4]==3&])],s]/.s->1,20]//Timing

c=0.581948659`9

V7

FullSimplify[1/2(1-Log[(Pi/(((Gamma[(1/4)])^2)/(Sqrt[2 π])))Exp[EulerGamma]])]

(1/4) (2-2 EulerGamma+Log[(1/(2 (π^3)))])+Log[Gamma[(1/4)]]-(1/4)Derivative[1][Function[s,Evaluate[Log[Product[If[Mod[Prime[n],4]==3,(1/(1-1/((Prime[n])^(2s)))),1],{n,10^3}]]]]][1]//N

Product[If[Mod[Prime[n],4]==3,(1/(1-1/((Prime[n])^(2s)))),1],{n,∞}]

Oleg

N[With[{n=10000},(1/2)*(1-Log[(Pi*E^EulerGamma)/(2*(Gamma[1/4]^2/(2*Sqrt[2*Pi])))])-(1/4)*D[Log[Product[Piecewise[{{1/(1-Prime[k]^(-2*s)),Mod[Prime[k],4]==3},{1,True}}],{k,1,1000}]],s]/.s->1]]//Timing

K==(lim_(n->∞)) (((log^(1/2))(n) (∑_(k=1)^n)1-(DiscreteDeltaSeq[(SquaresR[2, k])]))/n)

Sum[1-UnitStep[-SquaresR[2,k]],{k,n}]

Sum[1-DiscreteDelta[SquaresR[2,k]],{k,n}]

FunctionExpand[SquaresR[2,k]]

Table[Sum[1-DiscreteDelta[SquaresR[2,k]],{k,n}],{n,10}]

With[{n=10^6},((Sqrt[Log[n]])/n)Sum[1.-DiscreteDelta[SquaresR[2,k]],{k,n}]]//Timing

With[{lr=0.76422365358922066},Plot[((Sqrt[Log[n]])/n)Sum[1-DiscreteDelta[SquaresR[2,k]],{k,n}],{n,1,10^3},AxesLabel->{n,f[n]},PlotStyle->Red,Epilog->{Blue,Line[{{0,lr},{10^4,lr}}]}]
]