Mertens Theorem

Author

Eric W. Weisstein
April 24, 2003

This notebook downloaded from http://mathworld.wolfram.com/notebooks/PrimeNumbers/MertensTheorem.nb.

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

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

Additional Authors

Implementation suggestion by Michael Trott
April 17, 2003

Code

prods[n_,s_:-1]:=FoldList[#1/(1+s/#2)&,1,N[Prime[Range[n]]]]
terms[n_,s_:-1]:=Module[{p=N[Prime[Range[n]]]},
MapIndexed[ Log@@p[[#2]]^s #1&,Rest[FoldList[#1/(1+s/#2)&,1,p]]]
]

Terms

N[Times@@Table[1/(1-1/Prime[k]),{k,#}]/Log[Prime[#]]&[50000],20]//Timing

N[Exp[EulerGamma],20]

eg=MapIndexed[#1/Log@@Prime[#2]&,Rest[prods[200]]];

%//N

Plot

<<Graphics`Colors`

MakeBoxes[ominus,TraditionalForm]:=RowBox[{FractionBox["1",RowBox[{"ln"," ",SubscriptBox["p","n"]}]],RowBox[{UnderoverscriptBox["∏",RowBox[{"k","=","1"}],"n"],FractionBox["1",RowBox[{"1","-",FractionBox["1",SubscriptBox["p","k"]]}]]}]}]

ominus//TraditionalForm

With[{eg=Exp[EulerGamma]},
Show[GraphicsArray[
ListPlot[MapIndexed[#1/Log@@Prime[#2]&,Rest[prods[#]]],PlotStyle->Red,PlotJoined->True,DisplayFunction->Identity,
AxesLabel->TraditionalForm/@{n,ominus},
AxesOrigin->{0,eg},
Epilog->{Blue,Text[TraditionalForm[eg],{-#/20,eg}]}
]&/@{10^3,10^4}],GraphicsSpacing->-.1]
]

Inequality (Subscript[a, n])< (e^γ)

N[Exp[EulerGamma],20]

Min[terms[10^5,-1]]//Timing

Min[terms[10^6,-1]]//Timing

Min[terms[10^7,-1]]//Timing

Extension to +

Plot

<<Graphics`Colors`

MakeBoxes[oplus,TraditionalForm]:=RowBox[{RowBox[{"ln"," ",SubscriptBox["p","n"]}],RowBox[{UnderoverscriptBox["∏",RowBox[{"k","=","1"}],"n"],FractionBox["1",RowBox[{"1","+",FractionBox["1",SubscriptBox["p","k"]]}]]}]}]

oplus//TraditionalForm

With[{asymp=Pi^2/(6Exp[EulerGamma])},
Show[GraphicsArray[{
ListPlot[MapIndexed[#1 Log@@Prime[#2]&,Rest[prods[#,1]]],PlotStyle->Red,PlotJoined->True,DisplayFunction->Identity,
AxesOrigin->{0,asymp},
Epilog->{Blue,Text[TraditionalForm[asymp],{-#/6,asymp}]},
AxesLabel->TraditionalForm/@{n,oplus}
]&/@{10^3,10^4}
}],GraphicsSpacing->0]
]

Limit

N[Pi^2/(6Exp[EulerGamma]),20]

Max[terms[10^5,1]]//Timing

Max[terms[10^6,1]]//Timing

Max[terms[10^7,1]]//Timing